|
2 | 2 |
|
3 | 3 | [](https://ci.appveyor.com/project/zhengbli/tsjs-lib-generator/branch/master)
|
4 | 4 |
|
5 |
| -This tool is used to generate `dom.generated.d.ts` and `webworker.generated.d.ts` for TypeScript, and `domWeb.js` and `domWindows.js` for Visual Studio JavaScript language service. The input file is the XML spec file generated by the Microsoft Edge browser. |
| 5 | +This tool is used to generate `dom.generated.d.ts` and `webworker.generated.d.ts` for TypeScript, and `domWeb.js` and `domWindows.js` for Visual Studio JavaScript language service. |
| 6 | +The input file is the XML spec file generated by the Microsoft Edge browser. |
6 | 7 |
|
7 |
| -## Build Instruction |
8 |
| -To build the tool, simply clone the repo, and run `build.cmd` (Windows) or `build.sh` (OS X/Unix) in command line. If it runs successfully, the output files will be generated under the `generated` folder. |
| 8 | +## Build Instructions |
9 | 9 |
|
10 |
| -Note: for OS X/ Unix users, [Mono 4.2](http://www.mono-project.com/download/alpha/) is required. |
| 10 | +To build the tool, simply clone this repo, and run `build.cmd` (Windows) or `build.sh` (OS X/Unix) on the command line. |
| 11 | +If it runs successfully, the output files will be generated under the `generated` folder. |
11 | 12 |
|
12 |
| -## Contribution Guide |
13 |
| -The `dom.generated.d.ts` and `webworker.generated.d.ts` files in the TypeScript repo are used as baselines. |
14 |
| -For each pull request, we will run the script and compare the generated files with the baseline files. |
15 |
| -In order to make the tests pass, please update the baseline as well in any pull requests. |
| 13 | +Note: for OS X and Unix users, [Mono 4.2](http://www.mono-project.com/download/alpha/) is required. |
16 | 14 |
|
17 |
| -For common changes, it is sufficient to change the json files. |
18 |
| -There are three json files that are used to alter the file generation: `addedTypes.json`, `overridingTypes.json` and `removedTypes.json`. |
19 |
| -The format of each file can be inferred from their existing content. |
| 15 | +## Contribution Guidelines |
| 16 | + |
| 17 | +The `dom.generated.d.ts` and `webworker.generated.d.ts` files in the TypeScript repo are used as baselines. |
| 18 | +For each pull request, we will run the script and compare the generated files with the baseline files. |
| 19 | +In order to make the tests pass, please update the baseline as well in any pull requests. |
| 20 | + |
| 21 | +For common changes, it is sufficient to change the json files. |
| 22 | +There are three json files that are used to alter the file generation: `addedTypes.json`, `overridingTypes.json`, and `removedTypes.json`. |
| 23 | +The format of each file can be inferred from their existing content. |
20 | 24 |
|
21 | 25 | The common steps to send a pull request are:
|
22 |
| - 0. Open or refer to an issue in the [TypeScript repo](https://github.com/Microsoft/TypeScript). |
23 |
| - 1. Add missing elements to `inputfiles/addedTypes.json`, overriding elements to `inputfiles/overridingTypes.json`, or elements to remove to `inputfiles/removedTypes.json`. |
24 |
| - 2. Run the script locally to obtain new `dom.generated.d.ts` and `webworker.generated.d.ts`. |
25 |
| - 3. Update the files in the `baselines` folder using the newly generated files. |
| 26 | + |
| 27 | +0. Open or refer to an issue in the [TypeScript repo](https://github.com/Microsoft/TypeScript). |
| 28 | +1. Add missing elements to `inputfiles/addedTypes.json`, overriding elements to `inputfiles/overridingTypes.json`, or elements to remove to `inputfiles/removedTypes.json`. |
| 29 | +2. Run the script locally to obtain new `dom.generated.d.ts` and `webworker.generated.d.ts`. |
| 30 | +3. Update the files in the `baselines` folder using the newly generated files. |
26 | 31 |
|
27 | 32 | ## Code Structure
|
28 |
| -- `Shared.fs`: handles the parsing from XML spec file, and stores the common data structures for later use; |
29 |
| -- `TS.fs`: handles the emitting of the `lib.d.ts` file; |
30 |
| -- `JS.fs`: handles the emitting of the `domWeb.js` and `domWindows.js` |
31 | 33 |
|
32 |
| -## Input Files: |
33 |
| -- `browser.webidl.xml`: the XML spec file generated by Microsoft Edge (due to the different updating schedules between Edge and TypeScript, this may **not** be the most up-to-date version of the spec.); |
34 |
| -- `webworker.webidl.xml`: contains additional types for webworker. |
| 34 | +- `Shared.fs`: handles the parsing from XML spec file, and stores the common data structures for later use. |
| 35 | +- `TS.fs`: handles the emitting of the `lib.d.ts` file. |
| 36 | +- `JS.fs`: handles the emitting of the `domWeb.js` and `domWindows.js`. |
| 37 | + |
| 38 | +## Input Files |
| 39 | + |
| 40 | +- `browser.webidl.xml`: an XML spec file generated by Microsoft Edge. **Do not edit this file**. |
| 41 | + - Due to the different update schedules between Edge and TypeScript, this may not be the most up-to-date version of the spec. |
| 42 | +- `webworker.webidl.xml`: an XML spec file generated by Microsoft Edge that contains types for Web Workers. **Do not edit this file**. |
35 | 43 | - `addedTypes.json`: types that should exist in either browser or webworker but are missing from the Edge spec. The type can be `property`, `method`, `interface`, `constructor`, or `indexer`.
|
36 | 44 | - `overridingTypes.json`: types that are defined in the spec file but has a better or more up-to-date definitions in the json files.
|
37 | 45 | - `removedTypes.json`: types that are defined in the spec file but should be removed.
|
38 |
| -- `comments.json`: comment strings to be embedded in the generated .js files |
39 |
| -- `jsTemplate.js`: the initial templates for `domWeb.js` and `domWindows.js`, which contains the necessary helper functions; |
| 46 | +- `comments.json`: comment strings to be embedded in the generated .js files. |
| 47 | +- `jsTemplate.js`: the initial templates for `domWeb.js` and `domWindows.js`, which contains the necessary helper functions. |
40 | 48 | - `sample.json`: sample json file used to tell F# json type provider that structure of the json files. The content of it is not used anywhere.
|
0 commit comments