Add structured generic metadata support - #150
Draft
dacowan wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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 structured generic type metadata to
@minecraft/api-docs-generatorand corresponding rendering support to@minecraft/markup-generators-plugin.Metadata producers can now describe ordered generic declarations and recursive generic applications as data. The generators use that structure consistently across TypeScript declarations, MSDocs, cross-module links, and changelogs.
Why
The metadata model could describe concrete types but could not preserve relationships such as
Container<T>, generic methods, nested applications, or generic inheritance without relying on pre-rendered TypeScript text.Structured metadata is useful when the relationship can be represented directly: it remains machine-readable, participates in recursive type processing, and can be rendered consistently by every output format.
This does not replace the existing
raw_script_textpath. TypeScript-specific constructs such as conditional types, mapped types, indexed-access types, template-literal types, and complex type aliases remain better represented as TypeScript.Metadata contract
The model adds:
generic_class_typeson classes and interfacesgeneric_function_typeson functions and methodsgeneric_baseand orderedgeneric_typeson type recordsGeneric parameter and argument arrays preserve source order. All fields are optional, so existing non-generic metadata remains valid.
Generator behavior
NativeClass<T>helper when a valid reserved application is used, with validation for argument cardinality and public-name collisions.The producer-facing contract and ordering requirements are documented in
tools/api-docs-generator/README.md.Compatibility and scope
The new metadata fields are additive and optional. Existing non-generic fixtures and snapshots remain unchanged, and this PR does not modify production declaration output.
The structured model intentionally does not attempt to represent the complete TypeScript type system. Generic type-alias declarations, constructor type parameters, conditional and mapped types, variance, higher-kinded types, and raw TypeScript fragments remain outside its scope.
raw_script_textcontinues to work as before and does not trigger structuredNativeClass<T>helper synthesis.Validation
@minecraft/api-docs-generator: build, lint, and tests pass.@minecraft/markup-generators-plugin: build, lint, and tests pass.api-docs-generator-test-snapshots: build, lint, snapshots, and strict TypeScript diagnostics pass.NativeClass<T>synthesis.npx beachball checkrecognizes both package change records.