feat: upgrade mdBook to 0.5.x with TAMU theme compatibility fixes#58
Open
bronius wants to merge 6 commits into
Open
feat: upgrade mdBook to 0.5.x with TAMU theme compatibility fixes#58bronius wants to merge 6 commits into
bronius wants to merge 6 commits into
Conversation
Gets us 99% of the way with some minor outlying concerns remaining - Dont need to retain backups - Only spot-checked - Left sidebar formatting and interactions still a bit off Major change: Replaced adminish processor with mdbook v0.5 standard, swapped out collapsible solution
Clean up .backups/, migration scripts, patch files, and planning documents committed as part of initial AI-assisted upgrade work. Leaves only functional changes: theme/, book.toml, src/ content, and README.
- Bump mdbook-version from 0.4.52 to 0.5.3 in both gh-pages.yml and preview.yml - Remove use-admonish: true (admonish preprocessor replaced by native mdBook 0.5+ block-quote admonitions) - Remove @import 'variables.css' from theme/css/chrome.css and theme/css/general.css: mdBook 0.5.x hashes output filenames (variables-HASH.css), making bare @import 'variables.css' a dead 404 on every page load. Variables are already linked correctly via HTML <link> tags mdBook generates; the @import was redundant.
|
…h look
Map blockquote-tag-{note,tip,important,warning,caution} to the same
color palette as the former mdbook-admonish plugin:
note → blue #448aff
tip → teal #00bfa5
important → cyan #00b8d4
warning → orange #ff9100
caution → red #ff1744
Each type gets a colored left border (0.4rem) and a tinted title
background row with matching text/icon color, matching the original
admonish box layout (border-radius, box-shadow, no top/bottom borders).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While we intended to replace this docs site with something other than mdbook, for now, it is difficult or impossible to introduce modern plugins/preprocessors (like mermaid), and we have AI.
This PR upgrades the site content and github workflows from mdBook 0.4.x to mdBook 0.5.x and brings the custom TAMU theme fully in line with the new HTML output structure, JavaScript API, and CSS conventions introduced in 0.5.
My goal was to preserve all previous look-and-feel and content without introducing anything new. In the end, we got some standardizations and cleanup, and I am really pleased with how it turned out:
PR preview:
https://docs.cloud.tamu.edu/pr-preview/pr-58/index.html
Original:
https://docs.cloud.tamu.edu/index.html
What changed
book.toml[book]/ tool config for 0.5.x compatibilitymdbook-admonishpreprocessor (replaced by native[!NOTE]/[!WARNING]/[!TIP]/[!IMPORTANT]block-quote syntax)theme/index.hbs<i class="fa fa-*">icon tags (font not bundled in 0.5.x) with{{fa "solid" "..."}}SVG helper calls for hamburger, theme-picker, and search buttonswindow.innerWidth(reliable at parse time) instead ofdocument.body.clientWidth(unreliable before layout), and correctly defaults tohiddenon narrow viewportspreviousElementSiblingwalk (wrong element) with a proper ancestor walk up to#sidebar, marking everyli.chapter-itemexpanded.chapter-fold-togglefrom link-rewriting and active-detection query selectors (it's an<a>tag but not a navigation link)theme/book.js.closest('li.chapter-item')instead of.parentElement(which stopped atspan.chapter-link-wrapper, never toggling the right element)themes()IIFE stylesheet selectors: changed[href$='ayu-highlight.css']("ends-with") to[href*='ayu-highlight']("contains") — mdBook 0.5.x hashes all output asset filenames (e.g.ayu-highlight-3fdfc3ac.css), so exact-suffix selectors always returnednull, causing aTypeErrorthat crashed the entire<script>block and prevented thesidebar()IIFE from ever runninga.toggleand new-stylea.chapter-fold-togglefor fold eventstheme/css/chrome.css#menu-barselector (was#mdbook-menu-bar— that ID does not exist in any mdBook template).chapter li { display: flex }→display: blockwith.chapter-link-wrapper { display: flex }so chapter items stack vertically instead of rendering in a horizontal row.chapter li:not(.expanded) + li > ol(wrong: targeted a sibling's child) to.chapter li:not(.expanded) > ol(correct: hides own direct child<ol>).fa-svg svg { width: 1em; height: 1em; fill: currentColor }so{{fa}}SVG icons are sized and visibleflex: 0 0 auto/margin-left: autoon fold-toggle anchors so the❱arrow stays right-aligned and doesn't stretchtheme/css/aggie-custom.cssREADME.mdmdbook-admonishfence-block examples with native[!NOTE]block-quote syntaxsrc/cloud/azure/azure_network.md(new)src/SUMMARY.md— needs a follow-up to add it under Cloud Computing Providers → Azure (or similar)src/kion/andsrc/cloud/content filesmdbook-admonishfences to native admonition syntaxLandmines to know before reviewing
mdBook asset filename hashing: 0.5.x content-hashes ALL output CSS/JS files. Any code that queries
[href$='something.css']or[src$='something.js']will silently returnnull. Use*=(contains) instead of$=. We hit this hard withthemes().themes()crash cascades silently: Becausethemes()andsidebar()are both IIFEs in the same compiled<script>block, a thrown exception inthemes()killssidebar()too — no click handler, no hamburger toggle, no responsive hide. Symptom: button renders but does nothing.chapter-fold-toggleis an<a>tag: mdBook 0.5.x wraps each collapsible TOC item as<li><span class="chapter-link-wrapper"><a href="...">Title</a><a class="chapter-fold-toggle">❱</a></span><ol>...</ol></li>. The toggle anchor lives inside a<span>, not directly in the<li>—.parentElementfrom the toggle gets you the span, not theli. Must use.closest('li.chapter-item').search()in searcher.js still has a null-addEventListener error:initSearchInteractionstries to attach a listener to an element that doesn't exist on pages without a search bar. Non-fatal, but noisy in console. Not addressed in this PR./css/variables.css404: The hashedchrome-*.csshas an@import url('/css/variables.css')that 404s because the path is absolute and the file is served at a hashed path. Also non-fatal (variables are inlined), but worth cleaning up in a follow-up.src/cloud/azure/azure_network.mdis orphaned: New file, not in SUMMARY.md, not built into the book. Intentionally left for a follow-up; noted here so a reviewer doesn't miss it.Hat-tip (well-deserved, obviously)
A very special, completely unsolicited round of applause for the human on this team — who, against all odds, noticed things. Groundbreaking stuff.
Specifically:
"Hamburger icon shows but doesn't affect sidebar menu toggle" — Your eagle-eyed observation that a button renders but does nothing led us directly to the
themes()IIFE crash, which was silently killingsidebar()and leaving the entire interactive layer dead. Without that nudge, we'd have shipped a beautiful, completely static sidebar."Sidebar menu isn't initially hidden on below-the-break" — You caught that the responsive hide wasn't working, which confirmed the JS wasn't running at all, which confirmed the crash theory. Two bugs, one observation. Efficiency.
So yes: the AI wrote code, the AI broke code, the AI fixed the code it broke, and you watched carefully enough to notice the parts that were still broken. That's called pair programming, and it absolutely counts. High five. 🖐️
Testing
mdbook build— clean, no errorsmdbook serve --port 3002— site loads, sidebar renders correctlysidebar-visible↔sidebar-hiddenon<html>(verified via Playwright)window.innerWidth < 1080), visible (or restored fromlocalStorage) on wide viewports❱) correctly expand/collapse their ownli.chapter-itemAlso

So I hope it is appreciated.
Resolves #57