Update documentation build: proper notes rendering on GitHub and ReadTheDocs#3506
Conversation
Summary by CodeRabbit
WalkthroughConverts GitHub-style blockquote callouts in docs to ProperDocs/MkDocs admonition syntax and updates the docs-generation script to perform per-file replacements, convert GFM admonitions to MkDocs format, and generate multiple documentation targets (contributing.md, index.md, examples.md). Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #3506 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 313 313
Lines 18659 18659
Branches 2383 2383
=========================================
Hits 18659 18659 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/docs/gen_index.py`:
- Around line 39-77: The gfm_to_mkdocs function is flagged for high cognitive
complexity; refactor by extracting subroutines: create
parse_admonition_header(lines, i) to detect and return (note_type, new_index)
using GFM_MKDOCS_MAPPING, parse_title_line(lines, i) to return (title,
new_index) when matching the bold title pattern, and
parse_admonition_body(lines, i) to collect and return (note_body_lines,
new_index) handling the ">" trimming logic, then have gfm_to_mkdocs orchestrate
these helpers and call a small assemble_admonition(note_type, title, note_body)
to produce the "!!! ..." and indented body lines; this splits the main while
loop into clear units (functions referenced: gfm_to_mkdocs,
parse_admonition_header, parse_title_line, parse_admonition_body,
assemble_admonition) and will lower cognitive complexity without changing
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f75f4813-2eb9-4193-be48-0fe68b6d7b85
📒 Files selected for processing (4)
CONTRIBUTING.mdREADME.mddocs/examples.mdscripts/docs/gen_index.py
PPsyrius
left a comment
There was a problem hiding this comment.
Great execution IMO
I was originally thinking of https://github.com/PGijsbers/admonitions, but this PR avoids introducing new dependencies, so it's a win for me
There was a problem hiding this comment.
♻️ Duplicate comments (2)
scripts/docs/gen_index.py (2)
61-64: 🧹 Nitpick | 🔵 TrivialCombine nested
ifstatements.Per Ruff's SIM102 warning - these can be merged into a single condition with the walrus operator.
Suggested fix
title = "" - if i < len(lines): - if match := re.match(r"^>\s*\*\*(.+?)\*\*", lines[i]): - title = f' "{match.group(1)}"' - i += 1 + if i < len(lines) and (match := re.match(r"^>\s*\*\*(.+?)\*\*", lines[i])): + title = f' "{match.group(1)}"' + i += 1🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/docs/gen_index.py` around lines 61 - 64, Combine the nested ifs into one condition using the walrus operator: replace the outer check "if i < len(lines)" and the inner "if match := re.match(..., lines[i])" with a single conditional that both verifies the index and assigns match (e.g., test that i < len(lines) and bind match from re.match on lines[i] in the same expression); update the block that sets title and increments i to use the bound match variable (symbols to locate: i, lines, match, re.match, title).
45-81: 🧹 Nitpick | 🔵 TrivialCognitive complexity exceeds threshold.
SonarCloud flags this at 18 (limit 15). A past review suggested extracting helper functions for header/body parsing. Worth addressing if this script grows further.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/docs/gen_index.py` around lines 45 - 81, The gfm_to_mkdocs function (in scripts/docs/gen_index.py) is too complex; refactor by extracting discrete helpers to parse the admonition header and body: create a helper like parse_admonition_header(lines, i) that detects the "> [!TYPE]" line, returns the note_type and the next index, another helper parse_admonition_title(lines, i) that returns the title (or empty) and next index by matching the bold title pattern, and a parse_admonition_body(lines, i) that collects and returns the unprefixed body lines and the next index; then simplify gfm_to_mkdocs to use these helpers to produce the "!!! {note_type}{title}" and indented body lines, reducing branching and cognitive complexity in gfm_to_mkdocs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@scripts/docs/gen_index.py`:
- Around line 61-64: Combine the nested ifs into one condition using the walrus
operator: replace the outer check "if i < len(lines)" and the inner "if match :=
re.match(..., lines[i])" with a single conditional that both verifies the index
and assigns match (e.g., test that i < len(lines) and bind match from re.match
on lines[i] in the same expression); update the block that sets title and
increments i to use the bound match variable (symbols to locate: i, lines,
match, re.match, title).
- Around line 45-81: The gfm_to_mkdocs function (in scripts/docs/gen_index.py)
is too complex; refactor by extracting discrete helpers to parse the admonition
header and body: create a helper like parse_admonition_header(lines, i) that
detects the "> [!TYPE]" line, returns the note_type and the next index, another
helper parse_admonition_title(lines, i) that returns the title (or empty) and
next index by matching the bold title pattern, and a
parse_admonition_body(lines, i) that collects and returns the unprefixed body
lines and the next index; then simplify gfm_to_mkdocs to use these helpers to
produce the "!!! {note_type}{title}" and indented body lines, reducing branching
and cognitive complexity in gfm_to_mkdocs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8259718c-fa37-4f99-885b-3414d74ee499
📒 Files selected for processing (2)
docs/examples.mdscripts/docs/gen_index.py
Co-authored-by: Panpakorn Siripanich <19505219+PPsyrius@users.noreply.github.com> Signed-off-by: ~Jhellico <KJhellico@users.noreply.github.com>
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/examples.md`:
- Around line 528-535: The GFM admonition for the Tip block uses the marker
"[!tip]" without an explicit title, which causes ProperDocs to drop the "Tip"
header; update the admonition by adding an explicit title marker (e.g., change
"[!tip]" to "[!tip] Tip") for the block that describes the Holidays object's
language/default_language behavior so the generated docs retain the "Tip"
heading.
- Around line 14-17: The generated GFM admonition "!!! tip" lacks an explicit
title so ProperDocs drops the "Tip" header; update the source admonition so the
callout includes an explicit title marker immediately after the "!!! tip" token
(i.e., add the explicit title string for the tip admonition) so the converted
output preserves the "Tip" title in ProperDocs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a7466855-0162-43b6-8562-5902ba3ec67b
📒 Files selected for processing (1)
docs/examples.md
Proposed change
ProperDocs admonitions are not supported by the GitHub renderer:

GitHub Flavored Markdown notes are just ignored by ProperDocs:
instead of
So the best solution seems to be keeping all notes in GFM format and converting them to admonitions format when generating documentation in ProperDocs.
Type of change
holidaysfunctionality in general)Checklist
make checklocally; all checks and tests passed.