Repository navigation
feat(metadata): stabilize declaration ordering and compact formatting - #276
Closed
Hamilton Chapman (hamchapman) wants to merge 1 commit into
Closed
Hamilton Chapman (hamchapman) wants to merge 1 commit into
Hamilton Chapman (hamchapman) wants to merge 1 commit into
Conversation
|
This comment will be updated automatically if new data arrives. 🔗 Commit SHA: 2b50507 | Docs | View more details | Give us feedback! |
Hamilton Chapman (hamchapman)
force-pushed
the
hc/ffi-stable-metadata
branch
5 times, most recently
from
November 3, 2026 17:45
ca9fde3 to
bd60bb2
Compare
Hamilton Chapman (hamchapman)
force-pushed
the
hc/ffi-stable-metadata
branch
from
November 3, 2026 21:35
bd60bb2 to
2b50507
Compare
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
stable_headersorts exports, but metadata declarations still follow dependency discovery: adding an earlier export can move an existing type. Sort complete metadata declarations by kind and name, keeping the banner comment first, so their positions are independent of first use.Generate readable compact JSON: two-space indentation, inline short type objects, and recursive wrapping at a soft 120-character limit. Comments and string contents remain intact.
with_stable_header(false)retains dependency-discovery order while using the same formatting. C/C#/Lua output is unchanged.Each backend selects its output strategy before the definer is constructed. C/C#/Lua stream directly; metadata collects declarations for sorting, releases the raw JSON buffer after parsing, and renders one declaration at a time.
generate_with_definerkeeps its direct output behaviour. Custom callers can useLanguage::with_outputto construct their definer with the backend-selected writer. Caller-owned writers are not flushed by generation.serde_jsonbecomes an optionalheadersdependency because it now handles the complete metadata document; it remains absent fromno-default-featuresruntime builds. The metadata backend also uses it for constant and documentation string escaping.