Skip to content

feat: markdown spec parser for generate-spec#3528

Open
Apollon77 wants to merge 8 commits intospec15gen-v2from
spec15gen-v2-markdown-parser
Open

feat: markdown spec parser for generate-spec#3528
Apollon77 wants to merge 8 commits intospec15gen-v2from
spec15gen-v2-markdown-parser

Conversation

@Apollon77
Copy link
Copy Markdown
Collaborator

Summary

  • Adds markdown spec parsing to generate-spec, auto-detecting format from the --path directory structure
  • Both HTML and markdown inputs are supported; existing HTML pipeline is unchanged
  • Regenerates spec.ts from the Matter 1.5.1 markdown spec with identical validation results (7 errors, 7980 elements)
  • All downstream generated files (model, clusters, endpoints) updated — changes are purely in JSDoc/description text

Details

New modules (support/codegen/src/mom/spec/md/):

  • md-utils.ts — frontmatter parsing, text/prose helpers, heading parser
  • parse-tables.ts — pipe table + HTML table parsing, overflow cell merging for | in conformance
  • scan-markdown.ts — document scanner yielding HtmlReference objects
  • load-markdown-files.ts — directory discovery, chapter concatenation

Key fixes for markdown compatibility:

  • Command direction detection: client <= server pattern
  • Pipe table | overflow: column-aware merging for conformance/constraint expressions
  • <sup>, <a id>, italic/bold markdown stripping in table cells
  • Status code obsolete name cleanup for <strong> wrapped names

Test plan

  • npm run generate-spec -- --path .../markdown produces 7980 elements, 7 validation errors (matches HTML)
  • npm run generate-spec -- --path .../html still produces identical baseline output (0 diff)
  • npm run generate-model succeeds with 6 validation errors
  • npm run generate-clusters succeeds
  • npm run generate-endpoints succeeds
  • npm run format-verify clean
  • npm run test all passing
  • Generated file changes are comment/text only, no structural or API changes

🤖 Generated with Claude Code

Apollon77 and others added 3 commits April 2, 2026 18:17
The generate-spec tool now auto-detects markdown spec directories
(containing _index.md files) and parses them using a new markdown
pipeline, while preserving the existing HTML pipeline as fallback.

New modules in support/codegen/src/mom/spec/md/:
- md-utils.ts: frontmatter parsing, text/prose element helpers
- parse-tables.ts: pipe table + HTML table parsing with overflow
  cell merging for unescaped | in conformance expressions
- scan-markdown.ts: document scanner yielding HtmlReference objects
- load-markdown-files.ts: directory discovery and file concatenation

Also adds scan-spec.ts routing function and extends translate-cluster.ts
and translate-global.ts for markdown-specific patterns (command direction
<= syntax, status code obsolete name cleanup).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generated from the markdown version of the Matter 1.5.1 specification.
Produces identical validation results (7 errors, 7980 elements) as the
HTML source. Text differences are limited to prose formatting: different
word wrapping, admonition markers, list formatting, and minor punctuation.
No structural or semantic changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All changes are in generated JSDoc comments and description strings
reflecting the markdown-sourced spec.ts text formatting. No structural
or API changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Apollon77 Apollon77 requested a review from lauckhart as a code owner April 2, 2026 16:19
More generated JSDoc/description text updates from the markdown-sourced
spec.ts. No structural or API changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Apollon77 Apollon77 force-pushed the spec15gen-v2-markdown-parser branch from f058ad7 to 7dba748 Compare April 2, 2026 17:56
Copy link
Copy Markdown
Collaborator

@lauckhart lauckhart left a comment

Choose a reason for hiding this comment

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

What's the goal here? In theory .md parsing could be more lightweight and simplify the pipeline. This seems more like a custom markdown-to-html pass to feed the existing pipeline

Apollon77 and others added 4 commits April 4, 2026 18:50
Replace MD → HTMLElement → text pipeline with direct MD → text.
Drop HTML spec input support entirely. Translators now operate on
strings, tables produce string cells at parse time, prose is string[].

Delete scan-document.ts, scan-tables.ts, doc-utils.ts (HTML-only).
Rename html-translators.ts → translators.ts with string signatures.
Rename HtmlReference → SpecReference across the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Minor improvements from direct MD → text pipeline: removed spurious
heading markers on legend text, better paragraph merging, picked up
8 missing network conditions (Ethernet, WiFi, Thread, etc.).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove references to HTML spec input from README and generate-spec
usage text. Fix formatting in generated file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants