Skip to content

feat(metadata): stabilize declaration ordering and compact formatting - #276

Closed
Hamilton Chapman (hamchapman) wants to merge 1 commit into
getditto:masterfrom
hamchapman:hc/ffi-stable-metadata
Closed

Hamilton Chapman (hamchapman) wants to merge 1 commit into
getditto:masterfrom
hamchapman:hc/ffi-stable-metadata

Conversation

@hamchapman

@hamchapman Hamilton Chapman (hamchapman) commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Summary

stable_header sorts 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_definer keeps its direct output behaviour. Custom callers can use Language::with_output to construct their definer with the backend-selected writer. Caller-owned writers are not flushed by generation.

serde_json becomes an optional headers dependency because it now handles the complete metadata document; it remains absent from no-default-features runtime builds. The metadata backend also uses it for constant and documentation string escaping.

@hamchapman Hamilton Chapman (hamchapman) added the K-feature Kind: proposed new code to implement new behaviour label Nov 3, 2026
@datadog-official

datadog-official Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2b50507 | Docs | View more details | Give us feedback!

@hamchapman
Hamilton Chapman (hamchapman) force-pushed the hc/ffi-stable-metadata branch 5 times, most recently from ca9fde3 to bd60bb2 Compare November 3, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

K-feature Kind: proposed new code to implement new behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant