Skip to content

feat: wire mdbook-mermaid into mdbook build and pages#19

Merged
Chris-godz merged 1 commit intoRethinkCraft:mainfrom
Chris-godz:feat/mdbook-mermaid-pages
Mar 23, 2026
Merged

feat: wire mdbook-mermaid into mdbook build and pages#19
Chris-godz merged 1 commit intoRethinkCraft:mainfrom
Chris-godz:feat/mdbook-mermaid-pages

Conversation

@Chris-godz
Copy link
Copy Markdown
Collaborator

@Chris-godz Chris-godz commented Mar 23, 2026

Summary

  • enable the mdbook-mermaid preprocessor in book/book.toml and keep the readable book/mermaid-init.js bootstrap for the existing Mermaid diagrams
  • install mdbook-mermaid 0.17.0 in both Pages and docs validation workflows, and run mdbook-mermaid install book before each build so the runtime asset is generated there instead of being tracked in git
  • pin mdbook to 0.5.2 in CI so Pages and validation use the same toolchain when building Mermaid-enabled docs
  • ignore regenerated book/mermaid.min.js copies locally so the minified vendor blob does not keep showing up in git diffs

Note

Medium Risk
Medium risk because it changes GitHub Actions build steps and bumps/pins mdbook, which could break docs validation or Pages deployment if the toolchain install or preprocessor behavior differs across runners.

Overview
Mermaid rendering is now built into the mdBook pipeline. The book config enables the mdbook-mermaid preprocessor and loads Mermaid runtime/init JS via additional-js.

CI and Pages workflows now install Rust, mdbook-mermaid (pinned to 0.17.0), and run mdbook-mermaid install book before building; mdbook is pinned to 0.5.2 to keep builds consistent. The generated book/mermaid.min.js is added to .gitignore so the vendored asset isn’t tracked.

Written by Cursor Bugbot for commit 6446f51. This will update automatically on new commits. Configure here.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates Mermaid diagram rendering into the mdBook documentation build process. It configures the mdbook-mermaid preprocessor, includes necessary JavaScript assets for Mermaid, and ensures that the CI environment consistently builds the documentation with Mermaid support. The changes facilitate the display of dynamic diagrams within the documentation, enhancing its clarity and interactivity.

Highlights

  • Mermaid Integration: Enabled the mdbook-mermaid preprocessor and bundled Mermaid runtime assets to ensure existing diagrams render correctly in the published mdBook output.
  • CI Toolchain Alignment: Installed mdbook-mermaid version 0.17.0 in both Pages and docs validation workflows, and added a step to run mdbook-mermaid install book before each build.
  • Version Pinning: Pinned mdbook to version 0.5.2 in CI to standardize the toolchain used for building Mermaid-enabled documentation across Pages and validation environments.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/docs-validate.yml
    • .github/workflows/pages.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request integrates mdbook-mermaid to render diagrams in the documentation. The changes in book.toml correctly configure the preprocessor and add the necessary JavaScript files. The new book/mermaid-init.js script handles theme detection for Mermaid diagrams and reloads the page on theme changes to ensure diagrams are re-rendered correctly.

My review focuses on the new JavaScript file, where I've suggested a few improvements for conciseness and robustness. Specifically, I've pointed out a way to simplify the theme detection logic and how to prevent potential runtime errors when setting up event listeners for theme switching.

Comment on lines +11 to +17
let lastThemeWasLight = true;
for (const cssClass of classList) {
if (darkThemes.includes(cssClass)) {
lastThemeWasLight = false;
break;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This loop to determine the current theme can be made more concise and readable by using the Array.prototype.some() method. This simplifies seven lines of code into one.

Suggested change
let lastThemeWasLight = true;
for (const cssClass of classList) {
if (darkThemes.includes(cssClass)) {
lastThemeWasLight = false;
break;
}
}
const lastThemeWasLight = !darkThemes.some(theme => classList.contains(theme));

Comment on lines +25 to +29
document.getElementById(darkTheme).addEventListener('click', () => {
if (lastThemeWasLight) {
window.location.reload();
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To make the script more robust, consider using optional chaining (?.). This will prevent a runtime error if an element with a given theme ID is not found in the DOM. document.getElementById returns null for non-existent elements, and calling addEventListener on null would crash the script.

Suggested change
document.getElementById(darkTheme).addEventListener('click', () => {
if (lastThemeWasLight) {
window.location.reload();
}
});
document.getElementById(darkTheme)?.addEventListener('click', () => {
if (lastThemeWasLight) {
window.location.reload();
}
});

Comment on lines +33 to +37
document.getElementById(lightTheme).addEventListener('click', () => {
if (!lastThemeWasLight) {
window.location.reload();
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similarly, using optional chaining here will make the script more robust against missing theme-switcher elements. This prevents a potential runtime error if an element with a given theme ID is not found.

Suggested change
document.getElementById(lightTheme).addEventListener('click', () => {
if (!lastThemeWasLight) {
window.location.reload();
}
});
document.getElementById(lightTheme)?.addEventListener('click', () => {
if (!lastThemeWasLight) {
window.location.reload();
}
});

@Chris-godz Chris-godz force-pushed the feat/mdbook-mermaid-pages branch from 0263110 to d7363cd Compare March 23, 2026 09:32
- feat(book): enable the mermaid preprocessor and keep the readable init bootstrap without tracking the minified vendor blob
- ci(pages): install mdbook-mermaid 0.17.0, pin mdbook 0.5.2, and generate Mermaid assets before the Pages build
- ci(docs-validate): mirror the mdbook-mermaid setup and mdbook pin in docs validation
- chore(gitignore): ignore regenerated book/mermaid.min.js copies from local installs
@Chris-godz Chris-godz force-pushed the feat/mdbook-mermaid-pages branch from d7363cd to 6446f51 Compare March 23, 2026 09:40
@Chris-godz
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@Chris-godz Chris-godz merged commit 02dcfc0 into RethinkCraft:main Mar 23, 2026
5 checks passed
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.

1 participant