Conversation
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
Adds
ApiDocsRenderer, behind a newrenderer_api_docsfeature, which renders a markdown API documentation page per type from aSchemaGenerator. It works like the JSON schema renderer: the last type added is the page rendered, and every other type in the generator is a link target.A page has frontmatter, the type's description, an
## Indextable, then a section per property or variant with tags, its comment, and a table of type information (type, default, values, constraints, aliases, env var). Types referenced from the page are linked inline and listed under## References. Structs render properties, unit enums and unions render variants, headed by the variant name.Options
render_tags,render_description,render_link,render_anchor: functions that own how tags, descriptions, type links, and index fragments are rendered, for sites with their own components or heading ids.frontmatter: a map of extrakey: valueentries.enum_format: render a unit enum's variants as one table instead of sections.include_index,index_page,exclude_aliases,mark_struct_fields_required.ApiDocsRenderer::generate_allwrites a page for every type into a directory plus an index page listing them.Changes outside the renderer
UnionType.variants_names(new, optional). A union derived from an enum records each variant's name by position, so a variant can be labeled. A variant'sSchema.namecould not carry this: the generator treats any named schema as a standalone reference, soList(Vec<String>)would have become a top-levelListdefinition in JSON schema and TypeScript output. Mirrors howEnumType::from_schemasmoves names out of variant schemas. Hand-built unions carryNone, and serialization skips it.SchemaGenerator::addmoves a re-added type to the end. Without this, adding a type that an earlier type had nested left the old root in place, so a per-type loop silently rendered the wrong page. This reorders two TypeScript snapshots where a fixture re-adds a nested type; content is unchanged.Reviewer notes
Referencesrow, because a markdown link cannot sit inside a code span. Bare references link directly.Required, unlike the JSON schema renderer'srequiredlist, since serde accepts a missingOptionand a flattened field has no key.render_tags, as its block output cannot sit in a table cell.Book page at
book/src/schema/generator/api-docs.mdfills the existing "API documentation" placeholder in the summary. Changelog has anUnreleasedentry.Test plan
cargo test --workspacecargo clippy --workspace --all-targetscleancargo build -p schematic --no-default-features --features renderer_api_docscargo test -p schematic_typeson its own[patch.crates-io]🤖 Generated with Claude Code