-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Formalize book.js patch management system #2948
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
base: main
Are you sure you want to change the base?
Formalize book.js patch management system #2948
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@subhobhai943 Thank you for your contribution! Before we proceed with the code review, please sign the CLA following the instructions from the CLA bot above my comment. |
|
|
||
| - name: Make scripts executable | ||
| run: | | ||
| chmod +x theme/scripts/*.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scripts should just be stored as executable directly in the repository. The workflow should not have to fix this, we can fix it once and for all 😄
| - name: Install patch utility | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this is part of a base install on the GitHub runners?
| echo "Error: comprehensive-rust-enhancements.js is missing" | ||
| exit 1 | ||
| fi | ||
| echo "✅ Modular enhancements file exists" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't really output emojis in any of our other scripts. Please try to follow the existing style and remove it from here.
|
Thanks for the review, @mgeisler!
The updated workflow keeps the verification steps intact and uses the scripts directly. Please let me know if you’d like any additional adjustments. |
Overview
This PR implements a comprehensive patch management system for
theme/book.jscustomizations, addressing issue #2924. Instead of directly editingbook.js, we now maintain customizations as patches that can be applied to any mdbook version.🎯 Problem Solved
Before: Direct edits to
book.jsmade mdbook updates risky and customizations hard to trackAfter: Formalized patch system with modular enhancements, CI verification, and automated tools
🛠️ Implementation
1. Patch Management System
theme/patches/original/book.js- Vanilla mdbook v0.4.40 book.jstheme/patches/*.patch- Individual patches for each customizationtheme/scripts/- Management scripts for applying, verifying, and extracting patches2. Modular Enhancements
theme/comprehensive-rust-enhancements.js- Contains most custom logicbook.js(just integration points)3. Automation & CI
📝 Files Added/Modified
New Files
Modified Files
book.toml- Addedcomprehensive-rust-enhancements.jsto additional-js🎆 Features & Improvements
Customizations Preserved
#![allow(unused)]unlesswarnunusedclassNew Capabilities
make apply-patchesmake verify-patchesmake update-mdbook VERSION=v0.4.41🧪 Testing
Manual Testing
CI Testing
📋 Usage Examples
For Daily Development
# Normal development - no changes needed mdbook serveAdding New Customizations
Updating mdbook Version
🔗 Addresses Issue Requirements
✅ Store modifications as patches - Done via
theme/patches/*.patch✅ CI verification - Implemented in
.github/workflows/verify-book-js-patches.yml✅ Update script -
theme/scripts/update-mdbook-version.sh✅ Minimize patches - Modular design reduces patch size
✅ Future-compatible - System works with any mdbook version
🤝 Collaboration Notes
Following @djmitche's suggestion to minimize patches through modularization and @mgeisler's vision for a robust patch system. This implementation:
📚 Documentation
Complete documentation is available in
theme/README-patching.mdincluding:Fixes #2924
Testing Checklist: