From 2970eec72c57e122b24be51076531c1ace1f6428 Mon Sep 17 00:00:00 2001 From: Jorge Marques Date: Mon, 13 Jan 2025 13:22:22 +0100 Subject: [PATCH] scripts: backstage: Warn on missing description If a doc page does not contain an overview/short-description, exit with an error. Fix IndexError at get_description. Signed-off-by: Jorge Marques --- .github/scripts/gen_backstage_yaml.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/scripts/gen_backstage_yaml.py b/.github/scripts/gen_backstage_yaml.py index 44cba16da29..137c40bf909 100644 --- a/.github/scripts/gen_backstage_yaml.py +++ b/.github/scripts/gen_backstage_yaml.py @@ -1,6 +1,7 @@ from typing import Dict, List, Tuple from os import path, mkdir, walk, chdir from glob import glob +import sys import yaml import re import argparse @@ -93,7 +94,8 @@ def get_description_parts( def get_description( - data: List[str] + data: List[str], + file: str ) -> List[str]: desc = [] directive_lock = False @@ -109,6 +111,10 @@ def get_description( else: continue desc.append(d) + + if len(desc) < 3: + sys.exit(f"{file}: Missing overview/short-description.") + desc.pop() desc.pop() return desc @@ -139,7 +145,7 @@ def get_description_library( title = data[index-3][:-1] data = data[index:] - desc = get_description(data) + desc = get_description(data, file) return *get_description_parts(desc), title @@ -182,7 +188,7 @@ def get_description_project( index = index+1 if data[index] == '\n' else index data = data[index:] - desc = get_description(data) + desc = get_description(data, file) return *get_description_parts(desc), title