@typespec/tspd 0.70.0-dev.2 → 0.70.0
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/dist/src/cli.js +85 -103
- package/dist/src/gen-extern-signatures/components/decorator-signature-tests.d.ts +8 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-tests.d.ts.map +1 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-tests.js +16 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-tests.jsx +12 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-tests.jsx.map +1 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-type.d.ts +16 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-type.d.ts.map +1 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-type.js +404 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-type.jsx +316 -0
- package/dist/src/gen-extern-signatures/components/decorator-signature-type.jsx.map +1 -0
- package/dist/src/gen-extern-signatures/components/decorators-signatures.d.ts +12 -0
- package/dist/src/gen-extern-signatures/components/decorators-signatures.d.ts.map +1 -0
- package/dist/src/gen-extern-signatures/components/decorators-signatures.js +107 -0
- package/dist/src/gen-extern-signatures/components/decorators-signatures.jsx +60 -0
- package/dist/src/gen-extern-signatures/components/decorators-signatures.jsx.map +1 -0
- package/dist/src/gen-extern-signatures/components/dollar-decorators-type.d.ts +10 -0
- package/dist/src/gen-extern-signatures/components/dollar-decorators-type.d.ts.map +1 -0
- package/dist/src/gen-extern-signatures/components/dollar-decorators-type.js +39 -0
- package/dist/src/gen-extern-signatures/components/dollar-decorators-type.jsx +18 -0
- package/dist/src/gen-extern-signatures/components/dollar-decorators-type.jsx.map +1 -0
- package/dist/src/gen-extern-signatures/components/tspd-context.d.ts +10 -0
- package/dist/src/gen-extern-signatures/components/tspd-context.d.ts.map +1 -0
- package/dist/src/gen-extern-signatures/components/tspd-context.js +22 -0
- package/dist/src/gen-extern-signatures/components/tspd-context.js.map +1 -0
- package/dist/src/gen-extern-signatures/doc-builder.js +10 -12
- package/dist/src/gen-extern-signatures/external-packages/compiler.d.ts +17 -0
- package/dist/src/gen-extern-signatures/external-packages/compiler.d.ts.map +1 -0
- package/dist/src/gen-extern-signatures/external-packages/compiler.js +10 -0
- package/dist/src/gen-extern-signatures/external-packages/compiler.js.map +1 -0
- package/dist/src/gen-extern-signatures/gen-extern-signatures.d.ts.map +1 -1
- package/dist/src/gen-extern-signatures/gen-extern-signatures.js +109 -102
- package/dist/src/gen-extern-signatures/gen-extern-signatures.js.map +1 -1
- package/dist/src/gen-extern-signatures/types.js +1 -2
- package/dist/src/ref-doc/api-docs.js +56 -56
- package/dist/src/ref-doc/emitters/docusaurus.js +156 -209
- package/dist/src/ref-doc/emitters/markdown.js +278 -327
- package/dist/src/ref-doc/emitters/starlight.js +154 -190
- package/dist/src/ref-doc/experimental.js +48 -45
- package/dist/src/ref-doc/extractor.js +486 -449
- package/dist/src/ref-doc/index.js +1 -2
- package/dist/src/ref-doc/lib.js +29 -26
- package/dist/src/ref-doc/types.js +1 -2
- package/dist/src/ref-doc/utils/markdown.js +37 -44
- package/dist/src/ref-doc/utils/type-signature.js +89 -98
- package/package.json +12 -9
- package/dist/src/gen-extern-signatures/decorators-signatures.d.ts +0 -5
- package/dist/src/gen-extern-signatures/decorators-signatures.d.ts.map +0 -1
- package/dist/src/gen-extern-signatures/decorators-signatures.js +0 -338
- package/dist/src/gen-extern-signatures/decorators-signatures.js.map +0 -1
|
@@ -1,213 +1,177 @@
|
|
|
1
|
-
import { codeblock, inlinecode, renderMarkdowDoc, section
|
|
1
|
+
import { codeblock, inlinecode, renderMarkdowDoc, section } from "../utils/markdown.js";
|
|
2
2
|
import { MarkdownRenderer, groupByNamespace } from "./markdown.js";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Render doc to a markdown using docusaurus addons.
|
|
5
6
|
*/
|
|
6
7
|
export function renderToAstroStarlightMarkdown(refDoc) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const renderer = new StarlightRenderer(refDoc);
|
|
9
|
+
const files = {
|
|
10
|
+
"index.mdx": renderIndexFile(renderer, refDoc)
|
|
11
|
+
};
|
|
12
|
+
const decoratorFile = renderDecoratorFile(renderer, refDoc);
|
|
13
|
+
if (decoratorFile) {
|
|
14
|
+
files["decorators.md"] = decoratorFile;
|
|
15
|
+
}
|
|
16
|
+
const interfaceFile = renderInterfacesFile(renderer, refDoc);
|
|
17
|
+
if (interfaceFile) {
|
|
18
|
+
files["interfaces.md"] = interfaceFile;
|
|
19
|
+
}
|
|
20
|
+
const dataTypes = renderDataTypes(renderer, refDoc);
|
|
21
|
+
if (dataTypes) {
|
|
22
|
+
files["data-types.md"] = dataTypes;
|
|
23
|
+
}
|
|
24
|
+
const emitter = renderEmitter(renderer, refDoc);
|
|
25
|
+
if (emitter) {
|
|
26
|
+
files["emitter.md"] = emitter;
|
|
27
|
+
}
|
|
28
|
+
const linter = renderLinter(renderer, refDoc);
|
|
29
|
+
if (linter) {
|
|
30
|
+
files["linter.md"] = linter;
|
|
31
|
+
}
|
|
32
|
+
return files;
|
|
33
|
+
}
|
|
34
|
+
function renderIndexFile(renderer, refDoc) {
|
|
35
|
+
const content = ["---", `title: Overview`, `sidebar_position: 0`, "toc_min_heading_level: 2", "toc_max_heading_level: 3", "---", "import { Tabs, TabItem } from '@astrojs/starlight/components';", "", refDoc.description ?? [], renderer.install(refDoc), refDoc.emitter?.options ? section("Emitter usage", `[See documentation](./emitter.md)`) : [], groupByNamespace(refDoc.namespaces, namespace => {
|
|
36
|
+
const content = [];
|
|
37
|
+
if (namespace.decorators.length > 0) {
|
|
38
|
+
content.push(section("Decorators", renderer.toc(namespace.decorators)));
|
|
18
39
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
files["data-types.md"] = dataTypes;
|
|
40
|
+
if (namespace.interfaces.length > 0) {
|
|
41
|
+
content.push(section("Interfaces", renderer.toc(namespace.interfaces)));
|
|
22
42
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
files["emitter.md"] = emitter;
|
|
43
|
+
if (namespace.operations.length > 0) {
|
|
44
|
+
content.push(section("Operations", renderer.toc(namespace.operations)));
|
|
26
45
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
files["linter.md"] = linter;
|
|
46
|
+
if (namespace.models.length > 0) {
|
|
47
|
+
content.push(section("Models", renderer.toc(namespace.models)));
|
|
30
48
|
}
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const content = [
|
|
35
|
-
"---",
|
|
36
|
-
`title: Overview`,
|
|
37
|
-
`sidebar_position: 0`,
|
|
38
|
-
"toc_min_heading_level: 2",
|
|
39
|
-
"toc_max_heading_level: 3",
|
|
40
|
-
"---",
|
|
41
|
-
"import { Tabs, TabItem } from '@astrojs/starlight/components';",
|
|
42
|
-
"",
|
|
43
|
-
refDoc.description ?? [],
|
|
44
|
-
renderer.install(refDoc),
|
|
45
|
-
refDoc.emitter?.options ? section("Emitter usage", `[See documentation](./emitter.md)`) : [],
|
|
46
|
-
groupByNamespace(refDoc.namespaces, (namespace) => {
|
|
47
|
-
const content = [];
|
|
48
|
-
if (namespace.decorators.length > 0) {
|
|
49
|
-
content.push(section("Decorators", renderer.toc(namespace.decorators)));
|
|
50
|
-
}
|
|
51
|
-
if (namespace.interfaces.length > 0) {
|
|
52
|
-
content.push(section("Interfaces", renderer.toc(namespace.interfaces)));
|
|
53
|
-
}
|
|
54
|
-
if (namespace.operations.length > 0) {
|
|
55
|
-
content.push(section("Operations", renderer.toc(namespace.operations)));
|
|
56
|
-
}
|
|
57
|
-
if (namespace.models.length > 0) {
|
|
58
|
-
content.push(section("Models", renderer.toc(namespace.models)));
|
|
59
|
-
}
|
|
60
|
-
return content;
|
|
61
|
-
}),
|
|
62
|
-
];
|
|
63
|
-
return renderMarkdowDoc(content, 2);
|
|
49
|
+
return content;
|
|
50
|
+
})];
|
|
51
|
+
return renderMarkdowDoc(content, 2);
|
|
64
52
|
}
|
|
65
53
|
export function renderDecoratorFile(renderer, refDoc, options) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"toc_min_heading_level: 2",
|
|
74
|
-
"toc_max_heading_level: 3",
|
|
75
|
-
"---",
|
|
76
|
-
];
|
|
77
|
-
content.push(renderer.decoratorsSection(refDoc));
|
|
78
|
-
return renderMarkdowDoc(content, 2);
|
|
54
|
+
if (!refDoc.namespaces.some(x => x.decorators.length > 0)) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const title = options?.title ?? "Decorators";
|
|
58
|
+
const content = ["---", `title: "${title}"`, "toc_min_heading_level: 2", "toc_max_heading_level: 3", "---"];
|
|
59
|
+
content.push(renderer.decoratorsSection(refDoc));
|
|
60
|
+
return renderMarkdowDoc(content, 2);
|
|
79
61
|
}
|
|
80
62
|
function renderInterfacesFile(renderer, refDoc) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
63
|
+
if (!refDoc.namespaces.some(x => x.operations.length > 0 || x.interfaces.length > 0)) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const content = ["---", `title: "Interfaces and Operations"`, "---"];
|
|
67
|
+
content.push(groupByNamespace(refDoc.namespaces, namespace => {
|
|
68
|
+
if (namespace.operations.length === 0 && namespace.interfaces.length === 0) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const content = [];
|
|
72
|
+
for (const iface of namespace.interfaces) {
|
|
73
|
+
content.push(renderer.interface(iface), "");
|
|
74
|
+
}
|
|
75
|
+
for (const operation of namespace.operations) {
|
|
76
|
+
content.push(renderer.operation(operation), "");
|
|
77
|
+
}
|
|
78
|
+
return content;
|
|
79
|
+
}));
|
|
80
|
+
return renderMarkdowDoc(content, 2);
|
|
99
81
|
}
|
|
100
82
|
export function renderDataTypes(renderer, refDoc, options) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return content;
|
|
128
|
-
}));
|
|
129
|
-
return renderMarkdowDoc(content, 2);
|
|
83
|
+
if (!refDoc.namespaces.some(x => x.models.length > 0)) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const title = options?.title ?? "Data types";
|
|
87
|
+
const content = ["---", `title: "${title}"`, "---"];
|
|
88
|
+
content.push(groupByNamespace(refDoc.namespaces, namespace => {
|
|
89
|
+
const modelCount = namespace.models.length + namespace.enums.length + namespace.unions.length + namespace.scalars.length;
|
|
90
|
+
if (modelCount === 0) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const content = [];
|
|
94
|
+
for (const model of namespace.models) {
|
|
95
|
+
content.push(renderer.model(model), "");
|
|
96
|
+
}
|
|
97
|
+
for (const e of namespace.enums) {
|
|
98
|
+
content.push(renderer.enum(e), "");
|
|
99
|
+
}
|
|
100
|
+
for (const union of namespace.unions) {
|
|
101
|
+
content.push(renderer.union(union), "");
|
|
102
|
+
}
|
|
103
|
+
for (const scalar of namespace.scalars) {
|
|
104
|
+
content.push(renderer.scalar(scalar), "");
|
|
105
|
+
}
|
|
106
|
+
return content;
|
|
107
|
+
}));
|
|
108
|
+
return renderMarkdowDoc(content, 2);
|
|
130
109
|
}
|
|
131
110
|
function renderEmitter(renderer, refDoc) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
`title: "Emitter usage"`,
|
|
138
|
-
"---",
|
|
139
|
-
renderer.emitterUsage(refDoc),
|
|
140
|
-
];
|
|
141
|
-
return renderMarkdowDoc(content, 2);
|
|
111
|
+
if (refDoc.emitter?.options === undefined) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const content = ["---", `title: "Emitter usage"`, "---", renderer.emitterUsage(refDoc)];
|
|
115
|
+
return renderMarkdowDoc(content, 2);
|
|
142
116
|
}
|
|
143
117
|
function renderLinter(renderer, refDoc) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
`title: "Linter usage"`,
|
|
150
|
-
"---",
|
|
151
|
-
renderer.linterUsage(refDoc),
|
|
152
|
-
];
|
|
153
|
-
return renderMarkdowDoc(content, 2);
|
|
118
|
+
if (refDoc.linter === undefined) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const content = ["---", `title: "Linter usage"`, "---", renderer.linterUsage(refDoc)];
|
|
122
|
+
return renderMarkdowDoc(content, 2);
|
|
154
123
|
}
|
|
155
124
|
export class StarlightRenderer extends MarkdownRenderer {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
deprecationNotice(notice) {
|
|
202
|
-
return [":::caution", `**Deprecated**: ${notice.message}`, ":::"];
|
|
203
|
-
}
|
|
125
|
+
headingTitle(item) {
|
|
126
|
+
// Set an explicit anchor id.
|
|
127
|
+
return `${inlinecode(item.name)} {#${item.id}}`;
|
|
128
|
+
}
|
|
129
|
+
anchorId(item) {
|
|
130
|
+
// Set an explicit anchor id.
|
|
131
|
+
return item.id;
|
|
132
|
+
}
|
|
133
|
+
install(refDoc) {
|
|
134
|
+
return section("Install", tabs([{
|
|
135
|
+
label: "In a spec",
|
|
136
|
+
content: codeblock(`npm install ${refDoc.name}`, "bash")
|
|
137
|
+
}, {
|
|
138
|
+
label: "In a library",
|
|
139
|
+
content: codeblock(`npm install --save-peer ${refDoc.name}`, "bash")
|
|
140
|
+
}]));
|
|
141
|
+
}
|
|
142
|
+
filename(type) {
|
|
143
|
+
switch (type.kind) {
|
|
144
|
+
case "decorator":
|
|
145
|
+
return "./decorators.md";
|
|
146
|
+
case "operation":
|
|
147
|
+
case "interface":
|
|
148
|
+
return "./interfaces.md";
|
|
149
|
+
case "model":
|
|
150
|
+
case "enum":
|
|
151
|
+
case "union":
|
|
152
|
+
return "./data-types.md";
|
|
153
|
+
default:
|
|
154
|
+
return "";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
linterRuleLink(url) {
|
|
158
|
+
const homepage = this.refDoc.packageJson.docusaurusWebsite;
|
|
159
|
+
if (homepage && url.includes(homepage)) {
|
|
160
|
+
const fromRoot = url.replace(homepage, "");
|
|
161
|
+
return `${fromRoot}.md`;
|
|
162
|
+
} else {
|
|
163
|
+
return url;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
deprecationNotice(notice) {
|
|
167
|
+
return [":::caution", `**Deprecated**: ${notice.message}`, ":::"];
|
|
168
|
+
}
|
|
204
169
|
}
|
|
205
170
|
function tabs(tabs) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=starlight.js.map
|
|
171
|
+
const result = ["<Tabs>"];
|
|
172
|
+
for (const tab of tabs) {
|
|
173
|
+
result.push(`<TabItem label="${tab.label}" default>`, "", tab.content, "", "</TabItem>");
|
|
174
|
+
}
|
|
175
|
+
result.push("</Tabs>", "");
|
|
176
|
+
return result.join("\n");
|
|
177
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compile, createDiagnosticCollector, joinPaths, NodeHost
|
|
1
|
+
import { compile, createDiagnosticCollector, joinPaths, NodeHost } from "@typespec/compiler";
|
|
2
2
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
3
3
|
import prettier from "prettier";
|
|
4
4
|
import { generateJsApiDocs } from "./api-docs.js";
|
|
@@ -9,54 +9,57 @@ import { extractLibraryRefDocs, extractRefDocs } from "./extractor.js";
|
|
|
9
9
|
* @experimental this is for experimental and is for internal use only. Breaking change to this API can happen at anytime.
|
|
10
10
|
*/
|
|
11
11
|
export async function generateLibraryDocs(libraryPath, outputDir, options = {}) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
const diagnostics = createDiagnosticCollector();
|
|
13
|
+
const pkgJson = await readPackageJson(libraryPath);
|
|
14
|
+
const refDoc = diagnostics.pipe(await extractLibraryRefDocs(libraryPath));
|
|
15
|
+
const files = renderToAstroStarlightMarkdown(refDoc);
|
|
16
|
+
await mkdir(outputDir, {
|
|
17
|
+
recursive: true
|
|
18
|
+
});
|
|
19
|
+
const config = await prettier.resolveConfig(libraryPath);
|
|
20
|
+
for (const [name, content] of Object.entries(files)) {
|
|
21
|
+
const formatted = await formatMarkdown(name, content, config);
|
|
22
|
+
await writeFile(joinPaths(outputDir, name), formatted);
|
|
23
|
+
}
|
|
24
|
+
const readme = await formatMarkdown(joinPaths(libraryPath, "README.md"), await renderReadme(refDoc, libraryPath), config ?? {});
|
|
25
|
+
await writeFile(joinPaths(libraryPath, "README.md"), readme);
|
|
26
|
+
if (pkgJson.main && !options.skipJSApi) {
|
|
27
|
+
await generateJsApiDocs(libraryPath, joinPaths(outputDir, "js-api"));
|
|
28
|
+
}
|
|
29
|
+
return diagnostics.diagnostics;
|
|
28
30
|
}
|
|
29
31
|
export async function resolveLibraryRefDocsBase(libraryPath, options = {}) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
const diagnostics = createDiagnosticCollector();
|
|
33
|
+
const pkgJson = await readPackageJson(libraryPath);
|
|
34
|
+
if (pkgJson.tspMain) {
|
|
35
|
+
const main = joinPaths(libraryPath, pkgJson.tspMain);
|
|
36
|
+
const program = await compile(NodeHost, main, {
|
|
37
|
+
parseOptions: {
|
|
38
|
+
comments: true,
|
|
39
|
+
docs: true
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const refDoc = diagnostics.pipe(extractRefDocs(program, options));
|
|
43
|
+
for (const diag of program.diagnostics ?? []) {
|
|
44
|
+
diagnostics.add(diag);
|
|
42
45
|
}
|
|
43
|
-
return
|
|
46
|
+
return diagnostics.wrap(refDoc);
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
44
49
|
}
|
|
45
50
|
async function readPackageJson(libraryPath) {
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
const buffer = await readFile(joinPaths(libraryPath, "package.json"));
|
|
52
|
+
return JSON.parse(buffer.toString());
|
|
48
53
|
}
|
|
49
54
|
async function formatMarkdown(filename, content, options) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=experimental.js.map
|
|
55
|
+
try {
|
|
56
|
+
return await prettier.format(content, {
|
|
57
|
+
...(options ?? {}),
|
|
58
|
+
parser: "markdown"
|
|
59
|
+
});
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.error(`Cannot format with prettier ${filename}`, e);
|
|
63
|
+
return content;
|
|
64
|
+
}
|
|
65
|
+
}
|