Skip to content

fix: keep field tables in llms-txt output and type composed schemas - #38

Merged
dotNomad merged 4 commits into
mainfrom
dotnomad/llms-tables-composed-types
Nov 12, 2026
Merged

dotNomad merged 4 commits into
mainfrom
dotnomad/llms-tables-composed-types

Conversation

@dotNomad

@dotNomad dotNomad commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #24
Closes #37

Two fixes to the generated field tables:

  • In .llms.md, field tables come through as a list of fields instead of [TABLE].
  • Properties and parameters defined with allOf, anyOf or oneOf get a real type instead of unknown. Their enums, defaults and nested fields are kept.

The HTML page keeps the same table design. The table contents change: type labels, attributes and nested rows.

Field tables in .llms.md (#24)

Quarto builds each .llms.md from the rendered HTML with pandoc -t gfm-raw_html. A GFM table cell can only hold inline content, so Pandoc writes [TABLE] for any table with a paragraph break, a list or a <br> in a cell. Almost every field table has one, because the "Required. Example: …" line is its own paragraph.

fieldTable() in the new lib/fields.ts now writes each field table twice, using Quarto's conditional content:

  • ::: {.content-hidden when-format="llms-txt"} holds the list table, unchanged.
  • ::: {.content-visible when-format="llms-txt"} holds one bullet per field, - `name` (`type`), with the description and attributes as the item's paragraphs. A list item can hold any Markdown, so nothing is flattened.

Quarto keeps the llms-txt form out of the HTML page and search.json. Both forms are built from the same FieldRows.

Before:

#### Request body

[TABLE]

After:

#### Request body

- `name` (`string`)

  Display name.

  Must be unique within the account.

  Required. Example: `my-widget`.

- `owner` (`object|null`)

  Who owns the widget.

- `owner.guid` (`string`)

Types for composed schemas (#37)

formatTypeString fell back to unknown for any schema without type. Property rows, parameters and bodies now all go through one normalize step and one typeLabel function. normalize resolves $ref and merges allOf members, including non-object ones.

Schema Before After
anyOf: [{$ref: Owner}, {nullable: true}] unknown object|null, plus owner.id, owner.name, … rows
anyOf: [{type: string}, {type: integer}] unknown string|integer
anyOf: [{type: string, nullable: true}, {type: integer}] unknown string|null|integer
anyOf: [{type: array, items: …}, {nullable: true}] unknown [string]|null
allOf: [{$ref: StatusEnum}] object, enum dropped string, Enum: …
allOf: [{$ref: Owner}], nullable: true object object|null
map of anyOf values map[string, object] map[string, string|integer]
{} unknown any
array items that repeat a parent schema [unknown] [Expr]
body that is oneOf: [Cat, Dog] nothing each alternative's table, separated by "Or:"

Parameters now show the same types and attributes as properties, so enum, default and |null appear. Nested object rows now show their attributes ("Required.", "Read-only."), which were dropped before.

Labels describe the structure instead of naming the $ref as #37 suggests. resolve() expands nested $refs before a table is built, so the name is gone by then, and the listed fields say more than the name would. The exception is a circular reference, where expansion stops: expandRefs marks the stub with x-circular-ref, and the label names the schema it would repeat.

Not covered yet: a property with more than one object alternative (oneOf: [Cat, Dog] inside an object) is labelled object, and its alternatives' fields aren't listed. That needs its own row design.

Changes to the HTML page

  • Type labels, enums, defaults and nested rows, as above.
  • In parameter rows, attributes such as "Required." are a separate paragraph instead of being added to the end of the description, matching property rows.
  • The Name column can be wider when dotted nested rows such as owner.guid appear.

Results on a large API reference

Rendering an API reference of about 100 paths and 200 schemas, changing only this extension:

Build Tables [TABLE] in .llms.md unknown types
main 1165 1014 28
This PR 1165 0 0

These counts were measured on an earlier commit of this branch and haven't been re-run. The [TABLE] count of 0 follows from the design, because no field table reaches .llms.md as a table.

Tests

  • tests/fields_test.ts: both forms and their wrappers.
  • tests/quarto_render_test.ts: renders a field table with llms-txt: true and checks that .llms.md has no [TABLE] and keeps paragraphs, lists and line breaks, and that the HTML has none of the list form. It fails without the conditional wrappers.
  • tests/schema_test.ts: each row of the type table above.
  • tests/render_test.ts: parameter types and attributes from composed schemas.
  • tests/markdown_test.ts: an empty cell keeps a list-table row tight.

npm run check passes (161 tests) with Quarto 1.9.36 and 1.11.7, and npm run sync-example -- --check is clean. Quarto handles when-format="llms-txt" this way from 1.9.23, which covers every stable 1.9 release. Not yet checked with Quarto 2.

🤖 Generated with Claude Code

dotNomad and others added 3 commits November 10, 2026 16:33
Quarto builds `.llms.md` with Pandoc's GFM writer, which writes `[TABLE]`
for any table with block content in a cell. Description cells are now one
paragraph: paragraphs and attributes are spans the stylesheet lays out as
lines, and lists or code blocks move to a note under the table.

`anyOf`/`oneOf` properties are typed by their alternatives (`Owner|null`)
instead of `unknown`, and a nullable reference to an object lists the
object's properties, with a guard against recursive schemas.

Closes #24
Closes #37

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ne path

Field tables now come in two forms. The list table is wrapped in
`content-hidden when-format="llms-txt"` and is unchanged in the HTML page,
lists and code blocks included. A bullet list with one item per field is
wrapped in `content-visible when-format="llms-txt"`, so `.llms.md` gets every
description block without Pandoc's GFM writer turning the table into
`[TABLE]`. This replaces the span rewrite of description cells, which needed
the extension's stylesheet (loaded only with the extension's format) and
still produced `[TABLE]` for a description with an inline `<br>`.

Schema typing goes through one normalize step (resolve `$ref`, merge `allOf`
including non-object members) and one type label function, so:

- `allOf` around a primitive keeps its type and enum
- nested object rows show their attributes and `|null`
- arrays, maps and alternative members label consistently (`[string]|null`,
  `map[string, string|integer]`, a member's own `nullable`)
- a circular reference is labelled by the schema it repeats
- parameters use the same labels and attributes as properties
- a request or response body that is `anyOf`/`oneOf` renders each
  alternative

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dotNomad
dotNomad marked this pull request as ready for review November 12, 2026 19:32
Pandoc 3.8 (Quarto 1.9) writes a hard line break as two trailing spaces,
and Pandoc 3.10 (Quarto 1.11) writes it as a trailing backslash. Both are
GFM hard breaks, so the test accepts either.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mconflitti-pbc

Copy link
Copy Markdown

cc: @sarahsdao for visibility in case that has come up for other repos's docs as well

@mconflitti-pbc mconflitti-pbc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

Out of curiosity, why separate lines for the table's cells rather than building a markdown table? your approach is probably more token efficient though

@dotNomad

Copy link
Copy Markdown
Contributor Author

Thanks for fixing this!

Out of curiosity, why separate lines for the table's cells rather than building a markdown table? your approach is probably more token efficient though

GitHub Flavored Markdown table cells only support inline content: no paragraph breaks, lists, or code blocks. Our API descriptions use those, so I wrote each field as a list item instead of a table row.

@dotNomad
dotNomad merged commit d780469 into main Nov 12, 2026
2 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.

Composed schemas (allOf/anyOf/oneOf) render with type unknown Grid tables are dropped from llms-txt output

2 participants