Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/generate-rst-comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
normalize_md,
)

# SPDX header to prepend to guideline files
GUIDELINE_FILE_HEADER = """\
.. SPDX-License-Identifier: MIT OR Apache-2.0
SPDX-FileCopyrightText: The Coding Guidelines Subcommittee Contributors

"""


def extract_guideline_id(rst_content: str) -> str:
"""
Expand Down Expand Up @@ -57,6 +64,9 @@ def generate_comment(rst_content: str, chapter: str) -> str:
chapter_slug = chapter_to_filename(chapter)
guideline_id = extract_guideline_id(rst_content)

# Prepend the SPDX header to the RST content for display
full_rst_content = GUIDELINE_FILE_HEADER + rst_content.strip()

# Determine target path based on whether we have a guideline ID
if guideline_id:
target_dir = f"src/coding-guidelines/{chapter_slug}/"
Expand Down Expand Up @@ -122,7 +132,7 @@ def generate_comment(rst_content: str, chapter: str) -> str:
<summary><strong>📄 Click to expand RST content</strong></summary>

```rst
{rst_content}
{full_rst_content}
```

</details>
Expand Down