Skip to content

docs: Convert github alerts to sphinx admonitions #1483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nealvaidya
Copy link

@nealvaidya nealvaidya commented Jun 11, 2025

Overview:

Adds a sphinx extension to automatically convert github markdown style alerts to sphinx admonitions during the sphinx build process. This means that > [!NOTE], > [!WARNING] etc. will render appropriately in GitHub and on docs.nvidia.com

Summary by CodeRabbit

  • New Features

    • Introduced support for converting GitHub-style alert blockquotes (e.g., [!note], [!warning]) in Markdown documentation into visually distinct admonition boxes during the Sphinx build process.
    • Added a custom Sphinx extension to enable this alert conversion, now activated in the documentation build configuration.
  • Documentation

    • Updated documentation configuration to include the new alert conversion extension.

Adds a sphinx extension to automatically convert github markdown style
alerts to sphinx admonitions during the sphinx build process. This means
that `> [!NOTE]`, `> [!WARNING]` etc. will render appropriately in
GitHub and on docs.nvidia.com

Signed-off-by: Neal Vaidya <[email protected]>
Copy link

copy-pr-bot bot commented Jun 11, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Walkthrough

A new custom Sphinx extension for converting GitHub-style markdown alert blockquotes into MyST admonitions has been introduced. The extension is registered in the documentation build configuration, and supporting module metadata is added. The documentation build process is updated to recognize and utilize this new extension.

Changes

File(s) Change Summary
docs/_extensions/init.py Added module with Apache License, docstring, and __version__ metadata.
docs/_extensions/github_alerts.py Introduced Sphinx extension for AST-based conversion of GitHub alert blockquotes to MyST admonitions.
docs/conf.py Updated sys.path to include _extensions and enabled the github_alerts extension in Sphinx config.

Sequence Diagram(s)

sequenceDiagram
    participant Sphinx
    participant GitHubAlertsTransformer
    participant Document

    Sphinx->>GitHubAlertsTransformer: On 'doctree-resolved' event (for markdown files)
    GitHubAlertsTransformer->>Document: Scan for GitHub alert blockquotes
    GitHubAlertsTransformer->>Document: Replace blockquotes with MyST admonition nodes
    GitHubAlertsTransformer-->>Sphinx: Transformation complete
Loading

Poem

In docs we hop, alert and bright,
GitHub blocks now shine just right.
MyST admonitions take the stage,
As rabbits tweak the Sphinx-built page.
With custom code and clever cheer,
Our docs grow clearer, year by year!
🐇✨


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/_extensions/github_alerts.py (1)

234-234: Consider removing or documenting the unused github_alerts_mapping config.

The github_alerts_mapping configuration value is added but never used in the implementation. If it's intended for future use, consider adding a comment explaining its purpose. Otherwise, it should be removed to avoid confusion.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e924a7c and 3ae7ce1.

📒 Files selected for processing (3)
  • docs/_extensions/__init__.py (1 hunks)
  • docs/_extensions/github_alerts.py (1 hunks)
  • docs/conf.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (3)
docs/_extensions/__init__.py (1)

1-19: LGTM! Clean module initialization.

The package structure is well-organized with proper licensing header and clear module documentation.

docs/conf.py (1)

28-28: Configuration changes look good.

The modifications correctly set up the custom extension by:

  • Adding the _extensions directory to the Python path
  • Registering the github_alerts extension

The use of sys.path.insert(0, ...) ensures custom extensions take precedence.

Also applies to: 38-38, 85-85

docs/_extensions/github_alerts.py (1)

1-246: Well-structured Sphinx extension with comprehensive functionality.

The extension follows Sphinx best practices with proper event handling, configuration management, and error handling. The AST-based approach for transforming GitHub alerts is robust and maintainable.

- Use classes in maps instead of instances
- remove unused config map

Signed-off-by: Neal Vaidya <[email protected]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ae7ce1 and b1da5ee.

📒 Files selected for processing (1)
  • docs/_extensions/github_alerts.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (1)
docs/_extensions/github_alerts.py (1)

42-52: Good fix: ALERT_MAPPING now stores classes, not instances

Changing the mapping to use node classes eliminates the shared-instance problem highlighted in the earlier review. Nice job.

@nealvaidya nealvaidya marked this pull request as draft June 11, 2025 23:44
Copy link
Collaborator

@whoisj whoisj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to test these changes, but the code itself looks very promising!

THANKS!!!

Copy link
Collaborator

@whoisj whoisj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to verify that this works as intended. 🎉 :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants