@@ -13,19 +13,56 @@ group: "A connected docs tree"
1313# File kinds and schemas
1414
1515Not every Markdown file plays the same role. A plan is not a rule
16- README, and a release-channel page is not a guide. mdsmith lets
17- you model that.
18-
19- A ** kind** is a named bundle of rule config. You bind files to it
20- by front matter, a ` kind-assignment ` glob, or a ` path-pattern ` .
21- Each kind can attach a ** schema** that constrains required
22- headings, section order, and front-matter fields.
23-
24- Declare the schema inline on the kind or share it from a
25- ` proto.md ` template, so a whole directory validates against one
26- source of truth. Named field-type shortcuts keep the schema
27- short. ` MDS020 ` reports a precise diagnostic when a file breaks
28- its contract.
29-
30- See the [ file-kinds guide] ( ../guides/file-kinds.md ) and the
31- [ schemas guide] ( ../guides/schemas.md ) for the full vocabulary.
16+ README, and a release-channel page is not a guide. A per-file
17+ style linter treats them all alike: it catches a long line, but
18+ not a missing Decision section or an invented ` status ` value. A
19+ directory of similar files drifts as it grows.
20+
21+ A ** kind** gives each file a role; a ** schema** gives that role a
22+ contract. Bind files to a kind by a front-matter ` kinds: ` field or
23+ a ` kind-assignment ` glob. The kind's schema then constrains
24+ required headings, section order, and front-matter fields. Declare
25+ it inline on the kind, or share it from a ` proto.md ` template so a
26+ whole directory validates against one source of truth.
27+
28+ For example, an ` rfc ` kind can declare its schema inline in
29+ ` .mdsmith.yml ` :
30+
31+ ``` yaml
32+ kinds :
33+ rfc :
34+ schema :
35+ frontmatter :
36+ status : ' "draft" | "ratified" | "deprecated"'
37+ sections :
38+ - heading : " Context"
39+ - heading : " Decision"
40+ ` ` `
41+
42+ Tag a file with that kind:
43+
44+ ` ` ` markdown
45+ ---
46+ kinds : [rfc]
47+ status : approved
48+ ---
49+ # RFC-0007: Adopt structured logging
50+
51+ # # Context
52+
53+ We keep losing requests in unstructured log lines.
54+ ```
55+
56+ This file breaks the contract twice. ` approved ` is not an allowed
57+ ` status ` . The required ` Decision ` section is missing. ` MDS020 `
58+ reports both:
59+
60+ ``` text
61+ RFC-0007.md:3:1 MDS020 status: got "approved", expected one of: "draft", "ratified", "deprecated"
62+ RFC-0007.md:7:1 MDS020 ## Decision: got <missing>, expected section to be present
63+ ```
64+
65+ Schemas go further: they nest sections, repeat them, and inherit
66+ from a parent. See the [ file-kinds guide] ( ../guides/file-kinds.md )
67+ and the [ schemas guide] ( ../guides/schemas.md ) for the full
68+ vocabulary.
0 commit comments