forked from angular/angular
-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgenerate_element_api_json.ts
47 lines (41 loc) · 1.22 KB
/
generate_element_api_json.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {DocEntry, EntryType} from '@angular/compiler-cli';
import {readFileSync, writeFileSync} from 'fs';
import {basename} from 'path';
function main() {
const [paramFilePath] = process.argv.slice(2);
const rawParamLines = readFileSync(paramFilePath, {encoding: 'utf8'}).split('\n');
const [srcs, outputFileExecRootRelativePath] = rawParamLines;
const entries: DocEntry[] = srcs.split(',').map((sourceFilePath) => {
const fileContent = readFileSync(sourceFilePath, {encoding: 'utf8'});
return {
name: basename(sourceFilePath, '.md'),
source: {
filePath: '/' + sourceFilePath,
startLine: 0,
endLine: 0,
},
entryType: EntryType.Element,
description: fileContent,
rawComment: fileContent,
jsdocTags: [],
};
});
writeFileSync(
outputFileExecRootRelativePath,
JSON.stringify({
moduleName: '@angular/core',
normalizedModuleName: 'angular_core',
moduleLabel: 'core',
entries,
}),
{encoding: 'utf8'},
);
}
main();