|
| 1 | +--- |
| 2 | +"@objectstack/spec": patch |
| 3 | +--- |
| 4 | + |
| 5 | +fix(spec): reference pages no longer drop the whole section for a non-object root schema (#7658) |
| 6 | + |
| 7 | +`build-docs.ts` decided which node of a published document it was documenting by |
| 8 | +enumerating shapes — `properties`, `enum`, `anyOf`, `oneOf` — and answered "none |
| 9 | +of those" with `return ''`. A JSON Schema root is routinely none of those: |
| 10 | +`z.string().describe(…)` compiles to a bare scalar, `z.record(…)` to an object |
| 11 | +with `additionalProperties` and no `properties`, `z.array(…)` to an array, |
| 12 | +`z.intersection(…)` to an `allOf`. Every one of them lost its ENTIRE `## Name` |
| 13 | +section — heading included, and with it the `.describe()` prose an author wrote |
| 14 | +to be read — while the page's `## TypeScript Usage` block, which is spelled from |
| 15 | +the export surface rather than from this function, went on naming the export. The |
| 16 | +page read as if it had forgotten to finish rendering an entry it had just |
| 17 | +imported. |
| 18 | + |
| 19 | +**Measured on today's tree: 45 published schemas were in that state, 33 of them |
| 20 | +carrying a description.** The filed issue counted 22 (`~23`), having scanned only |
| 21 | +the bare-scalar spelling; record maps, one array root and one `allOf` are the |
| 22 | +same defect through the same line. Regenerating restores all 45 sections — 244 |
| 23 | +added lines, **zero removed**, so none of the 1533 sections that already rendered |
| 24 | +moves. Emitted file count is unchanged at 230: a section rendering as the empty |
| 25 | +string never removed a page, so no category's `pages.length` changes and the |
| 26 | +`meta.json` emit guard added in #7303 is untouched. |
| 27 | + |
| 28 | +Nothing was failing, which is why this stood for months: `check:docs` compares |
| 29 | +generated output to committed output, so a section that never existed stays green |
| 30 | +forever, and there is no grep for what is missing. |
| 31 | + |
| 32 | +The renderer moved to `scripts/lib/schema-section.ts` to be pinned directly — |
| 33 | +the same extraction, for the same reason, that `lib/format-type.ts` got at #4912. |
| 34 | +Its output was the empty string, the one thing grepping emitted `.mdx` cannot |
| 35 | +see. |
| 36 | + |
| 37 | +Sections for these shapes now carry the schema's description plus a single |
| 38 | +`**Type:**` line, rendered by the same `formatType` that every property row on |
| 39 | +the page uses, so a schema's own section and a property typed with it cannot |
| 40 | +disagree. Constraints (`pattern`, `minLength`, `minimum`) are deliberately not |
| 41 | +spelled: this renderer prints none in any position, and `json-schema/` stays the |
| 42 | +authority on them. |
0 commit comments