-
Notifications
You must be signed in to change notification settings - Fork 353
Expand file tree
/
Copy pathdocumentReadme.ts
More file actions
47 lines (41 loc) · 1.72 KB
/
documentReadme.ts
File metadata and controls
47 lines (41 loc) · 1.72 KB
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
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
import execa from 'execa';
import { promises as fs } from 'fs';
import { marked } from 'marked';
import strings from '../../package.nls.json';
import { getPreferredOrDebugType } from '../common/contributionUtils';
import { debuggers, DescribedAttribute } from './generate-contributions.js';
(async () => {
let out = `# Options\n\n`;
for (const dbg of debuggers) {
out += `### ${getPreferredOrDebugType(dbg.type)}: ${dbg.request}\n\n`;
out += `<details>`;
const entries = Object.entries(dbg.configurationAttributes).sort(([a], [b]) =>
a.localeCompare(b)
);
for (const [key, value] of entries as Iterable<[string, DescribedAttribute<unknown>]>) {
const descriptionKeyRaw = 'markdownDescription' in value
? value.markdownDescription
: value.description;
if (!descriptionKeyRaw) {
continue;
}
const descriptionKey = descriptionKeyRaw.slice(1, -1);
const description = strings[descriptionKey].replace(/\n/g, '<br>');
if (!description) {
continue;
}
const defaultValue = (dbg.defaults as unknown as { [key: string]: unknown })[key];
const docDefault = value.docDefault ?? JSON.stringify(defaultValue, null, 2) ?? 'undefined';
out += `<h4>${key}</h4>`;
out += `${marked(description)}`;
out += `<h5>Default value:</h4>`;
out += `<pre><code>${docDefault}</pre></code>`;
}
out += `</details>\n\n`;
}
await fs.writeFile('OPTIONS.md', out);
await execa('node_modules/.bin/dprint', ['fmt', 'OPTIONS.md']);
})().catch(console.error);