Skip to content

Generate RegisteredNodes category unions; remove HAND_WRITTEN_UNIONS#98

Merged
lorisleiva merged 1 commit into
mainfrom
loris/spec-gen-registered-nodes-union
Jun 10, 2026
Merged

Generate RegisteredNodes category unions; remove HAND_WRITTEN_UNIONS#98
lorisleiva merged 1 commit into
mainfrom
loris/spec-gen-registered-nodes-union

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

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.

lorisleiva commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • Jun 10, 2:13 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 10, 2:25 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 10, 2:25 PM UTC: @lorisleiva merged this pull request with Graphite.

@lorisleiva lorisleiva changed the base branch from loris/spec-gen-derive-inline-unions to graphite-base/98 June 10, 2026 14:22
@lorisleiva lorisleiva changed the base branch from graphite-base/98 to main June 10, 2026 14:23
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`.
@lorisleiva lorisleiva force-pushed the loris/spec-gen-registered-nodes-union branch from 6138545 to ec13b24 Compare June 10, 2026 14:24
@lorisleiva lorisleiva merged commit d2041f2 into main Jun 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant