Skip to content

Commit b84ed59

Browse files
authored
fix: show rst preview warnings before steps (#384)
1 parent 171ae43 commit b84ed59

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

scripts/generate-rst-comment.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -618,16 +618,12 @@ def generate_comment(
618618
else:
619619
return "No guideline ID generated, failing!"
620620

621-
comment = f"""## 📋 RST Preview for Coding Guideline
622-
623-
This is an automatically generated preview of your coding guideline in reStructuredText format.
624-
{file_instructions}
625-
626-
{test_results_section}
627-
628-
{bib_results_section}
629-
630-
### 📝 How to Use This
621+
header_section = (
622+
"## 📋 RST Preview for Coding Guideline\n\n"
623+
"This is an automatically generated preview of your coding guideline "
624+
"in reStructuredText format."
625+
)
626+
how_to_use_section = f"""### 📝 How to Use This
631627
632628
1. **Fork the repository** (if you haven't already) and clone it locally
633629
2. **Create a new branch** from `main`:
@@ -656,22 +652,31 @@ def generate_comment(
656652
git commit -m "Add guideline: <your guideline title>"
657653
git push origin guideline/your-descriptive-branch-name
658654
```
659-
8. **Open a Pull Request** against `main`
660-
661-
<details>
655+
8. **Open a Pull Request** against `main`"""
656+
rst_preview_section = f"""<details>
662657
<summary><strong>📄 Click to expand RST content</strong></summary>
663658
664659
```rst
665660
{full_rst_content}
666661
```
667662
668-
</details>
669-
670-
---
671-
<sub>🤖 This comment was automatically generated from the issue content. It will be updated when you edit the issue body.</sub>
672-
673-
<!-- rst-preview-comment -->
674-
"""
663+
</details>"""
664+
footer_section = (
665+
"---\n"
666+
"<sub>🤖 This comment was automatically generated from the issue "
667+
"content. It will be updated when you edit the issue body.</sub>\n\n"
668+
"<!-- rst-preview-comment -->"
669+
)
670+
sections = [
671+
header_section,
672+
test_results_section,
673+
bib_results_section,
674+
file_instructions.strip(),
675+
how_to_use_section,
676+
rst_preview_section,
677+
footer_section,
678+
]
679+
comment = "\n\n".join(section for section in sections if section)
675680
return comment
676681

677682

0 commit comments

Comments
 (0)