Skip to content

Commit e2deadf

Browse files
authored
docs: improve generated document guidance (#296)
1 parent 548b508 commit e2deadf

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

scripts/generate-rst-comment.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,20 +347,32 @@ def generate_comment(rst_content: str, chapter: str, test_results: List[CodeTest
347347
if guideline_id:
348348
target_dir = f"src/coding-guidelines/{chapter_slug}/"
349349
target_file = f"{target_dir}{guideline_id}.rst.inc"
350+
chapter_index_file = f"{target_dir}/index.rst"
350351
file_instructions = f"""
351352
### 📁 Target Location
352353
353354
Create a new file: `{target_file}`
354355
355356
> **Note:** The `.rst.inc` extension prevents Sphinx from auto-discovering the file.
356-
> It will be included via the chapter's `index.rst`."""
357-
else:
358-
# Fallback for legacy structure (shouldn't happen with new template)
359-
target_file = f"src/coding-guidelines/{chapter_slug}.rst"
360-
file_instructions = f"""
361-
### 📁 Target File
357+
> It will be included via the chapter's `index.rst`.
358+
359+
We add it to this path, to allow the newly added guideline to appear in the correct chapter.
360+
361+
### 🗂️ Update Chapter Index
362362
363-
Add this guideline to: `{target_file}`"""
363+
Update `{chapter_index_file}` to include {guideline_id}.rst.inc, like so:
364+
365+
```
366+
Expressions <- this should match {chapter_slug}
367+
===========
368+
369+
.. include:: gui_7y0GAMmtMhch.rst.inc -| existing guidelines
370+
.. include:: gui_ADHABsmK9FXz.rst.inc |
371+
.. include:: gui_HDnAZ7EZ4z6G.rst.inc -|
372+
.. include:: {guideline_id}.rst.inc <- your new guideline to add
373+
```"""
374+
else:
375+
return "No guideline ID generated, failing!"
364376

365377
comment = f"""## 📋 RST Preview for Coding Guideline
366378

0 commit comments

Comments
 (0)