Skip to content

Conversation

@winglian
Copy link
Collaborator

@winglian winglian commented Aug 8, 2025

WIP

Summary by CodeRabbit

  • New Features

    • Added automated generation of documentation for usage examples, including an index and individual pages for each example.
    • Introduced a new "Usage Examples" section in the website sidebar for easier navigation.
    • Implemented an allowlist to specify which examples are included in the documentation.
  • Chores

    • Updated project configuration to support multiple documentation generation scripts.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

📝 Walkthrough

Walkthrough

The changes introduce automated documentation generation for usage examples. A new script processes a YAML allowlist to convert example README files into Quarto markdown documents, handling assets and generating an index. Project configuration is updated to run this script pre-render and to add a new sidebar section for usage examples.

Changes

Cohort / File(s) Change Summary
Project configuration updates
_quarto.yml
Modified pre-render scripts to include the new example docs generator; updated sidebar to add a "Usage Examples" section that lists all example .qmd files before "Troubleshooting".
Example allowlist
docs/scripts/examples-allowlist.yml
Added a YAML file listing allowed example folders: distributed-parallel, slurm, llama-3, and gpt-oss.
Example docs generation script
docs/scripts/generate_examples_docs.py
Added a Python script to read the allowlist, process README files from allowed examples, copy and rewrite asset links, generate corresponding .qmd files with front matter, and create an index listing all examples.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch examples-docs

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.
  • 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.

Support

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

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 docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for 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.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2025

📖 Documentation Preview: https://689644a3fd6b0383be07d346--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit 6b60e0a

@codecov
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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: 2

🧹 Nitpick comments (2)
docs/scripts/examples-allowlist.yml (1)

1-5: Keep allow-list alphabetically sorted for simpler diffs

Minor, but ordering the entries (distributed-parallel, gpt-oss, llama-3, slurm) alphabetically avoids churn in future PRs and makes merge-conflicts less likely.

docs/scripts/generate_examples_docs.py (1)

82-85: Avoid double H1 by stripping it before writing .qmd

Because the title is also injected into front-matter, leaving the original # Heading produces two identical H1s on the page.

-        md = readme.read_text(encoding="utf-8")
+        md = readme.read_text(encoding="utf-8")
+        # drop first H1 so front-matter title is the only top-level heading
+        md = "\n".join(line for line in md.splitlines() if not line.startswith("# ") or line.count("#") > 1)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7cfc80e and 6b60e0a.

📒 Files selected for processing (3)
  • _quarto.yml (2 hunks)
  • docs/scripts/examples-allowlist.yml (1 hunks)
  • docs/scripts/generate_examples_docs.py (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: SalmanMohammadi
PR: axolotl-ai-cloud/axolotl#2994
File: index.qmd:7-8
Timestamp: 2025-07-31T11:48:46.313Z
Learning: In documentation workflow testing PRs, temporary test content like "test test" may be intentionally added to trigger documentation preview actions and validate workflow fixes, rather than being accidental debug text.
📚 Learning: 2025-07-31T11:48:46.313Z
Learnt from: SalmanMohammadi
PR: axolotl-ai-cloud/axolotl#2994
File: index.qmd:7-8
Timestamp: 2025-07-31T11:48:46.313Z
Learning: In documentation workflow testing PRs, temporary test content like "test test" may be intentionally added to trigger documentation preview actions and validate workflow fixes, rather than being accidental debug text.

Applied to files:

  • _quarto.yml
🔇 Additional comments (2)
_quarto.yml (1)

3-5: Confirm Quarto accepts list syntax in pre-render

Switching from a scalar to a sequence is correct, but Quarto only picks up scripts that are executable in the build environment. Double-check that docs/scripts/generate_examples_docs.py has the executable bit set (or is invoked through python).

docs/scripts/generate_examples_docs.py (1)

83-85: Quote style in front-matter is YAML, not Python repr

!r may emit single quotes with escapes that YAML doesn’t expect (e.g., backslashes). Use plain strings:

-    fm = f"---\ntitle: {title!r}\nformat:\n  html:\n    toc: true\n---\n\n"
+    fm = f"---\ntitle: \"{title}\"\nformat:\n  html:\n    toc: true\n---\n\n"

Comment on lines +291 to +295
- title: Usage Examples
desc: Example YAML files for training different models
contents:
- docs/examples/*.qmd

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use section: instead of title: for sidebar groups

In the sidebar config every other group uses section:. Quarto’s schema doesn’t recognise title: at this level, so the whole “Usage Examples” block may be ignored.

-        - title: Usage Examples
+        - section: "Usage Examples"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- title: Usage Examples
desc: Example YAML files for training different models
contents:
- docs/examples/*.qmd
- section: "Usage Examples"
desc: Example YAML files for training different models
contents:
- docs/examples/*.qmd
🤖 Prompt for AI Agents
In _quarto.yml around lines 291 to 295, replace the key `title:` with `section:`
for the sidebar group labeled "Usage Examples" because Quarto's schema requires
`section:` at this level for sidebar groups to be recognized. Update the YAML to
use `section:` instead of `title:` to ensure the block is properly included in
the sidebar.

Comment on lines +70 to +73
if not src_path.exists():
return m.group(0) # leave as-is if not found
rel = src_path.relative_to(src_dir)
dest_path = dest_assets / rel
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Handle assets that live outside the example directory

src_path.relative_to(src_dir) raises ValueError if the README references an asset like ../shared/logo.png. That aborts the whole run.

-        rel = src_path.relative_to(src_dir)
+        try:
+            rel = src_path.relative_to(src_dir)
+        except ValueError:
+            # fallback: flatten to basename to keep the run alive
+            rel = src_path.name
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if not src_path.exists():
return m.group(0) # leave as-is if not found
rel = src_path.relative_to(src_dir)
dest_path = dest_assets / rel
if not src_path.exists():
return m.group(0) # leave as-is if not found
try:
rel = src_path.relative_to(src_dir)
except ValueError:
# fallback: flatten to basename to keep the run alive
rel = src_path.name
dest_path = dest_assets / rel
🤖 Prompt for AI Agents
In docs/scripts/generate_examples_docs.py around lines 70 to 73, the code uses
src_path.relative_to(src_dir) which raises a ValueError if the asset path is
outside the example directory. To fix this, add a try-except block around the
relative_to call to catch ValueError and handle such cases gracefully, for
example by skipping those assets or processing them differently to avoid
aborting the entire run.

ROOT = THIS.parents[2] # repo root (docs/scripts -> docs -> ROOT)
EXAMPLES_DIR = ROOT / "examples"
OUTPUT_DIR = ROOT / "docs" / "examples"
ALLOWLIST_YML = THIS.parent / "examples-allowlist.yml"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is an allowlist necessary? I think anything matching README.md within the examples dir seem to be a good check?

We just need to make sure the resulting qmd has execute: false

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants