Generate RegisteredNodes category unions; remove HAND_WRITTEN_UNIONS#98
Merged
Merged
Conversation
This was referenced Jun 10, 2026
Member
Author
This was referenced Jun 10, 2026
Member
Author
Merge activity
|
Teaches the generator a new union-emission mode for category unions whose `registered<X>` twin contains members the standalone `<X>` doesn't \u2014 i.e. the categories that use Rust's `#[derive(RegisteredNodes)]` registered/standalone split. New helpers in `unions.ts`: `isRegisteredCategoryUnion` decides when this mode applies (true for `value`/`type`/`contextualValue`, false for `link`/`count`/`discriminator`/`pdaSeed`); `getRegisteredOnlyLeafKinds` returns the `#[registered]`-only variants in spec order. A new `registeredUnionPage.ts` fragment renderer emits `#[derive(RegisteredNodes)] #[node_union] pub enum Registered<X> { \u2026 #[registered] \u2026 }`, with standalone variants alphabetical and `#[registered]` variants in spec order (functionally equivalent to the hand-written file). The orchestrator in `index.ts` dispatches to the registered renderer when applicable. With the generator now able to emit `RegisteredValueNode` (and, in future PRs, `RegisteredTypeNode` / `RegisteredContextualValueNode`), `HAND_WRITTEN_UNIONS` becomes empty and is deleted. The hand-written `value_nodes/value_node.rs` shrinks to a `#[cfg(test)] mod tests` block (the two `kind_from_*` smoke tests), and `value_nodes/mod.rs` drops the now-redundant `pub use value_node::*;`. As a small companion change, `page.ts`'s import-grouping rule is generalised from "only `crate::*`" to "any shared module prefix" so the new `use codama_nodes_derive::{node_union, RegisteredNodes};` is grouped automatically (no more special case for `crate::*`). The override surface is now down to three maps: `CATEGORY_ROUTING`, `CATEGORY_DIRECTORIES`, and `FIELD_TYPE_OVERRIDES`.
6138545 to
ec13b24
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.

Teaches the generator a new union-emission mode for category unions whose
registered<X>twin contains members the standalone<X>doesn't \u2014 i.e. the categories that use Rust's#[derive(RegisteredNodes)]registered/standalone split. New helpers inunions.ts:isRegisteredCategoryUniondecides when this mode applies (true forvalue/type/contextualValue, false forlink/count/discriminator/pdaSeed);getRegisteredOnlyLeafKindsreturns the#[registered]-only variants in spec order. A newregisteredUnionPage.tsfragment renderer emits#[derive(RegisteredNodes)] #[node_union] pub enum Registered<X> { \u2026 #[registered] \u2026 }, with standalone variants alphabetical and#[registered]variants in spec order (functionally equivalent to the hand-written file). The orchestrator inindex.tsdispatches to the registered renderer when applicable. With the generator now able to emitRegisteredValueNode(and, in future PRs,RegisteredTypeNode/RegisteredContextualValueNode),HAND_WRITTEN_UNIONSbecomes empty and is deleted. The hand-writtenvalue_nodes/value_node.rsshrinks to a#[cfg(test)] mod testsblock (the twokind_from_*smoke tests), andvalue_nodes/mod.rsdrops the now-redundantpub use value_node::*;. As a small companion change,page.ts's import-grouping rule is generalised from "onlycrate::*" to "any shared module prefix" so the newuse codama_nodes_derive::{node_union, RegisteredNodes};is grouped automatically (no more special case forcrate::*). The override surface is now down to three maps:CATEGORY_ROUTING,CATEGORY_DIRECTORIES, andFIELD_TYPE_OVERRIDES.