Skip to content

Commit 2ffb89c

Browse files
authored
Enhance README with KDL patch guidelines
Added detailed documentation for KDL patches and editing policy.
1 parent 7179603 commit 2ffb89c

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

inputfiles/README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,62 @@ Some files in this directory are generated. Please do not edit them.
44
This specifically includes:
55

66
* `idl/*`
7-
* `mdn/*`
87

98
Feel free to send a pull request with changes to any other files.
9+
Note It is recommended to add your patch use KDL format, continue reading to find out more.
10+
11+
## Documentation for `patches/` KDL Folder
12+
13+
The `patches/` directory only contains `.kdl` files that specify modifications ("patches") to the default Web IDL or related specifications, using the [KDL format](https://kdl.dev/).
14+
These modifications are integrated into the build system (see [`src/build/patches.ts`](../src/build/patches.ts) for implementation details).
15+
16+
### Purpose
17+
18+
- Fix errors or omissions in upstream IDL data.
19+
- Add or override interfaces, mixins, and enums.
20+
- Apply project-specific features or changes.
21+
22+
### Editing Policy
23+
24+
It is **recommended** to document and comment your patch files and their intent.
25+
This helps keep the integration clear and maintainable.
26+
27+
### Structure & Parsing
28+
29+
- All `.kdl` files in this folder are read and parsed at build time.
30+
- Their structure typically mirrors major Web IDL concepts:
31+
- `enum`
32+
- `interface`
33+
- `interface-mixin`
34+
- Members like `event`, `property`, and `method`.
35+
36+
#### Example Patch File (`patches/my-patch.kdl`)
37+
```kdl
38+
// Add a readonly boolean property to Navigator
39+
interface "Navigator" {
40+
property "experimentalField" type="boolean" optional=false
41+
}
42+
43+
// Add a new value to an enum
44+
enum "MyEnum" {
45+
ValueA
46+
ValueB
47+
}
48+
```
49+
50+
### How It Works
51+
52+
The builder (see `src/build/patches.ts`):
53+
54+
- Locates all KDL files in the `patches/` directory.
55+
- Parses and type-checks them.
56+
- Merges their contents and applies structural transformations over the main IDL dataset.
57+
58+
See the source or comments in `patches.ts` for precise KDL syntax and advanced features.
59+
60+
### Notes
61+
62+
- You can split patches into multiple `.kdl` files if desired.
63+
- All the data in the json and jsonc files will be eventually transformed to KDL, so if possible submit patches to KDL.
64+
- When in doubt, consult `/src/build/patches.ts` for details on supported KDL structure and merging logic.
65+
- If there is a feature that is missing from the KDL parser, feel free to implement it yourself or ping @bashamega to help implement that feature in [this issue](https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/2053), or just add it to the jsonc files.

0 commit comments

Comments
 (0)