Skip to content

feat(ladfile): readable generated binding docs in mdbook - #679

Merged
makspll merged 3 commits into
mainfrom
agent/mdbook-docs-polish
Nov 8, 2026
Merged

makspll merged 3 commits into
mainfrom
agent/mdbook-docs-polish

Conversation

@makspll

@makspll makspll commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Reworks how mdbook_lad_preprocessor renders the generated binding docs. Reviewed against the full book (cargo xtask docs, all binding features) with screenshots before/after, and clicked through in headless Chromium.

Bugs fixed

  • Generics vanished as HTML tags: argument/return types and function titles weren't escaped, so Type<A>, Optional<A>, Handle<ScriptAsset>.asset_path rendered as Type, Optional, Handle.asset_path (the 11 mdbook warnings).
  • Previews: summaries were escaped (literal backticks/links) and cut from the whole docstring with newlines flattened (code fences, # Example, Returns: * squashed into one line). Now the first paragraph, cut after a sentence or at a word, with formatting kept (docstrings::summary). The old markdown_substring sliced by byte and is removed.
  • Rustdoc links: [`Transform`], [text](bevy_math::Vec3), [x][ref] + reference definitions resolve to type pages, or become plain text (was literal brackets / dead href="bevy_ecs::…").
  • Doc headings are nested under the page's (# Examples was an <h1> mid-page); rustdoc-hidden # use … example lines are dropped; the /// leading space is removed; rust examples are noplayground (they need crates the playground doesn't have).
  • Unknown types print as Unknown without a link (was Arc<TypeId(0x…)> linking to a missing page), also in titles. () gets a title and a unit page (was an empty title and .html).
  • Multi-line arg docs no longer break table rows (arguments are a list now).
  • JS errors on every page (pre-existing): mermaid-init.js looked up the mdbook 0.4 theme button ids (now mdbook-theme-*), and multi-code-block.js used the highlight.js 10.7 API while mdbook bundles 10.1, so lua/rune example tabs weren't highlighted.

Structure / look and feel

  • One page per type: functions are sections on their type/namespace/builtins page (### name {#anchor}), not pages of their own. Book pages 2165 → 332; the sidebar lists a type's functions under it. Generated chapters are unnumbered (no more 19.1.29.0.37.).
  • Signature at the top of each function, language neutral, types linked: get_component<A>(entity: Entity, registration: Type<A>) -> Optional<A>, plus "Generic over A, the type given as registration".
  • Functions grouped into Functions / Methods / Operators / Variant Functions, sorted; generic types document a function once with the instantiations it's on (was 9× Handle.new).
  • Type pages: badges (Component/Resource/Bundle/Asset/Generic), description first and unquoted, then a Fields table (or Variants table with their fields), opaque types get a one-line note.
  • Primitives spelled as such (f32, bool), HashSet<T> printed (was just T), variadics as ....
  • No "No Documentation 🚧" filler; namespaces with nothing in them are hidden; the namespace index shows contents (17 types, 3 functions).
  • docs/lad.css (scoped to generated pages via a .lad-page marker): full-width left-aligned tables with a light header, signature block, dividers between function sections, badges; content width 750 → 900px.

No LAD format changes.

Checked

  • Links: 22032 links over all 380 pages, 0 broken (pages and #anchors).
  • Headless Chromium over HTTP, all 332 generated pages: no JS errors, no failed requests; no horizontal page overflow at 1400px and 390px (wide tables scroll inside their wrapper on phones).
  • Clicked: summary table → function section, sidebar entry → section, signature type link → type page, namespace → type page, search looking_at → transform.html#looking_at.
  • Light, coal, navy and ayu themes; lua/rune example tabs.
  • Tests: mdbook_lad_preprocessor unit tests (new docstrings tests), book integration snapshot blessed, cargo test -p ladfile_builder -p ladfile -p lua_language_server_lad_backend -p mdbook_lad_preprocessor.

One page per type with its functions as sections (signature, docs, arguments), grouped into functions,
methods, operators and variant functions. Fixes generics rendered as HTML tags, escaped and flattened
previews, unresolved rustdoc links, doc headings outranking the page, unknown type ids leaking into
titles and links, and multi-line docs breaking tables. Adds lad.css for the generated pages.
… book

- `()` had an empty title and a `.html` page no link reached
- mermaid-init.js looked up the mdbook 0.4 theme button ids and threw on every page
- multi-code-block.js used the highlight.js 10.7 API, mdbook bundles 10.1, so lua/rune examples failed to highlight
- rust examples from Rust docs are `noplayground`, they need crates the playground doesn't have
… types like primitives

mdbook nests the sidebar by section numbers, so generated chapters are numbered again and lad.css hides
the numbers. Types standing for primitives are named like them (`f32`, not `F32`), also in titles,
and the types of a namespace are sorted in the sidebar like in its table.
@makspll
makspll enabled auto-merge (squash) November 8, 2026 22:50
@makspll
makspll merged commit 121d45f into main Nov 8, 2026
15 checks passed
@makspll
makspll deleted the agent/mdbook-docs-polish branch November 8, 2026 22:57
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