Skip to content

Commit 1beb7ee

Browse files
authored
fix: include contents of Exceptions(s) in coding guidelines issue template into generated RST guideline (#258)
1 parent a3568a1 commit 1beb7ee

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

generate_guideline_templates.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def guideline_rst_template(
4545
scope: str,
4646
tags: str,
4747
amplification: str,
48+
exceptions: str,
4849
rationale: str,
4950
non_compliant_ex_prose: str,
5051
non_compliant_ex: str,
@@ -67,6 +68,16 @@ def norm(value: str) -> str:
6768

6869
indented_compliant_ex = indent(compliant_example.strip(), " " * 13)
6970
indented_non_compliant_ex = indent(non_compliant_ex.strip(), " " * 13)
71+
72+
# Build the exception section only if exceptions content is provided
73+
exception_section = ""
74+
if exceptions and exceptions.strip():
75+
exception_section = f"""
76+
**Exception**
77+
78+
{exceptions.strip()}
79+
"""
80+
7081
guideline_text = dedent(f"""
7182
.. guideline:: {guideline_title.strip()}
7283
:id: {guideline_id}
@@ -79,7 +90,7 @@ def norm(value: str) -> str:
7990
:tags: {tags}
8091
8192
{amplification.strip()}
82-
93+
{exception_section}
8394
.. rationale::
8495
:id: {rationale_id}
8596
:status: {norm(status)}
@@ -130,6 +141,7 @@ def generate_guideline_template():
130141
scope="",
131142
tags="",
132143
amplification="Description of the guideline goes here.",
144+
exceptions="",
133145
rationale="Explanation of why this guideline is important.",
134146
non_compliant_ex_prose="Explanation of code example.",
135147
non_compliant_ex=""" fn example_function() {\n // Non-compliant implementation\n } """,

scripts/guideline_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ def get(key):
184184
md_to_rst(get("compliant_example_prose")), " " * 16
185185
)
186186

187+
# Process exceptions field - convert to RST and indent appropriately
188+
exceptions_raw = get("exceptions")
189+
exceptions_text = ""
190+
if exceptions_raw:
191+
exceptions_text = indent(md_to_rst(exceptions_raw), " " * 12)
192+
187193
guideline_text = guideline_rst_template(
188194
guideline_title=get("guideline_title"),
189195
category=get("category"),
@@ -195,6 +201,7 @@ def get(key):
195201
scope=get("scope"),
196202
tags=get("tags"),
197203
amplification=amplification_text,
204+
exceptions=exceptions_text,
198205
rationale=rationale_text,
199206
non_compliant_ex_prose=non_compliant_ex_prose_text,
200207
non_compliant_ex=format_code_block(get("non_compliant_ex")),

0 commit comments

Comments
 (0)