@markuplint/html-spec 5.0.0-rc.0 → 5.0.0-rc.2
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/ARCHITECTURE.ja.md +12 -25
- package/ARCHITECTURE.md +12 -13
- package/CHANGELOG.md +37 -0
- package/README.md +2 -2
- package/SKILL.md +3 -3
- package/docs/build-pipeline.ja.md +6 -25
- package/docs/build-pipeline.md +6 -25
- package/docs/maintenance.ja.md +53 -3
- package/docs/maintenance.md +57 -10
- package/index.json +221 -91
- package/package.json +19 -10
package/ARCHITECTURE.ja.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`@markuplint/html-spec` は HTML Living Standard のデータセットプロバイダです。TypeScript ソースコードを含まない純粋なデータパッケージであり、208 個の要素 JSON 仕様ファイル(HTML、SVG、MathML)と 2 個の共通定義ファイルから構成されます。
|
|
6
6
|
|
|
7
|
-
ビルド時に
|
|
7
|
+
ビルド時に `generator/` のスクリプトが外部ソース(MDN、W3C ARIA 1.1/1.2/1.3、HTML Living Standard、SVG 仕様、MathML 仕様)からデータをフェッチし、手動で管理されたローカル仕様とマージして、統合された `index.json`(48,000 行以上、約 1.4MB)を生成します。手動データは常に外部データより優先され、仕様の正確性を保証します。
|
|
8
8
|
|
|
9
9
|
## ディレクトリ構成
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ src/
|
|
|
18
18
|
├── spec-common.attributes.jsonc # 20 個のグローバル属性カテゴリ定義
|
|
19
19
|
└── spec-common.contents.jsonc # HTML 10 + SVG 19 + MathML 3 のコンテンツモデルカテゴリ定義
|
|
20
20
|
|
|
21
|
-
build.
|
|
21
|
+
build.ts # generator/ モジュールを呼び出すビルドスクリプト
|
|
22
22
|
index.json # 生成出力(48K 行以上、編集不可)
|
|
23
23
|
index.js # CommonJS エントリーポイント
|
|
24
24
|
index.d.ts # TypeScript 型宣言
|
|
@@ -38,7 +38,7 @@ flowchart TD
|
|
|
38
38
|
|
|
39
39
|
subgraph build ["ビルドパイプライン"]
|
|
40
40
|
buildMjs["build.mjs"]
|
|
41
|
-
specGen["
|
|
41
|
+
specGen["generator/\nmain()"]
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
subgraph external ["外部データソース"]
|
|
@@ -119,7 +119,7 @@ export = json;
|
|
|
119
119
|
| -------------- | --------------------------------------- | ------------------------------------------------------------- |
|
|
120
120
|
| ソース仕様 | `src/spec.*.jsonc`(208 ファイル) | 要素ごとの仕様定義(コンテンツモデル、属性、ARIA マッピング) |
|
|
121
121
|
| 共通定義 | `src/spec-common.*.jsonc`(2 ファイル) | グローバル属性カテゴリとコンテンツモデルマクロの共有定義 |
|
|
122
|
-
| ビルドシステム | `build.
|
|
122
|
+
| ビルドシステム | `build.ts` | `generator/` の `main()` を呼び出すエントリー |
|
|
123
123
|
| 生成出力 | `index.json` | 統合データセット(48K 行以上、直接編集不可) |
|
|
124
124
|
| 型宣言 | `index.d.ts` | `@markuplint/ml-spec` からの型を再エクスポート |
|
|
125
125
|
| スキーマ検証 | `test/structure.spec.mjs` | Ajv ベースの JSON スキーマ検証テスト |
|
|
@@ -186,19 +186,7 @@ export = json;
|
|
|
186
186
|
|
|
187
187
|
## ビルドパイプライン
|
|
188
188
|
|
|
189
|
-
ビルドは `build.
|
|
190
|
-
|
|
191
|
-
```javascript
|
|
192
|
-
import path from 'node:path';
|
|
193
|
-
import { main } from '@markuplint/spec-generator';
|
|
194
|
-
|
|
195
|
-
await main({
|
|
196
|
-
outputFilePath: path.resolve(import.meta.dirname, 'index.json'),
|
|
197
|
-
htmlFilePattern: path.resolve(import.meta.dirname, 'src', 'spec.*.jsonc'),
|
|
198
|
-
commonAttrsFilePath: path.resolve(import.meta.dirname, 'src', 'spec-common.attributes.jsonc'),
|
|
199
|
-
commonContentsFilePath: path.resolve(import.meta.dirname, 'src', 'spec-common.contents.jsonc'),
|
|
200
|
-
});
|
|
201
|
-
```
|
|
189
|
+
ビルドは `build.ts` を通じて `generator/` の `main()` 関数を呼び出します。
|
|
202
190
|
|
|
203
191
|
ビルドプロセスの流れ:
|
|
204
192
|
|
|
@@ -231,18 +219,17 @@ yarn gen:prettier
|
|
|
231
219
|
|
|
232
220
|
## 外部依存パッケージ
|
|
233
221
|
|
|
234
|
-
| パッケージ
|
|
235
|
-
|
|
|
236
|
-
| `@markuplint/ml-spec`
|
|
237
|
-
| `@markuplint/
|
|
238
|
-
| `@markuplint/test-tools` | 開発 | テストユーティリティ(`glob` 等) |
|
|
222
|
+
| パッケージ | 種別 | 用途 |
|
|
223
|
+
| ------------------------ | ---- | -------------------------------------------- |
|
|
224
|
+
| `@markuplint/ml-spec` | 本番 | 型定義(`Cites`, `ElementSpec`, `SpecDefs`) |
|
|
225
|
+
| `@markuplint/test-tools` | 開発 | テストユーティリティ(`glob` 等) |
|
|
239
226
|
|
|
240
227
|
## 他パッケージとの連携
|
|
241
228
|
|
|
242
229
|
```mermaid
|
|
243
230
|
flowchart LR
|
|
244
231
|
subgraph upstream ["上流パッケージ"]
|
|
245
|
-
specGen["
|
|
232
|
+
specGen["generator/\n(ビルドパイプライン)"]
|
|
246
233
|
mlSpecTypes["@markuplint/ml-spec\n(型定義)"]
|
|
247
234
|
end
|
|
248
235
|
|
|
@@ -273,7 +260,7 @@ flowchart LR
|
|
|
273
260
|
### 上流
|
|
274
261
|
|
|
275
262
|
- **`@markuplint/ml-spec`** は `index.d.ts` で使用される型定義(`Cites`, `ElementSpec`, `SpecDefs`)を提供します。
|
|
276
|
-
-
|
|
263
|
+
- **`generator/`** はビルド時に外部仕様のフェッチとデータ統合を担当します。
|
|
277
264
|
|
|
278
265
|
### 下流
|
|
279
266
|
|
|
@@ -285,5 +272,5 @@ flowchart LR
|
|
|
285
272
|
## ドキュメントマップ
|
|
286
273
|
|
|
287
274
|
- [要素仕様フォーマット](docs/element-spec-format.ja.md) -- 要素 JSON の構造、フィールド定義、条件分岐パターン
|
|
288
|
-
- [ビルドパイプライン](docs/build-pipeline.ja.md) --
|
|
275
|
+
- [ビルドパイプライン](docs/build-pipeline.ja.md) -- generator の動作、外部データフェッチ、マージ戦略
|
|
289
276
|
- [メンテナンスガイド](docs/maintenance.ja.md) -- 新規要素の追加、属性更新、外部仕様の変更対応
|
package/ARCHITECTURE.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
`@markuplint/html-spec` is the canonical HTML Living Standard dataset provider for markuplint. It is a pure data package with no TypeScript source code. It contains 208 per-element JSON specification files (HTML, SVG, and MathML) and 2 common definition files that are processed by
|
|
5
|
+
`@markuplint/html-spec` is the canonical HTML Living Standard dataset provider for markuplint. It is a pure data package with no TypeScript source code. It contains 208 per-element JSON specification files (HTML, SVG, and MathML) and 2 common definition files that are processed by `generator/` scripts to produce a single consolidated `index.json` (48K+ lines, 1.4MB).
|
|
6
6
|
|
|
7
|
-
During the build,
|
|
7
|
+
During the build, `generator/` fetches live data from MDN, W3C ARIA specifications (1.1, 1.2, 1.3), Graphics ARIA, DPub ARIA, HTML-ARIA mappings, the HTML Living Standard, SVG specifications, and MathML specifications, then merges that external data with the hand-authored JSON files. Manual specifications always take precedence over fetched data, ensuring stable, curated definitions while still benefiting from automated enrichment.
|
|
8
8
|
|
|
9
9
|
## Directory Structure
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ src/
|
|
|
18
18
|
├── spec-common.attributes.jsonc # 20 global attribute category definitions
|
|
19
19
|
└── spec-common.contents.jsonc # 10 HTML + 19 SVG + 3 MathML content model category definitions
|
|
20
20
|
|
|
21
|
-
build.
|
|
21
|
+
build.ts # Build script invoking generator/ modules
|
|
22
22
|
index.json # Generated output (48K+ lines, DO NOT EDIT)
|
|
23
23
|
index.js # CommonJS entry point (re-exports index.json)
|
|
24
24
|
index.d.ts # TypeScript type declarations
|
|
@@ -38,7 +38,7 @@ flowchart TD
|
|
|
38
38
|
|
|
39
39
|
subgraph build ["Build Pipeline"]
|
|
40
40
|
buildScript["build.mjs"]
|
|
41
|
-
specGen["
|
|
41
|
+
specGen["generator/\nmain()"]
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
subgraph external ["External Data Sources"]
|
|
@@ -142,18 +142,17 @@ An array of element specifications. Each entry defines a single HTML, SVG, or Ma
|
|
|
142
142
|
| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
|
143
143
|
| Source Specifications | 208 `src/spec.*.jsonc` files | Per-element definitions: content models, attributes, ARIA mappings |
|
|
144
144
|
| Common Definitions | `spec-common.attributes.jsonc`, `spec-common.contents.jsonc` | Shared global attribute categories and content model category macros |
|
|
145
|
-
| Build System | `build.
|
|
145
|
+
| Build System | `build.ts` | Invokes `generator/` to merge sources with external data |
|
|
146
146
|
| Generated Output | `index.json` | Single consolidated dataset consumed by downstream packages |
|
|
147
147
|
| Type Declarations | `index.d.ts` | Re-exports `Cites`, `ElementSpec`, `SpecDefs` from `@markuplint/ml-spec` |
|
|
148
148
|
| Schema Validation | `test/structure.spec.mjs` | Ajv-based validation of generated output against `@markuplint/ml-spec` schemas |
|
|
149
149
|
|
|
150
150
|
## External Dependencies
|
|
151
151
|
|
|
152
|
-
| Dependency
|
|
153
|
-
|
|
|
154
|
-
| `@markuplint/ml-spec`
|
|
155
|
-
| `@markuplint/
|
|
156
|
-
| `@markuplint/test-tools` | Dev | Test utilities (`glob` for file discovery) |
|
|
152
|
+
| Dependency | Type | Purpose |
|
|
153
|
+
| ------------------------ | ---------- | ----------------------------------------------------- |
|
|
154
|
+
| `@markuplint/ml-spec` | Production | Type definitions (`Cites`, `ElementSpec`, `SpecDefs`) |
|
|
155
|
+
| `@markuplint/test-tools` | Dev | Test utilities (`glob` for file discovery) |
|
|
157
156
|
|
|
158
157
|
## Integration Points
|
|
159
158
|
|
|
@@ -161,7 +160,7 @@ An array of element specifications. Each entry defines a single HTML, SVG, or Ma
|
|
|
161
160
|
flowchart LR
|
|
162
161
|
subgraph upstream ["Upstream"]
|
|
163
162
|
mlSpec["@markuplint/ml-spec\n(types + schemas)"]
|
|
164
|
-
specGen["
|
|
163
|
+
specGen["generator/\n(build scripts)"]
|
|
165
164
|
end
|
|
166
165
|
|
|
167
166
|
subgraph pkg ["@markuplint/html-spec"]
|
|
@@ -192,7 +191,7 @@ flowchart LR
|
|
|
192
191
|
### Upstream
|
|
193
192
|
|
|
194
193
|
- **`@markuplint/ml-spec`** provides the TypeScript type definitions (`MLMLSpec`, `ElementSpec`, `SpecDefs`) and JSON schemas used to validate the generated output. The `index.d.ts` re-exports these types.
|
|
195
|
-
-
|
|
194
|
+
- **`generator/`** is the build module invoked by `build.ts`. It reads the source JSON files, fetches live data from MDN Web Docs, W3C ARIA specifications (versions 1.1, 1.2, 1.3), Graphics ARIA, DPub ARIA, HTML-ARIA mappings, the HTML Living Standard, SVG specifications, and MathML specifications, then merges everything into `index.json`.
|
|
196
195
|
|
|
197
196
|
### Downstream
|
|
198
197
|
|
|
@@ -203,5 +202,5 @@ flowchart LR
|
|
|
203
202
|
## Documentation Map
|
|
204
203
|
|
|
205
204
|
- [Element Specification Format](docs/element-spec-format.md) -- Structure and fields of per-element JSON files
|
|
206
|
-
- [Build Pipeline](docs/build-pipeline.md) -- How build.
|
|
205
|
+
- [Build Pipeline](docs/build-pipeline.md) -- How build.ts and generator/ produce index.json
|
|
207
206
|
- [Maintenance Guide](docs/maintenance.md) -- Adding elements, updating external sources, troubleshooting
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,43 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-rc.2](https://github.com/markuplint/markuplint/compare/v5.0.0-rc.1...v5.0.0-rc.2) (2026-04-15)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **html-spec:** add dir as required attribute for bdo element ([81a6c1f](https://github.com/markuplint/markuplint/commit/81a6c1f40630b3b9a904d380aed47042dfb90972))
|
|
11
|
+
- **html-spec:** change dl content model from oneOrMore to zeroOrMore groups ([e29f6e4](https://github.com/markuplint/markuplint/commit/e29f6e4beb6cee1143d2aa4f53b770d97624dd0a)), closes [#3592](https://github.com/markuplint/markuplint/issues/3592)
|
|
12
|
+
- **html-spec:** change optgroup label type from Any to NoEmptyAny ([c6b0e88](https://github.com/markuplint/markuplint/commit/c6b0e887cbb7576e9139a269c98b8718bcaffb18))
|
|
13
|
+
- **html-spec:** correct permittedRoles for input[type=button/image/reset/submit] ([054e8e2](https://github.com/markuplint/markuplint/commit/054e8e2b1ca9c1b85fa5a0bcd18f72a22669f4a5)), closes [#3588](https://github.com/markuplint/markuplint/issues/3588)
|
|
14
|
+
- **html-spec:** override MDN incorrect experimental flag on audio loading attribute ([09d5898](https://github.com/markuplint/markuplint/commit/09d5898256ef0880bcdce9d8a514fbcae6b4d226))
|
|
15
|
+
- **html-spec:** override MDN incorrect experimental flag on video loading attribute ([52def75](https://github.com/markuplint/markuplint/commit/52def759157d046cacc0660422db188e4d8da753)), closes [#3697](https://github.com/markuplint/markuplint/issues/3697)
|
|
16
|
+
- **html-spec:** remove global attr overrides that drop type definitions ([6ff2f0d](https://github.com/markuplint/markuplint/commit/6ff2f0d2ac8c0410b90af5e9ccb6be126ec96c39))
|
|
17
|
+
- **html-spec:** restore ARIA 1.3 role name extraction ([01b9ce3](https://github.com/markuplint/markuplint/commit/01b9ce350b472e9f37f04238be446c3898e317a8))
|
|
18
|
+
|
|
19
|
+
- refactor(html-spec)!: migrate spec-generator into html-spec and run via native TypeScript ([8f928cc](https://github.com/markuplint/markuplint/commit/8f928ccf17a959447f477eb4c3d0db13ab2ba730))
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
- **html-spec:** add conditional attribute constraints for script element ([9abbf95](https://github.com/markuplint/markuplint/commit/9abbf95c43d8bcedbfa19d0c09223a322967bc3b))
|
|
24
|
+
- **html-spec:** add conditional value types for input element ([#3598](https://github.com/markuplint/markuplint/issues/3598)) ([290be1c](https://github.com/markuplint/markuplint/commit/290be1cde53165f1f6165731bf2ec184b0c46b54))
|
|
25
|
+
- **html-spec:** add forbiddenAncestors for main, header, footer, address ([e51b745](https://github.com/markuplint/markuplint/commit/e51b745c0fd7662946b267b67f94b1bfbf95b89c))
|
|
26
|
+
- **html-spec:** add loading attribute type for audio and video elements ([12a03f7](https://github.com/markuplint/markuplint/commit/12a03f7252bfb8bae2bd427dbb9a553e2038ecb3)), closes [#3542](https://github.com/markuplint/markuplint/issues/3542)
|
|
27
|
+
- **html-spec:** add speculationrules to script type attribute enum ([3568ee6](https://github.com/markuplint/markuplint/commit/3568ee6012b3f30e3f913f346e000519939c1448))
|
|
28
|
+
- **html-spec:** add touch event handler attributes (ontouchstart, etc.) ([9be2b57](https://github.com/markuplint/markuplint/commit/9be2b57ea39ec33c7d3f24bca530a40b6e4d7708))
|
|
29
|
+
- **html-spec:** add uniqueAttrs for track default attribute ([ccafb65](https://github.com/markuplint/markuplint/commit/ccafb65fbda86e42f509566eb95798cfac271c11))
|
|
30
|
+
- **html-spec:** split link[as] enum by rel condition ([#3189](https://github.com/markuplint/markuplint/issues/3189)) ([6aa1fe8](https://github.com/markuplint/markuplint/commit/6aa1fe896223a3b7437e38a3c2b5092edefcd240))
|
|
31
|
+
- **html-spec:** use #nonEmptyText for title and option elements ([ede5d4c](https://github.com/markuplint/markuplint/commit/ede5d4c87c72b7e2e95f17799f3632eb9108feef))
|
|
32
|
+
- **types:** add SRIHash type for integrity attribute validation ([7672999](https://github.com/markuplint/markuplint/commit/7672999a17f7d96dc286aabfcea5cc0861b73be5))
|
|
33
|
+
|
|
34
|
+
### BREAKING CHANGES
|
|
35
|
+
|
|
36
|
+
- @markuplint/spec-generator package is removed.
|
|
37
|
+
Its functionality is now internal to @markuplint/html-spec.
|
|
38
|
+
|
|
39
|
+
# [5.0.0-rc.1](https://github.com/markuplint/markuplint/compare/v5.0.0-rc.0...v5.0.0-rc.1) (2026-03-27)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @markuplint/html-spec
|
|
42
|
+
|
|
6
43
|
# [5.0.0-rc.0](https://github.com/markuplint/markuplint/compare/v5.0.0-alpha.3...v5.0.0-rc.0) (2026-03-12)
|
|
7
44
|
|
|
8
45
|
### Features
|
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ Core packages (Application Layer)
|
|
|
41
41
|
|
|
42
42
|
### Build System
|
|
43
43
|
|
|
44
|
-
- **`build.
|
|
44
|
+
- **`build.ts`** - Generation script that invokes `generator/` modules
|
|
45
45
|
- Fetches live data from MDN, W3C ARIA specs, Graphics ARIA, DPub ARIA, HTML-ARIA mappings, HTML Living Standard, SVG specs, and MathML specs
|
|
46
46
|
|
|
47
47
|
## Relationship to @markuplint/ml-spec
|
|
@@ -79,7 +79,7 @@ For detailed documentation, see:
|
|
|
79
79
|
|
|
80
80
|
- [Architecture](ARCHITECTURE.md) -- Package structure, data flow, and integration points
|
|
81
81
|
- [Element Specification Format](docs/element-spec-format.md) -- JSON spec file reference, content models, ARIA integration
|
|
82
|
-
- [Build Pipeline](docs/build-pipeline.md) -- Build process, external data sources,
|
|
82
|
+
- [Build Pipeline](docs/build-pipeline.md) -- Build process, external data sources, generator modules
|
|
83
83
|
- [Maintenance Guide](docs/maintenance.md) -- Common recipes, testing, troubleshooting
|
|
84
84
|
|
|
85
85
|
## License
|
package/SKILL.md
CHANGED
|
@@ -46,7 +46,7 @@ and review what has changed.
|
|
|
46
46
|
yarn up:gen
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
This runs
|
|
49
|
+
This runs the generator scripts in `generator/`, which scrape live MDN data and merge it with
|
|
50
50
|
the manual spec files in `src/`. The result is written to `index.json`.
|
|
51
51
|
|
|
52
52
|
### Step 2: Review the diff
|
|
@@ -191,9 +191,9 @@ Mark an element as obsolete. Follow recipe #8 in `docs/maintenance.md`.
|
|
|
191
191
|
|
|
192
192
|
There are two approaches:
|
|
193
193
|
|
|
194
|
-
- **Via
|
|
194
|
+
- **Via generator's hardcoded list** (preferred for standard obsolete elements):
|
|
195
195
|
Add the element name to the `obsoleteList` array in
|
|
196
|
-
`packages/@markuplint/spec
|
|
196
|
+
`packages/@markuplint/html-spec/generator/html-elements.ts`
|
|
197
197
|
- **Via manual spec file**: Set `"obsolete": true` in the element's
|
|
198
198
|
`src/spec.<element>.jsonc`
|
|
199
199
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## 概要
|
|
6
6
|
|
|
7
|
-
`@markuplint/html-spec` は
|
|
7
|
+
`@markuplint/html-spec` は `generator/` のスクリプトを使用して、単一の統合 `index.json` ファイルを生成します。ビルドプロセス:
|
|
8
8
|
|
|
9
9
|
1. `src/` から 208 個の要素 JSON 仕様ファイル(HTML、SVG、MathML)と 2 個の共通定義ファイルを読み込む
|
|
10
10
|
2. MDN Web Docs、W3C ARIA 仕様、HTML Living Standard から外部データをフェッチ
|
|
@@ -24,8 +24,8 @@ flowchart TD
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
subgraph build ["ビルド"]
|
|
27
|
-
buildScript["build.
|
|
28
|
-
specGen["
|
|
27
|
+
buildScript["build.ts"]
|
|
28
|
+
specGen["generator/"]
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
subgraph external ["外部データソース"]
|
|
@@ -54,30 +54,11 @@ flowchart TD
|
|
|
54
54
|
|
|
55
55
|
## ビルドエントリポイント
|
|
56
56
|
|
|
57
|
-
`build.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
import path from 'node:path';
|
|
61
|
-
import { main } from '@markuplint/spec-generator';
|
|
62
|
-
|
|
63
|
-
await main({
|
|
64
|
-
outputFilePath: path.resolve(import.meta.dirname, 'index.json'),
|
|
65
|
-
htmlFilePattern: path.resolve(import.meta.dirname, 'src', 'spec.*.jsonc'),
|
|
66
|
-
commonAttrsFilePath: path.resolve(import.meta.dirname, 'src', 'spec-common.attributes.jsonc'),
|
|
67
|
-
commonContentsFilePath: path.resolve(import.meta.dirname, 'src', 'spec-common.contents.jsonc'),
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
| オプション | 説明 |
|
|
72
|
-
| ------------------------ | ------------------------------------------ |
|
|
73
|
-
| `outputFilePath` | `index.json` の出力先パス |
|
|
74
|
-
| `htmlFilePattern` | 要素仕様ファイルにマッチする glob パターン |
|
|
75
|
-
| `commonAttrsFilePath` | グローバル属性定義ファイルのパス |
|
|
76
|
-
| `commonContentsFilePath` | コンテンツモデルマクロ定義ファイルのパス |
|
|
57
|
+
`build.ts` が `generator/` の `main()` を呼び出します。
|
|
77
58
|
|
|
78
59
|
## 外部データソース
|
|
79
60
|
|
|
80
|
-
|
|
61
|
+
generator はビルド時に以下の外部ソースからデータをフェッチします。
|
|
81
62
|
|
|
82
63
|
| ソース | 提供データ |
|
|
83
64
|
| ----------------------------------------- | ------------------------------------------------------------ |
|
|
@@ -90,7 +71,7 @@ spec-generator はビルド時に以下の外部ソースからデータをフ
|
|
|
90
71
|
| Graphics ARIA | グラフィックス固有 ARIA ロール |
|
|
91
72
|
| HTML-ARIA(`w3.org/TR/html-aria/`) | HTML 属性から ARIA プロパティへのマッピング |
|
|
92
73
|
|
|
93
|
-
|
|
74
|
+
generator の内部アーキテクチャ(スクレイピング、キャッシュ、モジュール構成)の詳細は `generator/` ディレクトリを参照してください。
|
|
94
75
|
|
|
95
76
|
## データ優先順位ルール
|
|
96
77
|
|
package/docs/build-pipeline.md
CHANGED
|
@@ -4,7 +4,7 @@ This document describes how `index.json` is generated from the source files and
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
The `@markuplint/html-spec` package uses
|
|
7
|
+
The `@markuplint/html-spec` package uses `generator/` scripts to produce a single consolidated `index.json` file. The build process:
|
|
8
8
|
|
|
9
9
|
1. Reads 208 per-element JSON spec files (HTML, SVG, MathML) and 2 common definition files from `src/`
|
|
10
10
|
2. Fetches external data from MDN Web Docs, W3C ARIA specifications, and the HTML Living Standard
|
|
@@ -24,8 +24,8 @@ flowchart TD
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
subgraph build ["Build"]
|
|
27
|
-
buildScript["build.
|
|
28
|
-
specGen["
|
|
27
|
+
buildScript["build.ts"]
|
|
28
|
+
specGen["generator/"]
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
subgraph external ["External Data Sources"]
|
|
@@ -54,30 +54,11 @@ flowchart TD
|
|
|
54
54
|
|
|
55
55
|
## Build Entry Point
|
|
56
56
|
|
|
57
|
-
The build is triggered via `build.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
import path from 'node:path';
|
|
61
|
-
import { main } from '@markuplint/spec-generator';
|
|
62
|
-
|
|
63
|
-
await main({
|
|
64
|
-
outputFilePath: path.resolve(import.meta.dirname, 'index.json'),
|
|
65
|
-
htmlFilePattern: path.resolve(import.meta.dirname, 'src', 'spec.*.jsonc'),
|
|
66
|
-
commonAttrsFilePath: path.resolve(import.meta.dirname, 'src', 'spec-common.attributes.jsonc'),
|
|
67
|
-
commonContentsFilePath: path.resolve(import.meta.dirname, 'src', 'spec-common.contents.jsonc'),
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
| Option | Description |
|
|
72
|
-
| ------------------------ | ------------------------------------------------ |
|
|
73
|
-
| `outputFilePath` | Absolute path where `index.json` will be written |
|
|
74
|
-
| `htmlFilePattern` | Glob pattern matching per-element spec files |
|
|
75
|
-
| `commonAttrsFilePath` | Path to global attribute definitions |
|
|
76
|
-
| `commonContentsFilePath` | Path to content model macro definitions |
|
|
57
|
+
The build is triggered via `build.ts`, which calls the `main()` function from `generator/index.ts`.
|
|
77
58
|
|
|
78
59
|
## External Data Sources
|
|
79
60
|
|
|
80
|
-
The
|
|
61
|
+
The generator fetches live data from the following sources during the build:
|
|
81
62
|
|
|
82
63
|
| Source | Data Provided |
|
|
83
64
|
| ---------------------------------------- | --------------------------------------------------------------------------------- |
|
|
@@ -90,7 +71,7 @@ The spec-generator fetches live data from the following sources during the build
|
|
|
90
71
|
| Graphics ARIA | Graphics-specific ARIA roles |
|
|
91
72
|
| HTML-ARIA (`w3.org/TR/html-aria/`) | HTML attribute to ARIA property mappings |
|
|
92
73
|
|
|
93
|
-
For details on the
|
|
74
|
+
For details on the generator's internal architecture (scraping, caching, module structure), see the `generator/` directory.
|
|
94
75
|
|
|
95
76
|
## Data Precedence Rules
|
|
96
77
|
|
package/docs/maintenance.ja.md
CHANGED
|
@@ -59,6 +59,57 @@
|
|
|
59
59
|
4. `yarn workspace @markuplint/html-spec run gen` を実行
|
|
60
60
|
5. `index.json` で属性が正しいメタデータとともに表示されることを確認
|
|
61
61
|
|
|
62
|
+
### 2b. 条件付き値型(`ConditionalAttributeType[]`)の使用
|
|
63
|
+
|
|
64
|
+
属性の期待する値型が(属性の存在可否ではなく)**別の属性の値に依存する**場合、`type` フィールドに単一の `AttributeType` ではなく `ConditionalAttributeType[]` を使用します。
|
|
65
|
+
|
|
66
|
+
これは属性レベルの `condition` フィールド(レシピ2)とは異なります。`condition` は**属性自体が有効かどうか**を制御しますが、条件付き値型は**どの値が有効か**を要素の状態に応じて制御します。
|
|
67
|
+
|
|
68
|
+
**例** -- `input[value]` の型は `type` 属性に依存:
|
|
69
|
+
|
|
70
|
+
```jsonc
|
|
71
|
+
"value": {
|
|
72
|
+
"type": [
|
|
73
|
+
{ "condition": "[type='color' i]", "type": "SimpleColor" },
|
|
74
|
+
{ "condition": "[type='url' i]", "type": "URL" },
|
|
75
|
+
{ "condition": "[type='email' i]", "type": "Email" },
|
|
76
|
+
{ "condition": ["[type='number' i]", "[type='range' i]"], "type": { "type": "float" } },
|
|
77
|
+
{ "condition": "[type='date' i]", "type": "DateString" }
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**ランタイムの動作:**
|
|
83
|
+
|
|
84
|
+
1. `@markuplint/rules` の `isValidAttr()` が `ConditionalAttributeType[]` を検出
|
|
85
|
+
2. 各エントリの `condition`(CSSセレクタまたはセレクタの配列)を要素に対してマッチ
|
|
86
|
+
3. 最初にマッチしたエントリの `type` でバリデーションを実行
|
|
87
|
+
4. どの条件にもマッチしない場合は `Any`(制約なし)にフォールバック
|
|
88
|
+
|
|
89
|
+
**使用タイミング:** HTML仕様が「属性 Y が Z のとき、値は X でなければならない」と規定している場合 — 例: `type=color` のとき `<input value>` は valid simple color でなければならない。
|
|
90
|
+
|
|
91
|
+
**例2** -- `link[as]` の有効な値は `rel` に依存:
|
|
92
|
+
|
|
93
|
+
```jsonc
|
|
94
|
+
"as": {
|
|
95
|
+
"type": [
|
|
96
|
+
{
|
|
97
|
+
"condition": "[rel~='preload' i]",
|
|
98
|
+
"type": { "enum": ["fetch", "font", "image", "script", "style", "track"] }
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"condition": "[rel~='modulepreload' i]",
|
|
102
|
+
"type": { "enum": ["audioworklet", "json", "paintworklet", "script", "serviceworker", "sharedworker", "style", "worker"] }
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"condition": ["[rel~='preload' i]", "[rel~='modulepreload' i]"]
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
注: 属性レベルの `condition` は `as` 属性自体が有効かどうか(`rel=preload` または `rel=modulepreload` の場合のみ)を制御し、型レベルの `ConditionalAttributeType[]` は各 `rel` 値に対してどの enum 値が有効かを制御します。
|
|
110
|
+
|
|
111
|
+
**参照:** `@markuplint/ml-spec` ドキュメント(`docs/type-definitions.md`)の `ConditionalAttributeType` セクション。
|
|
112
|
+
|
|
62
113
|
### 3. SVG要素の追加
|
|
63
114
|
|
|
64
115
|
1. `src/spec.svg_<localname>.jsonc` を作成(例: `src/spec.svg_circle.jsonc`)
|
|
@@ -216,7 +267,7 @@ description の表現変更などの表面的な変更は、更新された `ind
|
|
|
216
267
|
|
|
217
268
|
要素を非推奨にする方法は2つある:
|
|
218
269
|
|
|
219
|
-
- **ハードコードリスト経由**: `packages/@markuplint/spec
|
|
270
|
+
- **ハードコードリスト経由**: `packages/@markuplint/html-spec/generator/html-elements.ts` の `obsoleteList` 配列に要素名を追加
|
|
220
271
|
- **手動仕様経由**: 要素の仕様ファイルに `"obsolete": true` を設定
|
|
221
272
|
|
|
222
273
|
非推奨要素には自動的に以下が設定される:
|
|
@@ -285,12 +336,11 @@ yarn workspace @markuplint/html-spec run test
|
|
|
285
336
|
|
|
286
337
|
### 開発依存
|
|
287
338
|
|
|
288
|
-
- **`@markuplint/spec-generator`**: ビルドツール。外部データのスクレイピングとマージを担当
|
|
289
339
|
- **`@markuplint/test-tools`**: テストユーティリティ。`glob` 関数などを提供
|
|
290
340
|
|
|
291
341
|
### 依存関係更新時の注意
|
|
292
342
|
|
|
293
|
-
1.
|
|
343
|
+
1. `generator/` 更新後は必ず再生成を実行
|
|
294
344
|
2. `index.json` の差分を注意深くレビュー(外部データソースの変更により予期しない差分が出る場合がある)
|
|
295
345
|
3. テストを実行してスキーマ検証が通ることを確認
|
|
296
346
|
4. `@markuplint/ml-spec` のスキーマが変更された場合、ソースJSONファイルの更新が必要になることがある
|
package/docs/maintenance.md
CHANGED
|
@@ -15,14 +15,14 @@ This is a practical operations and maintenance guide for contributors working on
|
|
|
15
15
|
|
|
16
16
|
The generation process (`gen`) performs two steps in sequence via `npm-run-all`:
|
|
17
17
|
|
|
18
|
-
1. **`gen:build`** -- Executes `build.
|
|
19
|
-
|
|
18
|
+
1. **`gen:build`** -- Executes `build.ts`, which calls the `main()` function from
|
|
19
|
+
`generator/`. This reads all `src/spec.*.jsonc` files, merges them
|
|
20
20
|
with scraped MDN data and the common attribute/content files, appends obsolete
|
|
21
21
|
element stubs, and writes the consolidated output to `index.json`.
|
|
22
22
|
2. **`gen:prettier`** -- Runs Prettier on `index.json` to ensure consistent formatting
|
|
23
23
|
across regenerations.
|
|
24
24
|
|
|
25
|
-
The build is network-dependent because
|
|
25
|
+
The build is network-dependent because `generator/` fetches live data
|
|
26
26
|
from MDN for each element (descriptions, compatibility flags, attribute metadata).
|
|
27
27
|
Expect the build to take several minutes on a clean run.
|
|
28
28
|
|
|
@@ -77,6 +77,57 @@ will cause the element to be silently excluded from the build output.
|
|
|
77
77
|
4. Run `yarn workspace @markuplint/html-spec run gen`
|
|
78
78
|
5. Check `index.json` to confirm the attribute appears with correct metadata
|
|
79
79
|
|
|
80
|
+
### 2b. Using Conditional Value Types (`ConditionalAttributeType[]`)
|
|
81
|
+
|
|
82
|
+
When an attribute's expected value type depends on **another attribute's value** (not just its existence), use `ConditionalAttributeType[]` as the `type` field instead of a single `AttributeType`.
|
|
83
|
+
|
|
84
|
+
This is different from the attribute-level `condition` field (Recipe 2), which controls **whether the attribute is valid at all**. Conditional value types control **what values are valid** depending on element state.
|
|
85
|
+
|
|
86
|
+
**Example** -- `input[value]` type depends on the `type` attribute:
|
|
87
|
+
|
|
88
|
+
```jsonc
|
|
89
|
+
"value": {
|
|
90
|
+
"type": [
|
|
91
|
+
{ "condition": "[type='color' i]", "type": "SimpleColor" },
|
|
92
|
+
{ "condition": "[type='url' i]", "type": "URL" },
|
|
93
|
+
{ "condition": "[type='email' i]", "type": "Email" },
|
|
94
|
+
{ "condition": ["[type='number' i]", "[type='range' i]"], "type": { "type": "float" } },
|
|
95
|
+
{ "condition": "[type='date' i]", "type": "DateString" }
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**How it works at runtime:**
|
|
101
|
+
|
|
102
|
+
1. `isValidAttr()` in `@markuplint/rules` detects `ConditionalAttributeType[]`
|
|
103
|
+
2. Each entry's `condition` (a CSS selector or array of selectors) is matched against the element
|
|
104
|
+
3. The first matching entry's `type` is used for validation
|
|
105
|
+
4. If no condition matches, the value falls back to `Any` (no constraint)
|
|
106
|
+
|
|
107
|
+
**When to use:** When the HTML spec says "the value must be X when attribute Y is Z" — e.g., `<input value>` must be a valid simple color when `type=color`.
|
|
108
|
+
|
|
109
|
+
**Example 2** -- `link[as]` valid values depend on `rel`:
|
|
110
|
+
|
|
111
|
+
```jsonc
|
|
112
|
+
"as": {
|
|
113
|
+
"type": [
|
|
114
|
+
{
|
|
115
|
+
"condition": "[rel~='preload' i]",
|
|
116
|
+
"type": { "enum": ["fetch", "font", "image", "script", "style", "track"] }
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"condition": "[rel~='modulepreload' i]",
|
|
120
|
+
"type": { "enum": ["audioworklet", "json", "paintworklet", "script", "serviceworker", "sharedworker", "style", "worker"] }
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"condition": ["[rel~='preload' i]", "[rel~='modulepreload' i]"]
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Note: The attribute-level `condition` controls whether the `as` attribute is valid at all (only with `rel=preload` or `rel=modulepreload`), while the type-level `ConditionalAttributeType[]` controls which enum values are valid for each `rel` value.
|
|
128
|
+
|
|
129
|
+
**See also:** `ConditionalAttributeType` in `@markuplint/ml-spec` docs (`docs/type-definitions.md`).
|
|
130
|
+
|
|
80
131
|
### 3. Adding an SVG Element
|
|
81
132
|
|
|
82
133
|
1. Create `src/spec.svg_<localname>.jsonc` (e.g., `src/spec.svg_circle.jsonc`)
|
|
@@ -275,7 +326,7 @@ what has changed in web standards and ensuring the spec data remains accurate.
|
|
|
275
326
|
|
|
276
327
|
Elements can be marked obsolete in two ways:
|
|
277
328
|
|
|
278
|
-
- **Via the hardcoded list**: Add the element name to the `obsoleteList` array in `packages/@markuplint/spec
|
|
329
|
+
- **Via the hardcoded list**: Add the element name to the `obsoleteList` array in `packages/@markuplint/html-spec/generator/html-elements.ts`
|
|
279
330
|
- **Via manual spec**: Set `"obsolete": true` in the element's spec file
|
|
280
331
|
|
|
281
332
|
Obsolete elements automatically get:
|
|
@@ -358,15 +409,11 @@ grep -A5 '"accept"' index.json
|
|
|
358
409
|
|
|
359
410
|
### Dev Dependencies
|
|
360
411
|
|
|
361
|
-
- **`@markuplint/spec-generator`**: The build tool. Updates may change:
|
|
362
|
-
- How MDN pages are scraped (if MDN layout changes)
|
|
363
|
-
- Which ARIA spec versions are fetched
|
|
364
|
-
- The output format of `index.json`
|
|
365
412
|
- **`@markuplint/test-tools`**: Test utilities. Updates are generally safe.
|
|
366
413
|
|
|
367
414
|
### When Updating Dependencies
|
|
368
415
|
|
|
369
|
-
1. Always regenerate after updating
|
|
416
|
+
1. Always regenerate after updating `generator/`: `yarn up:gen`
|
|
370
417
|
2. Review `index.json` diff carefully for unexpected changes
|
|
371
418
|
3. Run tests to ensure schema validation passes
|
|
372
419
|
|
|
@@ -380,7 +427,7 @@ grep -A5 '"accept"' index.json
|
|
|
380
427
|
|
|
381
428
|
- Check network connectivity
|
|
382
429
|
- Failed fetches are cached as empty strings; the build will continue but affected elements will have missing metadata
|
|
383
|
-
- If MDN page structure changed,
|
|
430
|
+
- If MDN page structure changed, `generator/` scraping selectors may need updating
|
|
384
431
|
|
|
385
432
|
### Schema Validation Error
|
|
386
433
|
|