Repository navigation
feat(docs): auto-generate the stdlib reference - #93
Merged
Merged
Conversation
The stdlib reference page was maintained by hand, so its signatures and
descriptions could silently drift from the actual builtins. Generate it
instead by importing pkg/dang and iterating the builtin registry
(ForEachFunction, MethodReceivers/ForEachMethod, StaticModules), modeled
on how vito/bass builds its stdlib page.
A new Booklit plugin (docs/go/stdlib.go) exposes \stdlib-functions,
\stdlib-methods{Type}, and \stdlib-statics{Module}, which render each
entry's signature from its registered parameter, block, and return types
and its one-line description from .Doc(...). The page now carries only
the prose intros, cross-links, and the prelude-installed Error types,
which aren't in the registry.
The docs module gains a replace-directive dependency on the root module,
and build.sh runs Booklit with CGO_ENABLED=0 so pkg/dang compiles
pure-Go without pulling in tree-sitter.
Signed-off-by: Alex Suraci <[email protected]>
Deploying dang with
|
| Latest commit: |
e72805c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8c08d36b.dang-3kk.pages.dev |
| Branch Preview URL: | https://auto-generate-stdlib-docs.dang-3kk.pages.dev |
The generated stdlib reference was a flat bulleted list, which is hard to scan and impossible to link to a single entry. Render it like vito/bass's stdlib page instead: each definition is now a card titled by its signature and carrying an id anchor, so any entry is directly linkable, and long groups (String, List) are preceded by a quick-scan name to one-liner index. The Booklit plugin emits stdlib-module/stdlib-entry/stdlib-index styled content backed by new templates in docs/html, with matching CSS in page.tmpl that reuses the site's existing color variables. Bass-isms that don't apply to Dang — per-line source links and type predicates — are intentionally left out. Signed-off-by: Alex Suraci <[email protected]>
Two refinements to the generated stdlib reference. First, the signature cards are now tree-sitter highlighted client-side, reusing the same grammar and highlight query that power the playground and REPL editors, so signatures are colored consistently with the rest of the site rather than via a separate chroma path. To parse cleanly under the real grammar the signatures now use Dang's actual return-type syntax (`name(args): Ret`) instead of the invented `->` arrow. Second, each entry is emitted as a booklit.Target carrying its signature as the title and its description as the content, so the bindings land in the search index as linkable anchors; the per-group index and each card's self-link now resolve through booklit.Reference instead of hand-written hrefs. Signed-off-by: Alex Suraci <[email protected]>
Switch the stdlib signature highlighting from the client-side tree-sitter pass back to build-time chroma, using the same "dang" lexer and style as the rest of the site's code. The signatures are declaration-shaped and not always complete Dang programs, which the tree-sitter parser choked on; chroma's regex lexer tokenizes them gracefully and inlines both the colors and the dark code background onto the <code>, so the result is self-contained and needs no extra CSS or JS. Also fully qualify each entry's search-index title with its receiver or module, so a result reads "List.uniq: [a]!" instead of the bare ".uniq: [a]!" while the card and index still show the dotted call form. Signed-off-by: Alex Suraci <[email protected]>
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.
What
Auto-generates the
/stdlibreference page from Dang's builtin registry instead of maintaining it by hand.Why
Reader feedback on
/stdlib: rather than hand-maintaining the reference (where signatures and one-line descriptions can silently drift from the real builtins), generate it by importing Dang's builtins and iterating over all of them with a Booklit helper — modeled on how vito/bass does it.How
docs/go/stdlib.go— a new Booklit plugin exposing\stdlib-functions,\stdlib-methods{Type}, and\stdlib-statics{Module}. It introspects the registry (ForEachFunction,MethodReceivers/ForEachMethod,StaticModules/ForEachStaticMethod), rendering each entry's signature from its registered parameter/block/return types and its description from.Doc(...). Entries are alphabetized per group.docs/lit/reference/stdlib.md— replaces the hand-written entry lists with helper calls, keeping the prose intros, conceptual cross-links, and the prelude-installed Error types (which aren't in the registry).docs/go.mod— depends on the root module via areplacedirective.docs/build.sh— runs Booklit withCGO_ENABLED=0, sopkg/dangcompiles pure-Go (its tree-sitter usage is gated behind//go:build cgo).Editing a builtin's
.Doc(...)now updates the page; there's nothing left to hand-maintain.