@typespec/tspd 0.70.0-dev.1 → 0.70.0-dev.3
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 +10 -6
- 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,232 +1,179 @@
|
|
|
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 renderToDocusaurusMarkdown(refDoc) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const renderer = new DocusaurusRenderer(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 from '@theme/Tabs';", "import TabItem from '@theme/TabItem';", "", 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 from '@theme/Tabs';",
|
|
42
|
-
"import TabItem from '@theme/TabItem';",
|
|
43
|
-
"",
|
|
44
|
-
refDoc.description ?? [],
|
|
45
|
-
renderer.install(refDoc),
|
|
46
|
-
refDoc.emitter?.options ? section("Emitter usage", `[See documentation](./emitter.md)`) : [],
|
|
47
|
-
groupByNamespace(refDoc.namespaces, (namespace) => {
|
|
48
|
-
const content = [];
|
|
49
|
-
if (namespace.decorators.length > 0) {
|
|
50
|
-
content.push(section("Decorators", renderer.toc(namespace.decorators)));
|
|
51
|
-
}
|
|
52
|
-
if (namespace.interfaces.length > 0) {
|
|
53
|
-
content.push(section("Interfaces", renderer.toc(namespace.interfaces)));
|
|
54
|
-
}
|
|
55
|
-
if (namespace.operations.length > 0) {
|
|
56
|
-
content.push(section("Operations", renderer.toc(namespace.operations)));
|
|
57
|
-
}
|
|
58
|
-
if (namespace.models.length > 0) {
|
|
59
|
-
content.push(section("Models", renderer.toc(namespace.models)));
|
|
60
|
-
}
|
|
61
|
-
return content;
|
|
62
|
-
}),
|
|
63
|
-
];
|
|
64
|
-
return renderMarkdowDoc(content, 2);
|
|
49
|
+
return content;
|
|
50
|
+
})];
|
|
51
|
+
return renderMarkdowDoc(content, 2);
|
|
65
52
|
}
|
|
66
53
|
export function renderDecoratorFile(renderer, refDoc, options) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"toc_min_heading_level: 2",
|
|
75
|
-
"toc_max_heading_level: 3",
|
|
76
|
-
"---",
|
|
77
|
-
];
|
|
78
|
-
content.push(renderer.decoratorsSection(refDoc));
|
|
79
|
-
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);
|
|
80
61
|
}
|
|
81
62
|
function renderInterfacesFile(renderer, refDoc) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for (const operation of namespace.operations) {
|
|
101
|
-
content.push(renderer.operation(operation), "");
|
|
102
|
-
}
|
|
103
|
-
return content;
|
|
104
|
-
}));
|
|
105
|
-
return renderMarkdowDoc(content, 2);
|
|
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"`, "toc_min_heading_level: 2", "toc_max_heading_level: 3", "---"];
|
|
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);
|
|
106
81
|
}
|
|
107
82
|
export function renderDataTypes(renderer, refDoc, options) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
for (const union of namespace.unions) {
|
|
135
|
-
content.push(renderer.union(union), "");
|
|
136
|
-
}
|
|
137
|
-
for (const scalar of namespace.scalars) {
|
|
138
|
-
content.push(renderer.scalar(scalar), "");
|
|
139
|
-
}
|
|
140
|
-
return content;
|
|
141
|
-
}));
|
|
142
|
-
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}"`, "toc_min_heading_level: 2", "toc_max_heading_level: 3", "---"];
|
|
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);
|
|
143
109
|
}
|
|
144
110
|
function renderEmitter(renderer, refDoc) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
`title: "Emitter usage"`,
|
|
151
|
-
"toc_min_heading_level: 2",
|
|
152
|
-
"toc_max_heading_level: 3",
|
|
153
|
-
"---",
|
|
154
|
-
renderer.emitterUsage(refDoc),
|
|
155
|
-
];
|
|
156
|
-
return renderMarkdowDoc(content, 2);
|
|
111
|
+
if (refDoc.emitter?.options === undefined) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const content = ["---", `title: "Emitter usage"`, "toc_min_heading_level: 2", "toc_max_heading_level: 3", "---", renderer.emitterUsage(refDoc)];
|
|
115
|
+
return renderMarkdowDoc(content, 2);
|
|
157
116
|
}
|
|
158
117
|
function renderLinter(renderer, refDoc) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
`title: "Linter usage"`,
|
|
165
|
-
"toc_min_heading_level: 2",
|
|
166
|
-
"toc_max_heading_level: 3",
|
|
167
|
-
"---",
|
|
168
|
-
renderer.linterUsage(refDoc),
|
|
169
|
-
];
|
|
170
|
-
return renderMarkdowDoc(content, 2);
|
|
118
|
+
if (refDoc.linter === undefined) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const content = ["---", `title: "Linter usage"`, "toc_min_heading_level: 2", "toc_max_heading_level: 3", "---", renderer.linterUsage(refDoc)];
|
|
122
|
+
return renderMarkdowDoc(content, 2);
|
|
171
123
|
}
|
|
172
124
|
export class DocusaurusRenderer extends MarkdownRenderer {
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
deprecationNotice(notice) {
|
|
221
|
-
return [":::warning", `**Deprecated**: ${notice.message}`, ":::"];
|
|
222
|
-
}
|
|
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
|
+
id: "spec",
|
|
136
|
+
label: "In a spec",
|
|
137
|
+
content: codeblock(`npm install ${refDoc.name}`, "bash")
|
|
138
|
+
}, {
|
|
139
|
+
id: "library",
|
|
140
|
+
label: "In a library",
|
|
141
|
+
content: codeblock(`npm install --save-peer ${refDoc.name}`, "bash")
|
|
142
|
+
}]));
|
|
143
|
+
}
|
|
144
|
+
filename(type) {
|
|
145
|
+
switch (type.kind) {
|
|
146
|
+
case "decorator":
|
|
147
|
+
return "./decorators.md";
|
|
148
|
+
case "operation":
|
|
149
|
+
case "interface":
|
|
150
|
+
return "./interfaces.md";
|
|
151
|
+
case "model":
|
|
152
|
+
case "enum":
|
|
153
|
+
case "union":
|
|
154
|
+
return "./data-types.md";
|
|
155
|
+
default:
|
|
156
|
+
return "";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
linterRuleLink(url) {
|
|
160
|
+
const homepage = this.refDoc.packageJson.docusaurusWebsite;
|
|
161
|
+
if (homepage && url.includes(homepage)) {
|
|
162
|
+
const fromRoot = url.replace(homepage, "");
|
|
163
|
+
return `${fromRoot}.md`;
|
|
164
|
+
} else {
|
|
165
|
+
return url;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
deprecationNotice(notice) {
|
|
169
|
+
return [":::warning", `**Deprecated**: ${notice.message}`, ":::"];
|
|
170
|
+
}
|
|
223
171
|
}
|
|
224
172
|
function tabs(tabs) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
//# sourceMappingURL=docusaurus.js.map
|
|
173
|
+
const result = ["<Tabs>"];
|
|
174
|
+
for (const tab of tabs) {
|
|
175
|
+
result.push(`<TabItem value="${tab.id}" label="${tab.label}" default>`, "", tab.content, "", "</TabItem>");
|
|
176
|
+
}
|
|
177
|
+
result.push("</Tabs>", "");
|
|
178
|
+
return result.join("\n");
|
|
179
|
+
}
|