Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions changelog.d/metamodel-docs-mustache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- **metamodel-docs: the vocabulary reference pages are shared Mustache templates, and every
port writes them.** `INDEX.md`, `providers.md` and the `types/<family>.md` pages are now the
`templates/metamodel/` template set rendered over page data each port builds from its own
registry vocabulary manifest and its embedded provider definitions. C#, Java, Kotlin, Python
and Rust gain a `metamodel-docs` generator; every port is held to `fixtures/metamodel-docs/`
(the page data under `data/` and the bytes under `expected/`). A project can override a
page by placing a `templates/metamodel/<page>.mustache` of its own. The TypeScript pages are
unchanged except one fix: `index.lookup` was missing its owning provider
(`metaobjects-core-types`) and the provider of its `@fields`, because the index definition
was left out of the provenance list.

Upgrading: `@metaobjectsdev/metadata` no longer exports `renderMetamodelDocs`,
`renderCoreMetamodelDocs`, `buildMetamodelProvenance` or the `MetamodelProvenance` type; it
exports `coreMetamodelDocsPages()` and `buildMetamodelDocsPages()` (each page's path,
template ref and data) instead, and codegen-ts renders them. An ejected
`codegen/generators/metamodel-docs.ts` that calls `renderCoreMetamodelDocs` stops compiling:
eject it again (`meta eject metamodel-docs`).
2 changes: 1 addition & 1 deletion docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ regenerate with `ls -d fixtures/<corpus>/*/ | wc -l` for directory-shaped corpor
| [`fixtures/agent-context-conformance/`](../fixtures/agent-context-conformance/) | 6 | ✓ (the emitter is TS-owned) | — | — | — | — | — |
| [`fixtures/list-query-conformance/`](../fixtures/list-query-conformance/) (how a list route reads its query string: filter tree, search, sort, page, or the named 400) | 95 cases | ✓ (reference; the source of the expected answers) | planned (R-JV) | planned (R-KT) | ✓ (`ListQueryConformanceTests`) | planned (R-PY) | ✓ (`list_query_conformance.rs`, the parser `meta_http` ships) |
| [`fixtures/docs-page-conformance/`](../fixtures/docs-page-conformance/) (the requirements pages and the model-only schema page: each page's data and bytes) | 4 cases | ✓ (reference; the source of the expected bytes) | planned | planned (through Java) | ✓ | planned | planned (G-RS-1) |
| [`fixtures/metamodel-docs/`](../fixtures/metamodel-docs/) | 1 | ✓ (docs emit is TS-owned) | — | — | — | — | — |
| [`fixtures/metamodel-docs/`](../fixtures/metamodel-docs/) (the vocabulary reference pages: each page's data and bytes, shared `templates/metamodel/`) | 1 (23 pages) | ✓ (reference; the source of the expected bytes) | ✓ (`MetamodelDocsCorpusTest`) | ✓ (through Java's builder and emitter) | ✓ (`MetamodelDocsTests`) | ✓ (`test_metamodel_docs_conformance.py`) | ✓ (`tests/metamodel_docs.rs`) |
| [`fixtures/fmt-conformance/`](../fixtures/fmt-conformance/) (#304 — `meta fmt`) | 13 | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ | — (no `fmt`) |
| [`fixtures/field-lint-conformance/`](../fixtures/field-lint-conformance/) (the `verify` field authoring lint) | 15 | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ | — |
| [`fixtures/model-lint-conformance/`](../fixtures/model-lint-conformance/) (the `verify` overlay, node-name and deprecated-reference authoring lints) | 17 | ✓ (reference) | planned | planned (through Java) | ✓ | planned | — |
Expand Down
2 changes: 1 addition & 1 deletion docs/features/own-your-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ it yourself.
| `api-docs` | which units get a page, where a page lands, whether the index and the agent form (`AGENT-API.md`) are written | the model of the generated API (`buildApiModelForRun`, which also reads the run: layout, `apiPrefix`, whether Hono routes are wired) and its renderers (`renderEntityApiPage`, `renderApiIndex`, `renderAgentApi`) |
| `requirements` | which files the ledger becomes and where they land (`requirements.md`, `requirements.toon`); a project with no `requirement.*` node gets none | the two page builders (`requirements-markdown`, `requirements-toon`) and the projection they read (`requirements-view`) |
| `agent-docs` | which of the three pages are written and where | the three page builders (`agent-schema-page`, which also walks the model for the column-to-field map, lineage, relationships and enums; `agent-ui-page`; `agent-requirements-page`) |
| `metamodel-docs` | where the pages land | nothing: the pages are rendered by `@metaobjectsdev/metadata`, which is core |
| `metamodel-docs` | which pages are written and where they land | the page render call (`renderDocPage`); each page's data comes from `coreMetamodelDocsPages` in `@metaobjectsdev/metadata`, which is core, and its layout from the shared `metamodel/*.mustache` templates |

The page templates themselves (the Mustache files the docs generators render) stay in the
package. To change the wording of a model page you need no eject: put a file of the same
Expand Down
5 changes: 5 additions & 0 deletions docs/ports/csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ a project whose `codegen/Codegen.csproj` pins an older `MetaObjects.Codegen` tha
prints a warning naming the line to change. See
[Own your codegen → C#](../features/own-your-codegen.md#c-dotnet-meta-eject).

**The metamodel reference.** The `metamodel-docs` generator writes the metamodel vocabulary
reference (`metamodel/INDEX.md`, `providers.md`, `types/<family>.md`) from the shared
`templates/metamodel/` Mustache set; a `metamodel/<page>.mustache` under its `TemplateRoot`
overrides a shipped page.

**Generators write through a code writer.** `MetaObjects.Codegen.Writer.CsWriter` is where a
generator's layout lives (ADR-0063): it owns the indent, the braces, the `using` lines and the
blank lines, so a generator states what the file says and not how many spaces it takes. Every
Expand Down
1 change: 1 addition & 0 deletions docs/ports/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ name in every port.
| `template` | `TemplateScopeGenerator` | `metaobjects-codegen-base` | The generic Mustache primitive: walk the model by a named `scope`, render one shared template per walk result, write each file. The declarative alternative to writing a generator class — see [Declarative template-codegen](#declarative-template-codegen-templatescopegenerator) below. It renders through `render.templategen.TemplateGenerator`, the byte-pinned cross-port factory; that factory takes a walk callback and is not itself a `Generator`, so `TemplateScopeGenerator` is the class a pom names. |
| `api-docs` | `JavaApiDocsGenerator` | `metaobjects-codegen-spring` | The Java SDK api reference: one page per entity, value object, projection, served report and template, an index and `AGENT-API.md`, under `<outputDir>/<apiSubDir>`. A `<generator>` entry like any other, run by `metaobjects:generate` and checked by `metaobjects:verify`. Args: `outputDir` (required; give it generated files only, since `verify` compares the whole tree), `apiSubDir` (default `api/java`), `layout` (`flat`, the default, or `package`), `projectName` (the agent page's header label, default `project`) and `modelBaseUrl` (absolute base for the links to the model pages; with none set the pages carry no `Model / metadata` link, since nothing writes a page for it to point at). The `metaobjects:docs` goal was removed in 8.1.0 ([migration](../features/migrations/docs-are-generators.md#java-and-kotlin)). Ejectable: the copy takes the page IR, the builder, the renderer, the page paths and the page templates with it. |
| `plantuml` | `PlantUMLGenerator` | `metaobjects-codegen-plantuml` | One PlantUML class diagram of the object model (`outputDir`, `outputFilename`; `showAttrs`, `showFields`, `showAbstracts`, `drawKeys`, `drawRefs` choose what is drawn). Ejectable: the copy takes `PlantUMLWriter` with it. |
| `metamodel-docs` | `MetamodelDocsGenerator` | `metaobjects-codegen-base` | The reference of the built-in metamodel as Markdown: `INDEX.md`, `providers.md` and one `types/<family>.md` per type family, rendered from the shared `templates/metamodel/` Mustache set over the build's own registry, so every port writes the same pages. Args: `outputDir` (required, generated files only), `subDir` (default `metamodel`; empty writes at the root) and `metamodelTemplateDir` (a directory holding `metamodel/<page>.mustache` that win over the packaged ones; a same-path resource earlier on the classpath does too). Reads no model objects. Ejectable: the page data and templates stay in the package. |
| `html-docs` | `MetaDataHtmlDocumentationGenerator` | `metaobjects-codegen-base` | One HTML page describing the registered metamodel types (`outputDir`, `outputFilename`). It reads the type registry, not your model, so it documents the vocabulary your build loads, providers included. Ejectable: the copy takes `MetaDataHtmlDocumentationWriter` with it. |
| `ai-docs` | `MetaDataAIDocumentationGenerator` | `metaobjects-codegen-base` | The same type reference as JSON, laid out for an AI reader (`outputDir`, `outputFilename`). Ejectable: the copy takes `MetaDataAIDocumentationWriter` with it. |
| `json-schema` | `MetaDataFileJsonSchemaGenerator` | `metaobjects-codegen-base` | A JSON Schema that validates metadata files, built from the type registry (`outputDir`, `outputFilename`). Ejectable: the copy takes `MetaDataFileSchemaWriter` with it. |
Expand Down
1 change: 1 addition & 0 deletions docs/ports/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ The 18 generators registered in `codegen-kotlin` (`GeneratorRegistry.kt`):
| `KotlinReportExportGenerator` | Standalone export of a served report (`?format=csv\|json\|xml`, see [Report export](#report-export)): one `<Report>Export.kt` per served report beside its controller and one shared `ReportExportWriter.kt`. Args: `outputDir` (required), `maxRows` (default `100000`), `xmlNulls` (`empty`, the default, or `nil`), `csvBom` (default `false`) and `writerPackage` (default: the package prefix the served reports share, else `export`). Never implied by a library. Ejectable | every served report |
| `KotlinSharedModelGenerator` | `<name>.metaobjects.json` and `metaobjects.pkg.json` — the FR-023 shared-model artifact and manifest a consumer's `meta deps sync` reads. See [Publishing a shared model](#publishing-a-shared-model-shared-model) | once per project (`include` selects the nodes) |
| `KotlinApiDocsGenerator` | The Kotlin SDK api reference, under `<outputDir>/<apiSubDir>`: `<Unit>.md` per entity, value object, projection, served report and template, a `README.md` index and `AGENT-API.md`. A `<generator>` entry like any other, run by `metaobjects:generate` and checked by `metaobjects:verify`. Args: `outputDir` (required, generated files only), `apiSubDir` (default `api/kotlin`), `layout` (`flat` or `package`), `projectName` and `modelBaseUrl`, as for the Java `api-docs` (with no `modelBaseUrl` the pages carry no `Model / metadata` link). The `metaobjects:docs` goal was removed in 8.1.0 ([migration](../features/migrations/docs-are-generators.md#java-and-kotlin)). Ejectable, with the page model, builder, renderer and path math | the whole model, once |
| `KotlinMetamodelDocsGenerator` | The reference of the built-in metamodel, under `<outputDir>/<subDir>`: `INDEX.md`, `providers.md` and one `types/<family>.md` per type family, rendered from the shared `templates/metamodel/` Mustache set over the build's own registry, so every port writes the same pages. Args: `outputDir` (required, generated files only), `subDir` (default `metamodel`; empty writes at the root) and `metamodelTemplateDir` (a directory holding `metamodel/<page>.mustache` that win over the packaged ones). Reads no model objects. Ejectable | once per project |

Maven wiring. The plugin bundles `metaobjects-codegen-kotlin`, so it is not a dependency of your
project. Keep `<configuration>` at plugin level and bind the goal in `<executions>`: without the
Expand Down
1 change: 1 addition & 0 deletions docs/ports/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ definitions, and import lines are stable.
| Drift verify | Yes — template / payload drift (`metaobjects verify`); `verify --codegen` regenerates the config's list and diffs each target's `outDir` |
| API reference docs | Yes — `api-docs` in a target's `generators`, options in the top-level `apiDocs` block (`apiSubDir`, `projectName`, `modelBaseUrl`); `metaobjects docs` was removed in 1.1.0 ([migration](../features/migrations/docs-are-generators.md#python)) |
| Requirements and agent pages | Yes — `requirements` (`requirements.md`, `requirements.toon`) and `agent-docs` (`agent/requirements.md` and the model-only `agent/schema.md`: no SQL types, defaults, indexes or checks; `agent/ui.md` is TypeScript-only) in a target's `generators`, rendered from the shared templates bundled in the package; a same-named file under the project's templates directory overrides a page; both ejectable |
| Metamodel reference | Yes — `metamodel-docs` in a target's `generators` (`INDEX.md`, `providers.md` and `types/<family>.md` under `metamodel/`; option `subDir`), rendered from the shared templates bundled in the package over the port's own registry manifest and embedded provider definitions; reads no model objects; a same-named file under the project's templates directory overrides a page; ejectable |
| Requirement gate + requirement tests | Yes (`metaobjects verify`, on every run; `requirement-tests` emits pytest and is ejectable) |
| Business-rules gate (ADR-0066, experimental) | Yes (`metaobjects verify`, on every run; see [business rules](../features/business-rules.md)) |
| Runtime metadata | Yes (`metaobjects.runtime.ObjectManagerDb` — DB-API 2 drivers: Postgres via pg8000/psycopg, `SqliteDriver` over the standard library's `sqlite3`, `MySqlDriver` over PyMySQL with the `mysql` extra) + loader API + render engine |
Expand Down
11 changes: 6 additions & 5 deletions docs/ports/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The loader is the `metaobjects` crate, and the workspace at `server/rust/` adds
| Frozen tree | The loader freezes the tree when it finishes. A frozen tree memoizes its resolved reads (effective children, attributes and array-ness), so many readers can share one. |
| Timings | Every load records how long each phase and each validation pass took (`LoadResult::timings`). |
| Report shapes | `metaobjects::report_shape::report_shape` derives an `object.report`'s fields (FR-044 Table B, with Table C's `required`): each dimension and measure, its subtype, and the `@of` field it takes its type from. It byte-matches `fixtures/persistence-conformance/report-shapes.json`, as every port does. |
| Code generation (`cargo meta`) | The run engine, eleven generators (`entity`, `rules-names`, `contract-types`, `repository`, `service`, `service-routes`, `client`, `commands`, `render-helper`, `output-parser`, `output-prompt`), the codegen and template drift gates and `eject`. See [The command](#the-command-cargo-meta) and [What `gen` writes](#what-gen-writes) below. |
| Code generation (`cargo meta`) | The run engine, twelve generators (`entity`, `rules-names`, `contract-types`, `repository`, `service`, `service-routes`, `client`, `commands`, `render-helper`, `output-parser`, `output-prompt`, and the opt-in `metamodel-docs`, the metamodel reference pages rendered from the shared Mustache set), the codegen and template drift gates and `eject`. See [The command](#the-command-cargo-meta) and [What `gen` writes](#what-gen-writes) below. |

## The command: `cargo meta`

Expand Down Expand Up @@ -78,10 +78,11 @@ one, and no eject is needed:
The file takes that one key: a layer is only a generator, so there are no layer settings. An entry is a
name, or `{"name": "<generator>", "options": {...}}` for a generator that takes options; the
generator's `configure` reads them and refuses a key it does not know (`ERR_UNKNOWN_GENERATOR_OPTION`,
naming the options it takes). The shipped generators take none, so any option given to one fails the
run, also a run `--generators` narrows to other generators. A project with no such file runs every
generator but `service-routes`, which runs only when it is listed: an HTTP server is a choice the
project makes, not a default. A generator that leaves the list has its files removed
naming the options it takes). Of the shipped generators only `metamodel-docs` takes one (`subDir`), so
any other option fails the run, also a run `--generators` narrows to other generators. A project with
no such file runs every generator but `service-routes` and `metamodel-docs`, which run only when they
are listed: an HTTP server is a choice the project makes, not a default, and so are the metamodel
reference pages. A generator that leaves the list has its files removed
on the next `gen` (a file somebody edited is refused by name instead), and the run fails, naming the
file, for a name nothing offers, a duplicate, an unknown key, or a generator listed without one it
builds on (`client`, `render-helper` and `output-parser` need `entity`; `commands` needs `entity` and `client`; each layer needs the one beneath it, up to `service-routes`, which needs `service`). `cargo meta gen --list` shows each generator
Expand Down
4 changes: 2 additions & 2 deletions fixtures/generator-registry-conformance/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@
"concept": "The reference of the built-in metamodel: every type, subtype and attribute the build registers, by provider.",
"tier": "neutral",
"layer": "docs",
"note": "TYPESCRIPT ONLY: it was `meta docs --metamodel` until 1.1.0 (ADR-0034 Amendment 9).",
"note": "Every port renders the shared templates/metamodel/ Mustache set over its own registry manifest and provider definitions, gated by fixtures/metamodel-docs/. In TypeScript it was `meta docs --metamodel` until 1.1.0 (ADR-0034 Amendment 9).",
"eject": "full",
"ports": ["typescript"]
"ports": ["typescript", "csharp", "java", "kotlin", "python", "rust"]
},
"docs-site": {
"concept": "The browsable HTML site of the model: navigation, search, a page per package and per object, ER diagrams.",
Expand Down
Loading
Loading