@markuplint/html-spec 5.0.0-rc.2 → 5.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/CLAUDE.md +41 -0
- package/README.md +0 -7
- package/index.json +410 -180
- package/package.json +6 -6
- package/ARCHITECTURE.ja.md +0 -276
- package/ARCHITECTURE.md +0 -206
- package/SKILL.md +0 -358
- package/docs/build-pipeline.ja.md +0 -154
- package/docs/build-pipeline.md +0 -155
- package/docs/element-spec-format.ja.md +0 -1034
- package/docs/element-spec-format.md +0 -570
- package/docs/maintenance.ja.md +0 -424
- package/docs/maintenance.md +0 -478
package/SKILL.md
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Perform maintenance tasks for @markuplint/html-spec
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# html-spec-maintenance
|
|
6
|
-
|
|
7
|
-
Perform maintenance tasks for `@markuplint/html-spec`: regenerate specification data,
|
|
8
|
-
review upstream changes, update manual spec files, and ensure cross-package consistency.
|
|
9
|
-
|
|
10
|
-
## Input
|
|
11
|
-
|
|
12
|
-
`$ARGUMENTS` specifies the task. Supported tasks:
|
|
13
|
-
|
|
14
|
-
| Task | Description |
|
|
15
|
-
| ------------------------------------- | ------------------------------------------------------ |
|
|
16
|
-
| `update` | Regenerate `index.json` and review upstream changes |
|
|
17
|
-
| `add-element <name>` | Add a new HTML element specification |
|
|
18
|
-
| `add-svg-element <name>` | Add a new SVG element specification |
|
|
19
|
-
| `add-attribute <element> <attr>` | Add an attribute to an element |
|
|
20
|
-
| `remove-attribute <element> <attr>` | Remove an attribute from an element |
|
|
21
|
-
| `obsolete-element <name>` | Mark an element as obsolete |
|
|
22
|
-
| `obsolete-attribute <element> <attr>` | Mark an attribute as deprecated |
|
|
23
|
-
| `change-flag <element> <attr> <flag>` | Change `experimental`/`deprecated`/`nonStandard` flags |
|
|
24
|
-
| `check` | Verify cross-package consistency |
|
|
25
|
-
|
|
26
|
-
If omitted, defaults to `update`.
|
|
27
|
-
|
|
28
|
-
## Reference
|
|
29
|
-
|
|
30
|
-
Before executing any task, read `docs/maintenance.md` (or `docs/maintenance.ja.md`)
|
|
31
|
-
for the full guide. The recipes there are the source of truth for procedures.
|
|
32
|
-
|
|
33
|
-
Also read:
|
|
34
|
-
|
|
35
|
-
- `docs/element-spec-format.md` -- JSON spec file format reference
|
|
36
|
-
- `docs/build-pipeline.md` -- Build pipeline and data precedence rules
|
|
37
|
-
|
|
38
|
-
## Task: update
|
|
39
|
-
|
|
40
|
-
The primary maintenance workflow. Regenerate `index.json` with the latest MDN/W3C data
|
|
41
|
-
and review what has changed.
|
|
42
|
-
|
|
43
|
-
### Step 1: Regenerate
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
yarn up:gen
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
This runs the generator scripts in `generator/`, which scrape live MDN data and merge it with
|
|
50
|
-
the manual spec files in `src/`. The result is written to `index.json`.
|
|
51
|
-
|
|
52
|
-
### Step 2: Review the diff
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
git diff packages/@markuplint/html-spec/index.json
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Categorize each change:
|
|
59
|
-
|
|
60
|
-
| Category | Examples | Action |
|
|
61
|
-
| ------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
-
| **Minor description rewording** | MDN refines role/element/attribute descriptions | Commit as-is |
|
|
63
|
-
| **New attributes** | `interestfor`, `switch` added by MDN | Commit as-is (MDN-sourced, no manual spec change needed) |
|
|
64
|
-
| **Flag transitions** | `experimental` → `deprecated`, `nonStandard` added/removed | Commit as-is |
|
|
65
|
-
| **Significant spec changes** | ARIA property `required` → `inherited`, content model restructured | Requires manual spec update (go to Step 3) |
|
|
66
|
-
| **ARIA 1.3 updates** | New/revised role definitions, property requirement changes | WAI-ARIA 1.3 is a Working Draft -- expect ongoing changes. 1.1 and 1.2 are finalized Recommendations and will not change. |
|
|
67
|
-
|
|
68
|
-
> **Caution -- ARIA version duplication:** `index.json` contains role definitions for
|
|
69
|
-
> WAI-ARIA 1.1, 1.2, and 1.3, so many strings appear three times. When editing
|
|
70
|
-
> descriptions or properties, **do not use `replace_all`** -- it will modify all three
|
|
71
|
-
> versions simultaneously. Always target the specific version block you intend to change.
|
|
72
|
-
|
|
73
|
-
### Step 3: Handle significant changes (if any)
|
|
74
|
-
|
|
75
|
-
If the diff contains substantive changes to element behavior, ARIA mappings, or
|
|
76
|
-
content models:
|
|
77
|
-
|
|
78
|
-
1. Identify the affected elements
|
|
79
|
-
2. Determine which source files need updating:
|
|
80
|
-
- `src/spec.<element>.jsonc` for element-specific changes
|
|
81
|
-
- `src/spec-common.contents.jsonc` for content model category changes
|
|
82
|
-
- `src/spec-common.attributes.jsonc` for global attribute changes
|
|
83
|
-
- In rare cases, `@markuplint/ml-spec` schemas or types may need updating
|
|
84
|
-
3. Make the changes, referencing the authoritative specification:
|
|
85
|
-
- HTML Living Standard: https://html.spec.whatwg.org/multipage/
|
|
86
|
-
- HTML-ARIA: https://w3c.github.io/html-aria/
|
|
87
|
-
- WAI-ARIA: https://w3c.github.io/aria/
|
|
88
|
-
4. Regenerate to incorporate manual spec changes:
|
|
89
|
-
```bash
|
|
90
|
-
yarn up:gen
|
|
91
|
-
```
|
|
92
|
-
5. Verify the final diff is correct
|
|
93
|
-
|
|
94
|
-
### Step 3b: Idempotency verification (when spec files are modified)
|
|
95
|
-
|
|
96
|
-
When you modify `src/spec.*.jsonc` files, verify that your changes produce stable output
|
|
97
|
-
before committing. This ensures the generated `index.json` does not contain unintended
|
|
98
|
-
drift:
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
# 1. Stage spec files and index.json
|
|
102
|
-
git add packages/@markuplint/html-spec/src/spec.*.jsonc packages/@markuplint/html-spec/index.json
|
|
103
|
-
|
|
104
|
-
# 2. Regenerate
|
|
105
|
-
yarn up:gen
|
|
106
|
-
|
|
107
|
-
# 3. Check that the attributes you changed are NOT in the diff (= stable output)
|
|
108
|
-
git diff packages/@markuplint/html-spec/index.json | grep '"your-attr"'
|
|
109
|
-
|
|
110
|
-
# 4. If stable, discard the regenerated file and use the staged version
|
|
111
|
-
git checkout packages/@markuplint/html-spec/index.json
|
|
112
|
-
|
|
113
|
-
# 5. Proceed to commit
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
If the diff shows unexpected changes for your attribute, it means the spec file and
|
|
117
|
-
the generator produce different values -- investigate before committing.
|
|
118
|
-
|
|
119
|
-
### Step 4: Test and commit
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
yarn workspace @markuplint/html-spec run test
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Stage and commit `index.json` and any modified `src/` files.
|
|
126
|
-
|
|
127
|
-
## Task: add-element
|
|
128
|
-
|
|
129
|
-
Add a new HTML element specification. Follow recipe #1 in `docs/maintenance.md`.
|
|
130
|
-
|
|
131
|
-
1. Read `src/spec.a.jsonc` as a reference for a typical element
|
|
132
|
-
2. Create `src/spec.<name>.jsonc` with required fields:
|
|
133
|
-
- `contentModel` with `contents`
|
|
134
|
-
- `globalAttrs` (`#HTMLGlobalAttrs`, `#GlobalEventAttrs`, `#ARIAAttrs` set to `true`)
|
|
135
|
-
- `attributes` (element-specific, can be `{}`)
|
|
136
|
-
- `aria` with `implicitRole` and `permittedRoles`
|
|
137
|
-
3. Add spec URL comments at the top (`//` format)
|
|
138
|
-
4. **Cross-package step**: If the element belongs to content categories (flow, phrasing, etc.),
|
|
139
|
-
add it to the appropriate categories in `src/spec-common.contents.jsonc`.
|
|
140
|
-
Without this, `@markuplint/rules`' `permitted-contents` rule will flag the element
|
|
141
|
-
as invalid content in parent elements that allow those categories.
|
|
142
|
-
5. Regenerate: `yarn workspace @markuplint/html-spec run gen`
|
|
143
|
-
6. Verify the element appears in `index.json`
|
|
144
|
-
7. Run tests: `yarn workspace @markuplint/html-spec run test`
|
|
145
|
-
|
|
146
|
-
## Task: add-svg-element
|
|
147
|
-
|
|
148
|
-
Add a new SVG element specification. Follow recipe #3 in `docs/maintenance.md`.
|
|
149
|
-
|
|
150
|
-
1. Read `src/spec.svg_circle.jsonc` as a reference for a typical SVG element
|
|
151
|
-
2. Create `src/spec.svg_<name>.jsonc` (the `svg_` prefix maps to namespace `svg:<name>`)
|
|
152
|
-
3. Use SVG-specific global attribute categories (`#SVGCoreAttrs`, `#SVGPresentationAttrs`)
|
|
153
|
-
4. For ARIA, use AAM references: `{ "core-aam": true, "graphics-aam": true }`
|
|
154
|
-
5. Regenerate: `yarn workspace @markuplint/html-spec run gen`
|
|
155
|
-
6. Run tests: `yarn workspace @markuplint/html-spec run test`
|
|
156
|
-
|
|
157
|
-
## Task: add-attribute
|
|
158
|
-
|
|
159
|
-
Add an attribute to an element. Follow recipe #2 in `docs/maintenance.md`.
|
|
160
|
-
|
|
161
|
-
1. Open `src/spec.<element>.jsonc`
|
|
162
|
-
2. Add the attribute entry to the `attributes` object. See `docs/element-spec-format.md`
|
|
163
|
-
for the full attribute definition format. Common patterns:
|
|
164
|
-
- Simple typed attribute: `"href": { "type": "URL" }`
|
|
165
|
-
- Conditional attribute: `"accept": { "type": ..., "condition": "[type='file' i]" }`
|
|
166
|
-
- Boolean attribute: `"disabled": { "type": "Boolean" }`
|
|
167
|
-
3. For a **global** attribute (applies to all elements), edit
|
|
168
|
-
`src/spec-common.attributes.jsonc` instead, adding the attribute to the
|
|
169
|
-
appropriate category (e.g., `#HTMLGlobalAttrs`)
|
|
170
|
-
4. Regenerate: `yarn workspace @markuplint/html-spec run gen`
|
|
171
|
-
5. Verify the attribute appears in `index.json` with correct metadata
|
|
172
|
-
6. Run tests: `yarn workspace @markuplint/html-spec run test`
|
|
173
|
-
|
|
174
|
-
## Task: remove-attribute
|
|
175
|
-
|
|
176
|
-
Remove an attribute from an element's manual specification.
|
|
177
|
-
|
|
178
|
-
1. Open `src/spec.<element>.jsonc`
|
|
179
|
-
2. Remove the attribute entry from the `attributes` object
|
|
180
|
-
3. For a **global** attribute, edit `src/spec-common.attributes.jsonc` instead
|
|
181
|
-
4. Regenerate: `yarn workspace @markuplint/html-spec run gen`
|
|
182
|
-
5. Verify the attribute no longer appears in `index.json` for the element.
|
|
183
|
-
**Note**: If the attribute also exists in MDN data, it will still appear in
|
|
184
|
-
`index.json` from the MDN source. To fully suppress an MDN-sourced attribute,
|
|
185
|
-
you may need to override it in the manual spec rather than simply removing it.
|
|
186
|
-
6. Run tests: `yarn workspace @markuplint/html-spec run test`
|
|
187
|
-
|
|
188
|
-
## Task: obsolete-element
|
|
189
|
-
|
|
190
|
-
Mark an element as obsolete. Follow recipe #8 in `docs/maintenance.md`.
|
|
191
|
-
|
|
192
|
-
There are two approaches:
|
|
193
|
-
|
|
194
|
-
- **Via generator's hardcoded list** (preferred for standard obsolete elements):
|
|
195
|
-
Add the element name to the `obsoleteList` array in
|
|
196
|
-
`packages/@markuplint/html-spec/generator/html-elements.ts`
|
|
197
|
-
- **Via manual spec file**: Set `"obsolete": true` in the element's
|
|
198
|
-
`src/spec.<element>.jsonc`
|
|
199
|
-
|
|
200
|
-
Obsolete elements automatically get:
|
|
201
|
-
|
|
202
|
-
- `cite` pointing to the HTML spec obsolete features section
|
|
203
|
-
- `contents: true` (any content allowed)
|
|
204
|
-
- `permittedRoles: true`, `implicitRole: false`
|
|
205
|
-
|
|
206
|
-
After making the change:
|
|
207
|
-
|
|
208
|
-
1. Regenerate: `yarn up:gen`
|
|
209
|
-
2. Verify the element appears in `index.json` with `"obsolete": true`
|
|
210
|
-
3. Run tests: `yarn workspace @markuplint/html-spec run test`
|
|
211
|
-
|
|
212
|
-
## Task: obsolete-attribute
|
|
213
|
-
|
|
214
|
-
Mark an attribute as deprecated in an element's specification.
|
|
215
|
-
|
|
216
|
-
1. Open `src/spec.<element>.jsonc`
|
|
217
|
-
2. Add `"deprecated": true` to the attribute definition:
|
|
218
|
-
```json
|
|
219
|
-
"align": {
|
|
220
|
-
"deprecated": true
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
If the attribute already has other fields (`type`, `condition`, etc.),
|
|
224
|
-
simply add `"deprecated": true` alongside them.
|
|
225
|
-
3. For a **global** attribute, edit `src/spec-common.attributes.jsonc` instead
|
|
226
|
-
4. Regenerate: `yarn workspace @markuplint/html-spec run gen`
|
|
227
|
-
5. Verify the attribute shows `"deprecated": true` in `index.json`
|
|
228
|
-
6. Run tests: `yarn workspace @markuplint/html-spec run test`
|
|
229
|
-
|
|
230
|
-
## Task: change-flag
|
|
231
|
-
|
|
232
|
-
Change the `experimental`, `deprecated`, or `nonStandard` flag on an attribute.
|
|
233
|
-
|
|
234
|
-
These boolean flags indicate the standardization status of an attribute:
|
|
235
|
-
|
|
236
|
-
| Flag | Meaning |
|
|
237
|
-
| -------------- | ----------------------------------------------------------------- |
|
|
238
|
-
| `experimental` | The attribute is part of an emerging specification not yet stable |
|
|
239
|
-
| `deprecated` | The attribute is obsolete and should not be used |
|
|
240
|
-
| `nonStandard` | The attribute is not part of any standard |
|
|
241
|
-
|
|
242
|
-
1. Open `src/spec.<element>.jsonc` (or `src/spec-common.attributes.jsonc` for globals)
|
|
243
|
-
2. Add, change, or remove the flag on the target attribute:
|
|
244
|
-
```json
|
|
245
|
-
"attributionsrc": {
|
|
246
|
-
"deprecated": true
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
To remove a flag, delete the property entirely.
|
|
250
|
-
3. **Note**: Flags from MDN scraping also appear in `index.json`. Manual spec flags
|
|
251
|
-
take precedence, so setting a flag in the manual spec will override the MDN value.
|
|
252
|
-
However, MDN-only attributes (not defined in manual specs) can only be overridden
|
|
253
|
-
by adding an entry for that attribute in the manual spec.
|
|
254
|
-
4. Regenerate: `yarn workspace @markuplint/html-spec run gen`
|
|
255
|
-
5. Verify the flag change in `index.json`
|
|
256
|
-
6. Run tests: `yarn workspace @markuplint/html-spec run test`
|
|
257
|
-
|
|
258
|
-
## ARIA Version System
|
|
259
|
-
|
|
260
|
-
### Resolution Logic
|
|
261
|
-
|
|
262
|
-
`resolveVersion()` (`@markuplint/ml-spec/src/utils/resolve-version.ts`) checks
|
|
263
|
-
`aria[version]` first, falls back to top-level `aria`. The runtime default is
|
|
264
|
-
`ARIA_RECOMMENDED_VERSION = '1.2'` (`@markuplint/ml-spec/src/utils/aria-version.ts`).
|
|
265
|
-
|
|
266
|
-
### Key Placement Rules
|
|
267
|
-
|
|
268
|
-
| Key | Meaning | Mutability |
|
|
269
|
-
| ---------------- | --------------------------------------------------------- | -------------------------------------------- |
|
|
270
|
-
| Top-level `aria` | Default / latest. Fallback for versions without overrides | Mutable — update to match current W3C Rec |
|
|
271
|
-
| `"1.1"` | ARIA 1.1 snapshot | **Frozen** — never add new roles |
|
|
272
|
-
| `"1.2"` | ARIA 1.2 snapshot (rarely needed) | Only create when top-level diverges from 1.2 |
|
|
273
|
-
|
|
274
|
-
### Decision: Where to add new permittedRoles
|
|
275
|
-
|
|
276
|
-
1. Is the role in the W3C Recommendation "ARIA in HTML" (ARIA 1.2 based, Aug 2025)?
|
|
277
|
-
→ Add to **top-level only**
|
|
278
|
-
2. Is the role ARIA 1.3 draft-only (not in W3C Rec)?
|
|
279
|
-
→ Add to **top-level**, AND create `"1.2"` key with the current 1.2 list to freeze it
|
|
280
|
-
3. Was the role in the original ARIA 1.1 spec for this element?
|
|
281
|
-
→ It should already be in `"1.1"`. **Never add new roles to `"1.1"`**.
|
|
282
|
-
|
|
283
|
-
### permittedRoles Quick Reference
|
|
284
|
-
|
|
285
|
-
| Pattern | Meaning |
|
|
286
|
-
| ---------------------------------------- | ----------------------------------- |
|
|
287
|
-
| `true` | Any role allowed |
|
|
288
|
-
| `false` | No roles allowed |
|
|
289
|
-
| `["role1", "role2"]` | Specific roles (alphabetical order) |
|
|
290
|
-
| `[{"name": "role", "deprecated": true}]` | Deprecated role |
|
|
291
|
-
|
|
292
|
-
## Task: check
|
|
293
|
-
|
|
294
|
-
Verify cross-package consistency between `@markuplint/html-spec` and related packages.
|
|
295
|
-
|
|
296
|
-
1. **Content model categories**: Verify that category names in `src/spec-common.contents.jsonc`
|
|
297
|
-
match the `Category` enum in `@markuplint/ml-spec/schemas/content-models.schema.json`
|
|
298
|
-
2. **Element membership**: Verify that elements listed in content categories have
|
|
299
|
-
corresponding `src/spec.<element>.jsonc` files and consistent `contentModel` definitions
|
|
300
|
-
3. **Attribute types**: Check that attribute type references (e.g., `"URL"`, `"<color>"`)
|
|
301
|
-
exist in `@markuplint/types`' definitions registry
|
|
302
|
-
4. **Schema validation**: Run `yarn workspace @markuplint/html-spec run test` to validate
|
|
303
|
-
all source JSON files against `@markuplint/ml-spec` schemas
|
|
304
|
-
|
|
305
|
-
Report results as:
|
|
306
|
-
|
|
307
|
-
```
|
|
308
|
-
| # | Check | Status | Notes |
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
## Testing Requirements for Spec Changes
|
|
312
|
-
|
|
313
|
-
Spec data changes propagate to multiple test suites. Always run `yarn test`
|
|
314
|
-
(full suite) before committing.
|
|
315
|
-
|
|
316
|
-
### Test Matrix
|
|
317
|
-
|
|
318
|
-
| Change type | Primary test file | Also check |
|
|
319
|
-
| ----------------------------------- | -------------------------------------------- | ------------------------------------------------------------- |
|
|
320
|
-
| ARIA (implicitRole, permittedRoles) | `rules/src/wai-aria/index.spec.ts` | `ml-spec/src/algorithm/aria/get-permitted-roles-spec.spec.ts` |
|
|
321
|
-
| Attributes (new/changed) | `rules/src/invalid-attr/index.spec.ts` | Existing tests with changed enum error messages |
|
|
322
|
-
| Content model | `rules/src/permitted-contents/index.spec.ts` | — |
|
|
323
|
-
|
|
324
|
-
### Cross-Package Impact
|
|
325
|
-
|
|
326
|
-
- **Hardcoded role arrays**: `ml-spec/.../get-permitted-roles-spec.spec.ts` has
|
|
327
|
-
hardcoded `permittedRoles` for img, button, input, form, etc. Update these
|
|
328
|
-
when changing `permittedRoles` in html-spec.
|
|
329
|
-
- **Enum error messages**: Adding a value to an enum (e.g., button `command`)
|
|
330
|
-
changes the error message string in existing `invalid-attr` tests.
|
|
331
|
-
|
|
332
|
-
### Test Conventions
|
|
333
|
-
|
|
334
|
-
- `toStrictEqual` with exact `{ severity, line, col, message, raw }` — never `toBeGreaterThan(0)`
|
|
335
|
-
- Always include both valid (empty violations) and invalid (exact violation) cases
|
|
336
|
-
- ARIA version in tests: `{ rule: { options: { version: '1.1' } } }`
|
|
337
|
-
- Some roles require ARIA attributes: focusable `separator` → `aria-valuenow`,
|
|
338
|
-
`meter` → `aria-valuenow`
|
|
339
|
-
|
|
340
|
-
## Rules
|
|
341
|
-
|
|
342
|
-
1. **`index.json` is generated -- never edit it directly.** Always modify `src/` files and regenerate.
|
|
343
|
-
2. **Manual spec data takes precedence over MDN data.** Attributes defined in `src/spec.*.jsonc` override same-named MDN-sourced attributes. Use this to correct inaccurate MDN data.
|
|
344
|
-
3. **Minor MDN description changes should be committed as-is.** Do not attempt to override cosmetic upstream improvements.
|
|
345
|
-
4. **Content model category membership is critical.** A missing element in a category causes `permitted-contents` rule false positives in downstream linting.
|
|
346
|
-
5. **Always run tests after changes.** Schema validation catches structural errors before they propagate to downstream packages.
|
|
347
|
-
6. **Reference authoritative specs for significant changes.** Use WebSearch to verify against HTML Living Standard, WAI-ARIA, and HTML-ARIA before modifying manual spec files.
|
|
348
|
-
7. **Use conventional commit prefixes based on the nature of the change:**
|
|
349
|
-
|
|
350
|
-
| Change type | Prefix | Example |
|
|
351
|
-
| ------------------------ | ------- | ------------------------------------------------- |
|
|
352
|
-
| Description updates only | `chore` | `chore(html-spec): update role descriptions` |
|
|
353
|
-
| Attribute/spec additions | `feat` | `feat(html-spec): add input switch attribute` |
|
|
354
|
-
| Spec data corrections | `fix` | `fix(html-spec): correct ARIA mapping for button` |
|
|
355
|
-
|
|
356
|
-
8. **Separate spec changes into individual PRs.** Each specification change (new attribute, ARIA mapping fix, etc.) should be on its own branch and PR. Description-only updates can be batched into a single PR.
|
|
357
|
-
9. **Run `yarn test` (full suite) before committing.** Spec changes affect `@markuplint/rules` and `@markuplint/ml-spec` tests.
|
|
358
|
-
10. **Keep `permittedRoles` arrays in alphabetical order.**
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
# ビルドパイプライン
|
|
2
|
-
|
|
3
|
-
ソースファイルと外部データから `index.json` がどのように生成されるかを解説します。
|
|
4
|
-
|
|
5
|
-
## 概要
|
|
6
|
-
|
|
7
|
-
`@markuplint/html-spec` は `generator/` のスクリプトを使用して、単一の統合 `index.json` ファイルを生成します。ビルドプロセス:
|
|
8
|
-
|
|
9
|
-
1. `src/` から 208 個の要素 JSON 仕様ファイル(HTML、SVG、MathML)と 2 個の共通定義ファイルを読み込む
|
|
10
|
-
2. MDN Web Docs、W3C ARIA 仕様、HTML Living Standard から外部データをフェッチ
|
|
11
|
-
3. 手動仕様と外部データをマージ(手動データが常に優先)
|
|
12
|
-
4. 統合結果を `index.json` に出力(約 48K 行、約 1.4MB)
|
|
13
|
-
|
|
14
|
-
ビルドは外部データをライブでフェッチするため、ネットワーク依存です。クリーンな実行で数分かかります。
|
|
15
|
-
|
|
16
|
-
## ビルドフロー図
|
|
17
|
-
|
|
18
|
-
```mermaid
|
|
19
|
-
flowchart TD
|
|
20
|
-
subgraph inputs ["ソースファイル(html-spec)"]
|
|
21
|
-
specFiles["src/spec.*.jsonc\n(208 要素ファイル)"]
|
|
22
|
-
commonAttrs["src/spec-common.attributes.jsonc\n(20 グローバル属性カテゴリ)"]
|
|
23
|
-
commonContents["src/spec-common.contents.jsonc\n(コンテンツモデルマクロ)"]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
subgraph build ["ビルド"]
|
|
27
|
-
buildScript["build.ts"]
|
|
28
|
-
specGen["generator/"]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
subgraph external ["外部データソース"]
|
|
32
|
-
mdn["MDN Web Docs"]
|
|
33
|
-
aria["W3C ARIA(1.1 / 1.2 / 1.3)"]
|
|
34
|
-
svg["SVG / Graphics ARIA"]
|
|
35
|
-
mathml["MathML"]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
subgraph output ["出力"]
|
|
39
|
-
indexJson["index.json\n(48K+ 行)"]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
specFiles --> buildScript
|
|
43
|
-
commonAttrs --> buildScript
|
|
44
|
-
commonContents --> buildScript
|
|
45
|
-
buildScript --> specGen
|
|
46
|
-
|
|
47
|
-
mdn --> specGen
|
|
48
|
-
aria --> specGen
|
|
49
|
-
svg --> specGen
|
|
50
|
-
mathml --> specGen
|
|
51
|
-
|
|
52
|
-
specGen -->|"手動データ優先で\nマージ"| indexJson
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## ビルドエントリポイント
|
|
56
|
-
|
|
57
|
-
`build.ts` が `generator/` の `main()` を呼び出します。
|
|
58
|
-
|
|
59
|
-
## 外部データソース
|
|
60
|
-
|
|
61
|
-
generator はビルド時に以下の外部ソースからデータをフェッチします。
|
|
62
|
-
|
|
63
|
-
| ソース | 提供データ |
|
|
64
|
-
| ----------------------------------------- | ------------------------------------------------------------ |
|
|
65
|
-
| MDN Web Docs(HTML) | 要素の説明、コンテンツカテゴリ、属性メタデータ、互換性フラグ |
|
|
66
|
-
| MDN Web Docs(SVG) | SVG 要素の説明、非推奨要素リスト |
|
|
67
|
-
| MDN Web Docs(MathML) | MathML 要素の説明、非推奨要素リスト |
|
|
68
|
-
| WAI-ARIA 1.1(`w3.org/TR/wai-aria-1.1/`) | ロール定義、プロパティ、ステート |
|
|
69
|
-
| WAI-ARIA 1.2(`w3.org/TR/wai-aria-1.2/`) | 更新されたロール定義 |
|
|
70
|
-
| WAI-ARIA 1.3(`w3c.github.io/aria/`) | 最新の Editor's Draft |
|
|
71
|
-
| Graphics ARIA | グラフィックス固有 ARIA ロール |
|
|
72
|
-
| HTML-ARIA(`w3.org/TR/html-aria/`) | HTML 属性から ARIA プロパティへのマッピング |
|
|
73
|
-
|
|
74
|
-
generator の内部アーキテクチャ(スクレイピング、キャッシュ、モジュール構成)の詳細は `generator/` ディレクトリを参照してください。
|
|
75
|
-
|
|
76
|
-
## データ優先順位ルール
|
|
77
|
-
|
|
78
|
-
手動仕様と外部データが重複する場合:
|
|
79
|
-
|
|
80
|
-
| データ | ソース | 優先度 |
|
|
81
|
-
| -------------- | --------------- | -------------------------- |
|
|
82
|
-
| `contentModel` | 手動仕様のみ | 最高(スクレイピングなし) |
|
|
83
|
-
| `aria` | 手動仕様のみ | 最高(スクレイピングなし) |
|
|
84
|
-
| `globalAttrs` | 手動仕様のみ | 最高(スクレイピングなし) |
|
|
85
|
-
| `attributes` | 手動仕様 + MDN | 手動が優先、MDN が補完 |
|
|
86
|
-
| `description` | MDN のみ | MDN のみ |
|
|
87
|
-
| `categories` | MDN のみ | MDN のみ |
|
|
88
|
-
| `cite` | 手動仕様 or MDN | 手動仕様があれば優先 |
|
|
89
|
-
| 互換性フラグ | 手動仕様 + MDN | 手動が優先、MDN が補完 |
|
|
90
|
-
|
|
91
|
-
ポイント:
|
|
92
|
-
|
|
93
|
-
- **手動データが常に優先** -- MDN スクレイピングデータを上書きする
|
|
94
|
-
- `attributes` は、手動仕様に同名の属性がない場合のみ MDN データが追加される
|
|
95
|
-
- `contentModel` と `aria` はスクレイピングされない -- `src/spec.*.jsonc` からのみ取得
|
|
96
|
-
- `cite` URL はデフォルトで MDN ページだが、要素ごとにオーバーライド可能
|
|
97
|
-
|
|
98
|
-
**属性マージの詳細動作:**
|
|
99
|
-
|
|
100
|
-
1. **仕様ファイルに属性定義あり** -- MDN データ(description、互換性フラグ)がマージ
|
|
101
|
-
されるが、仕様ファイル側の値が優先される。例えば、仕様ファイルで `"deprecated": true`
|
|
102
|
-
を設定し、MDN が deprecated フラグを付けていない場合、仕様ファイルの値が使われる。
|
|
103
|
-
2. **MDN にのみ属性あり** -- MDN のメタデータとともにそのまま追加される。
|
|
104
|
-
3. **仕様ファイルにのみ属性あり** -- MDN による補完なしにそのまま使用される。
|
|
105
|
-
|
|
106
|
-
## 生成出力構造
|
|
107
|
-
|
|
108
|
-
`index.json` は `@markuplint/ml-spec` の `ExtendedSpec` 型に従います。
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
{
|
|
112
|
-
cites: string[]; // フェッチされた全 URL のソート済みリスト
|
|
113
|
-
def: {
|
|
114
|
-
"#globalAttrs": { ... }, // 20 グローバル属性カテゴリ
|
|
115
|
-
"#aria": { // バージョン別 ARIA 定義
|
|
116
|
-
"1.1": { roles, props, graphicsRoles },
|
|
117
|
-
"1.2": { roles, props, graphicsRoles },
|
|
118
|
-
"1.3": { roles, props, graphicsRoles }
|
|
119
|
-
},
|
|
120
|
-
"#contentModels": { ... } // コンテンツモデルカテゴリマクロ
|
|
121
|
-
},
|
|
122
|
-
specs: ElementSpec[] // 要素仕様配列(アルファベット順、MathML は HTML の後、SVG はその後)
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
- `cites` -- フェッチされた全 URL(トレーサビリティ用)
|
|
127
|
-
- `def["#globalAttrs"]` -- `spec-common.attributes.jsonc` から
|
|
128
|
-
- `def["#aria"]` -- W3C ARIA 仕様からスクレイピング
|
|
129
|
-
- `def["#contentModels"]` -- `spec-common.contents.jsonc` から
|
|
130
|
-
- `specs` -- マージ済み要素仕様の配列
|
|
131
|
-
|
|
132
|
-
## ビルドコマンド
|
|
133
|
-
|
|
134
|
-
| コマンド | 説明 |
|
|
135
|
-
| ------------------------------------------------------- | ---------------------------------------------- |
|
|
136
|
-
| `yarn workspace @markuplint/html-spec run gen` | フル生成(ビルド + Prettier フォーマット) |
|
|
137
|
-
| `yarn workspace @markuplint/html-spec run gen:build` | 生成のみ |
|
|
138
|
-
| `yarn workspace @markuplint/html-spec run gen:prettier` | Prettier で `index.json` をフォーマット |
|
|
139
|
-
| `yarn up:gen` | リポジトリルートから全 spec パッケージを再生成 |
|
|
140
|
-
|
|
141
|
-
`gen` は `npm-run-all` を使用して `gen:build` → `gen:prettier` を順次実行します。
|
|
142
|
-
|
|
143
|
-
## エクスポート
|
|
144
|
-
|
|
145
|
-
パッケージは 2 通りの方法でデータをエクスポートします。
|
|
146
|
-
|
|
147
|
-
```json
|
|
148
|
-
{
|
|
149
|
-
".": { "import": { "default": "./index.js", "types": "./index.d.ts" } },
|
|
150
|
-
"./json": "./index.json"
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
型付きラッパーのインポート、または `./json` サブパスによる生の JSON アクセスが可能です。
|
package/docs/build-pipeline.md
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
# Build Pipeline
|
|
2
|
-
|
|
3
|
-
This document describes how `index.json` is generated from the source files and external data.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The `@markuplint/html-spec` package uses `generator/` scripts to produce a single consolidated `index.json` file. The build process:
|
|
8
|
-
|
|
9
|
-
1. Reads 208 per-element JSON spec files (HTML, SVG, MathML) and 2 common definition files from `src/`
|
|
10
|
-
2. Fetches external data from MDN Web Docs, W3C ARIA specifications, and the HTML Living Standard
|
|
11
|
-
3. Merges manual specifications with external data (manual data takes precedence)
|
|
12
|
-
4. Writes the consolidated output to `index.json` (~48K lines, ~1.4MB)
|
|
13
|
-
|
|
14
|
-
The build is network-dependent because external data is fetched live. Expect several minutes on a clean run.
|
|
15
|
-
|
|
16
|
-
## Build Flow Diagram
|
|
17
|
-
|
|
18
|
-
```mermaid
|
|
19
|
-
flowchart TD
|
|
20
|
-
subgraph inputs ["Source Files (html-spec)"]
|
|
21
|
-
specFiles["src/spec.*.jsonc\n(208 element files)"]
|
|
22
|
-
commonAttrs["src/spec-common.attributes.jsonc\n(20 global attribute categories)"]
|
|
23
|
-
commonContents["src/spec-common.contents.jsonc\n(content model macros)"]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
subgraph build ["Build"]
|
|
27
|
-
buildScript["build.ts"]
|
|
28
|
-
specGen["generator/"]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
subgraph external ["External Data Sources"]
|
|
32
|
-
mdn["MDN Web Docs"]
|
|
33
|
-
aria["W3C ARIA (1.1 / 1.2 / 1.3)"]
|
|
34
|
-
svg["SVG / Graphics ARIA"]
|
|
35
|
-
mathml["MathML"]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
subgraph output ["Output"]
|
|
39
|
-
indexJson["index.json\n(48K+ lines)"]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
specFiles --> buildScript
|
|
43
|
-
commonAttrs --> buildScript
|
|
44
|
-
commonContents --> buildScript
|
|
45
|
-
buildScript --> specGen
|
|
46
|
-
|
|
47
|
-
mdn --> specGen
|
|
48
|
-
aria --> specGen
|
|
49
|
-
svg --> specGen
|
|
50
|
-
mathml --> specGen
|
|
51
|
-
|
|
52
|
-
specGen -->|"merge\n(manual takes precedence)"| indexJson
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Build Entry Point
|
|
56
|
-
|
|
57
|
-
The build is triggered via `build.ts`, which calls the `main()` function from `generator/index.ts`.
|
|
58
|
-
|
|
59
|
-
## External Data Sources
|
|
60
|
-
|
|
61
|
-
The generator fetches live data from the following sources during the build:
|
|
62
|
-
|
|
63
|
-
| Source | Data Provided |
|
|
64
|
-
| ---------------------------------------- | --------------------------------------------------------------------------------- |
|
|
65
|
-
| MDN Web Docs (HTML) | Element descriptions, content categories, attribute metadata, compatibility flags |
|
|
66
|
-
| MDN Web Docs (SVG) | SVG element descriptions and deprecated element list |
|
|
67
|
-
| MDN Web Docs (MathML) | MathML element descriptions and deprecated element list |
|
|
68
|
-
| WAI-ARIA 1.1 (`w3.org/TR/wai-aria-1.1/`) | Role definitions, properties, states |
|
|
69
|
-
| WAI-ARIA 1.2 (`w3.org/TR/wai-aria-1.2/`) | Updated role definitions |
|
|
70
|
-
| WAI-ARIA 1.3 (`w3c.github.io/aria/`) | Latest editor's draft |
|
|
71
|
-
| Graphics ARIA | Graphics-specific ARIA roles |
|
|
72
|
-
| HTML-ARIA (`w3.org/TR/html-aria/`) | HTML attribute to ARIA property mappings |
|
|
73
|
-
|
|
74
|
-
For details on the generator's internal architecture (scraping, caching, module structure), see the `generator/` directory.
|
|
75
|
-
|
|
76
|
-
## Data Precedence Rules
|
|
77
|
-
|
|
78
|
-
When manual specifications and external data overlap:
|
|
79
|
-
|
|
80
|
-
| Data | Source | Precedence |
|
|
81
|
-
| ------------------- | ------------------ | --------------------------- |
|
|
82
|
-
| `contentModel` | Manual spec only | Highest (never scraped) |
|
|
83
|
-
| `aria` | Manual spec only | Highest (never scraped) |
|
|
84
|
-
| `globalAttrs` | Manual spec only | Highest (never scraped) |
|
|
85
|
-
| `attributes` | Manual spec + MDN | Manual wins; MDN fills gaps |
|
|
86
|
-
| `description` | MDN only | MDN only |
|
|
87
|
-
| `categories` | MDN only | MDN only |
|
|
88
|
-
| `cite` | Manual spec or MDN | Manual spec if provided |
|
|
89
|
-
| Compatibility flags | Manual spec + MDN | Manual wins; MDN fills gaps |
|
|
90
|
-
|
|
91
|
-
Key points:
|
|
92
|
-
|
|
93
|
-
- **Manual data always takes precedence** over MDN-scraped data
|
|
94
|
-
- For `attributes`, MDN-scraped attributes are added only when the manual spec does not define that attribute name
|
|
95
|
-
- Content models and ARIA mappings are never scraped -- they come exclusively from your `src/spec.*.jsonc` files
|
|
96
|
-
- The `cite` URL defaults to the MDN page but can be overridden per element
|
|
97
|
-
|
|
98
|
-
**Attribute merge behavior in detail:**
|
|
99
|
-
|
|
100
|
-
1. **Attribute defined in spec file** -- MDN data (description, compatibility flags) is
|
|
101
|
-
merged in, but spec-side values take precedence. For example, if the spec file sets
|
|
102
|
-
`"deprecated": true` but MDN does not flag the attribute as deprecated, the spec
|
|
103
|
-
value wins.
|
|
104
|
-
2. **Attribute exists only in MDN** -- Added to the element as-is with MDN metadata.
|
|
105
|
-
3. **Attribute exists only in spec file** -- Used as-is with no MDN augmentation.
|
|
106
|
-
|
|
107
|
-
## Generated Output Structure
|
|
108
|
-
|
|
109
|
-
The `index.json` follows the `ExtendedSpec` type from `@markuplint/ml-spec`:
|
|
110
|
-
|
|
111
|
-
```typescript
|
|
112
|
-
{
|
|
113
|
-
cites: string[]; // Sorted list of all URLs fetched during generation
|
|
114
|
-
def: {
|
|
115
|
-
"#globalAttrs": { ... }, // 20 global attribute categories
|
|
116
|
-
"#aria": { // ARIA definitions per version
|
|
117
|
-
"1.1": { roles, props, graphicsRoles },
|
|
118
|
-
"1.2": { roles, props, graphicsRoles },
|
|
119
|
-
"1.3": { roles, props, graphicsRoles }
|
|
120
|
-
},
|
|
121
|
-
"#contentModels": { ... } // Content model category macros
|
|
122
|
-
},
|
|
123
|
-
specs: ElementSpec[] // Element specifications, sorted alphabetically (MathML after HTML, SVG after MathML)
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
- `cites` -- all fetched URLs, for traceability
|
|
128
|
-
- `def["#globalAttrs"]` -- from `spec-common.attributes.jsonc`
|
|
129
|
-
- `def["#aria"]` -- scraped from W3C ARIA specifications
|
|
130
|
-
- `def["#contentModels"]` -- from `spec-common.contents.jsonc`
|
|
131
|
-
- `specs` -- merged element specifications array
|
|
132
|
-
|
|
133
|
-
## Build Commands
|
|
134
|
-
|
|
135
|
-
| Command | Description |
|
|
136
|
-
| ------------------------------------------------------- | ------------------------------------------------- |
|
|
137
|
-
| `yarn workspace @markuplint/html-spec run gen` | Full generation (build + Prettier formatting) |
|
|
138
|
-
| `yarn workspace @markuplint/html-spec run gen:build` | Generation only |
|
|
139
|
-
| `yarn workspace @markuplint/html-spec run gen:prettier` | Format `index.json` with Prettier |
|
|
140
|
-
| `yarn up:gen` | Regenerate all spec packages from repository root |
|
|
141
|
-
|
|
142
|
-
The `gen` script runs `gen:build` then `gen:prettier` in sequence via `npm-run-all`.
|
|
143
|
-
|
|
144
|
-
## Exports
|
|
145
|
-
|
|
146
|
-
The package exports the data in two ways:
|
|
147
|
-
|
|
148
|
-
```json
|
|
149
|
-
{
|
|
150
|
-
".": { "import": { "default": "./index.js", "types": "./index.d.ts" } },
|
|
151
|
-
"./json": "./index.json"
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Consumers can import the typed wrapper or access the raw JSON via the `./json` subpath.
|