Skip to content

[Website] Simplify protocol docs generation #872

Description

@widal001

Summary

Make each protocol docs page find its content by schema name instead of hand-typed file paths and line numbers, and remove the generator scripts that are no longer needed.

Rationale

The protocol pages work, but keeping them correct takes more manual effort than it should:

  • Each schema section finds its TypeSpec, Python and TypeScript snippets by a file path and a pair of line numbers typed into the page's frontmatter. There are 240 of these across 40 pages
  • Editing a source file shifts its line numbers, and nothing checks them, so a snippet can silently show the wrong lines. The TypeScript tab on the date types page and the AwdIds TypeSpec tab on the award page are wrong on the live site today
  • Adding a schema means writing about 25 lines of frontmatter and looking up line numbers in three source files
  • Two of the four generate-*.ts scripts (generate-schema-metadata.ts, generate-type-formatting.ts) write output that nothing reads

The benefits of the change:

  • A page names the schema, and the site finds the JSON Schema, the TypeSpec source and the SDK code for it at build time
  • Source edits can't break a snippet, and a snippet that can't be found fails the build instead of publishing
  • Adding a schema is one short section in its page, with no line numbers, no file paths and no script run
  • pnpm dev and pnpm build run one docs generator instead of four

Approach

The pages stay as MDX. This issue first proposed porting to a catalog file and a dynamic route, the way CommonBenefits does it. That fits a site whose schema pages are only a table and code tabs. Nearly every schema section here also has hand-written prose, such as what changed in v0.5 and how a field should be read, and a generated page has no place for it.

So the catalog and dynamic route are out of scope. What carries over from CommonBenefits is finding a declaration by name, as its typespec-extractor.ts does.

Implementation notes

  • Find TypeSpec declarations by schema name. 142 of the 144 schema names are declared in exactly one .tsp file under lib/core/lib/
  • Find the Python and TypeScript declarations by name too. About 20 are named differently from the schema (the filter operator enums, for example), so a section needs a way to give the SDK name explicitly
  • Keep the 50 hand-written examples. The rest are already generated from the schema
  • Build the schema-to-page map that powers cross-links while the site builds, replacing generate-schema-docs.ts
  • Remove generate-schema-metadata.ts, generate-type-formatting.ts and the unused SchemaMetadataLoader
  • Keep generate-versioned-schemas.ts. It writes the per-version schema files that every Changelog section links to, and that competition.mdx, form.mdx and a mock conformance test read from disk

Acceptance criteria

  • Every code snippet on the protocol pages shows its complete declaration, including the ones that are cut off or wrong today
  • Everything else on every protocol page (tables, examples, prose, changelogs, links) is unchanged, shown by comparing the built pages before and after
  • Adding a schema is one section in its MDX page that names the schema, with no line numbers, no file paths and no script run
  • The build fails when a page names a schema or a snippet that can't be found
  • generate-schema-docs.ts, generate-schema-metadata.ts and generate-type-formatting.ts are removed and the website still builds clean

Activity

  1. added theissue type on May 29, 2026
  2. added
    featureNew capability. Belongs on a hold branch.
    documentationImprovements or additions to documentation
    on Aug 27, 2026
  3. SnowboardTechie commented on Nov 19, 2026

    @SnowboardTechie
    Collaborator

    I looked into this before starting the v0.6 docs tickets and reworked the description above. What changed from the original:

    • The pages stay as MDX, with no catalog or dynamic route. Nearly every schema section has hand-written prose (about 1,070 lines across 160 sections). The CommonBenefits route renders a table and code tabs, so that writing would have nowhere to live.
    • The real problem turned out to be the line numbers. Each page finds its code snippets by hand-typed line ranges, and 89 of the 240 code tabs were off, from a missing comment line to the wrong code entirely. Finding snippets by schema name fixes those and keeps them from breaking again, and that's the one piece I'm taking from CommonBenefits.
    • Three scripts go instead of four. Two write output nothing reads, and the page map can be built during the site build. generate-versioned-schemas.ts stays because the Changelog sections link to the files it writes.
    • The committed metadata criterion is dropped. website/cache/ is already gitignored.

    This also keeps line numbers out of the v0.6 model and type page updates in the models, types and API docs dropdown ticket, so I'm doing it ahead of that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

documentationImprovements or additions to documentationenhancementNew feature or requestfeatureNew capability. Belongs on a hold branch.websiteIssues related to the website

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions