Skip to content

feat: add paragraphs rule, top-level paragraph collection, and unknown-key warnings - #76

Merged
jackchuka merged 6 commits into
mainfrom
feat/paragraphs-rule-and-unknown-key-warnings
Jul 24, 2026
Merged

feat: add paragraphs rule, top-level paragraph collection, and unknown-key warnings#76
jackchuka merged 6 commits into
mainfrom
feat/paragraphs-rule-and-unknown-key-warnings

Conversation

@jackchuka

Copy link
Copy Markdown
Owner

Summary

Adds three related features to mdschema:

  • Paragraph collection in the parser — top-level paragraphs are now collected per section, excluding paragraphs nested inside lists or blockquotes (gated on Parent().Kind() == ast.KindDocument).
  • paragraphs section rule — a new structural rule validating paragraph count constraints (min/max) per section, modeled on the existing wordcount rule.
  • Unknown schema config-key warnings — the loader now emits non-fatal warnings (to stderr) when .mdschema.yml contains keys not recognized by the schema, without rejecting the config.

schema.json and the generator are updated to reflect the new rule.

Changes

  • internal/parser/ — collect top-level paragraphs per section; new Paragraph type
  • internal/rules/paragraph.go — new paragraphs structural rule + tests
  • internal/schema/warnings.go — unknown-key detection + tests
  • internal/vast/types.goNode.Paragraphs() accessor
  • cmd/mdschema/commands/ — warnings wired to CLI (stderr)
  • schema.json — regenerated
  • testdata/paragraph/ + internal/integration/paragraph_test.go — valid/invalid fixtures

Testing

  • go build ./..., go vet ./..., go test ./... — all pass
  • New unit tests: parser (paragraph collection + list/blockquote exclusion), rules (min/max), schema warnings
  • Integration fixtures cover valid + invalid (min) cases

Notes

Reviewed on-branch; no Critical/Important issues found. Minor follow-up: consider an integration fixture exercising the max constraint (currently only covered by the rules unit test).

🤖 Generated with Claude Code

…phs slice

Use a loose list (blank line between items) in TestParagraphsTopLevelOnly
so item content becomes ast.Paragraph with a ListItem parent, genuinely
exercising the ast.KindDocument exclusion gate in parser.go. A tight list
renders as ast.TextBlock and never hit that gate. Also initialize the
Paragraphs slice in the root/heading Section literals in hierarchy.go for
consistency with sibling fields.
golangci-lint govet flags reflect.Ptr as an alias that should be inlined
to reflect.Pointer.
@jackchuka
jackchuka marked this pull request as ready for review July 24, 2026 22:52
@jackchuka
jackchuka merged commit 45dc3b6 into main Jul 24, 2026
1 check passed
@jackchuka
jackchuka deleted the feat/paragraphs-rule-and-unknown-key-warnings branch July 24, 2026 22:52
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.

1 participant