From 260bcb0176947ed84a41ff313d551d3c68fdd33e Mon Sep 17 00:00:00 2001 From: Pete LeVasseur Date: Sun, 7 Dec 2025 23:15:07 +0900 Subject: [PATCH] fix: include contents of Exceptions(s) in coding guidelines issue template into generated RST guideline --- generate_guideline_templates.py | 14 +++++++++++++- scripts/guideline_utils.py | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/generate_guideline_templates.py b/generate_guideline_templates.py index e1c2f101a..2b5e44cfc 100755 --- a/generate_guideline_templates.py +++ b/generate_guideline_templates.py @@ -45,6 +45,7 @@ def guideline_rst_template( scope: str, tags: str, amplification: str, + exceptions: str, rationale: str, non_compliant_ex_prose: str, non_compliant_ex: str, @@ -67,6 +68,16 @@ def norm(value: str) -> str: indented_compliant_ex = indent(compliant_example.strip(), " " * 13) indented_non_compliant_ex = indent(non_compliant_ex.strip(), " " * 13) + + # Build the exception section only if exceptions content is provided + exception_section = "" + if exceptions and exceptions.strip(): + exception_section = f""" + **Exception** + + {exceptions.strip()} +""" + guideline_text = dedent(f""" .. guideline:: {guideline_title.strip()} :id: {guideline_id} @@ -79,7 +90,7 @@ def norm(value: str) -> str: :tags: {tags} {amplification.strip()} - +{exception_section} .. rationale:: :id: {rationale_id} :status: {norm(status)} @@ -130,6 +141,7 @@ def generate_guideline_template(): scope="", tags="", amplification="Description of the guideline goes here.", + exceptions="", rationale="Explanation of why this guideline is important.", non_compliant_ex_prose="Explanation of code example.", non_compliant_ex=""" fn example_function() {\n // Non-compliant implementation\n } """, diff --git a/scripts/guideline_utils.py b/scripts/guideline_utils.py index 4be1740d1..5d0f46ebe 100644 --- a/scripts/guideline_utils.py +++ b/scripts/guideline_utils.py @@ -184,6 +184,12 @@ def get(key): md_to_rst(get("compliant_example_prose")), " " * 16 ) + # Process exceptions field - convert to RST and indent appropriately + exceptions_raw = get("exceptions") + exceptions_text = "" + if exceptions_raw: + exceptions_text = indent(md_to_rst(exceptions_raw), " " * 12) + guideline_text = guideline_rst_template( guideline_title=get("guideline_title"), category=get("category"), @@ -195,6 +201,7 @@ def get(key): scope=get("scope"), tags=get("tags"), amplification=amplification_text, + exceptions=exceptions_text, rationale=rationale_text, non_compliant_ex_prose=non_compliant_ex_prose_text, non_compliant_ex=format_code_block(get("non_compliant_ex")),