@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,14 +1,12 @@
|
|
|
1
1
|
export function renderDoc(doc) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
doc.forEach(render);
|
|
9
|
-
}
|
|
2
|
+
const flattened = [];
|
|
3
|
+
function render(doc) {
|
|
4
|
+
if (typeof doc === "string") {
|
|
5
|
+
flattened.push(doc);
|
|
6
|
+
} else {
|
|
7
|
+
doc.forEach(render);
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
}
|
|
10
|
+
render(doc);
|
|
11
|
+
return flattened.join("");
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const typespecCompiler: {} & {
|
|
2
|
+
DecoratorContext: import("@alloy-js/core").Refkey;
|
|
3
|
+
Type: import("@alloy-js/core").Refkey;
|
|
4
|
+
Namespace: import("@alloy-js/core").Refkey;
|
|
5
|
+
Model: import("@alloy-js/core").Refkey;
|
|
6
|
+
ModelProperty: import("@alloy-js/core").Refkey;
|
|
7
|
+
Enum: import("@alloy-js/core").Refkey;
|
|
8
|
+
EnumMember: import("@alloy-js/core").Refkey;
|
|
9
|
+
Operation: import("@alloy-js/core").Refkey;
|
|
10
|
+
Interface: import("@alloy-js/core").Refkey;
|
|
11
|
+
Union: import("@alloy-js/core").Refkey;
|
|
12
|
+
UnionVariant: import("@alloy-js/core").Refkey;
|
|
13
|
+
Scalar: import("@alloy-js/core").Refkey;
|
|
14
|
+
EnumValue: import("@alloy-js/core").Refkey;
|
|
15
|
+
Numeric: import("@alloy-js/core").Refkey;
|
|
16
|
+
} & import("@alloy-js/core").SymbolCreator;
|
|
17
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../../src/gen-extern-signatures/external-packages/compiler.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;0CAuB3B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createPackage } from "@alloy-js/typescript";
|
|
2
|
+
export const typespecCompiler = createPackage({
|
|
3
|
+
name: "@typespec/compiler",
|
|
4
|
+
version: "^1.0.0",
|
|
5
|
+
descriptor: {
|
|
6
|
+
".": {
|
|
7
|
+
named: ["DecoratorContext", "Type", "Namespace", "Model", "ModelProperty", "Enum", "EnumMember", "Operation", "Interface", "Union", "UnionVariant", "Scalar", "EnumValue", "Numeric"]
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../../src/gen-extern-signatures/external-packages/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;IAC5C,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,QAAQ;IACjB,UAAU,EAAE;QACV,GAAG,EAAE;YACH,KAAK,EAAE;gBACL,kBAAkB;gBAClB,MAAM;gBACN,WAAW;gBACX,OAAO;gBACP,eAAe;gBACf,MAAM;gBACN,YAAY;gBACZ,WAAW;gBACX,WAAW;gBACX,OAAO;gBACP,cAAc;gBACd,QAAQ;gBACR,WAAW;gBACX,SAAS;aACV;SACF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen-extern-signatures.d.ts","sourceRoot":"","sources":["../../../src/gen-extern-signatures/gen-extern-signatures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gen-extern-signatures.d.ts","sourceRoot":"","sources":["../../../src/gen-extern-signatures/gen-extern-signatures.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAEZ,UAAU,EACV,SAAS,EACT,KAAK,WAAW,EAChB,OAAO,EAYR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAQhC,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAiChC;AAED,wBAAsB,iCAAiC,CACrD,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC,CAAC,CAsB7C;AAOD,MAAM,WAAW,8BAA8B;IAC7C,+GAA+G;IAC/G,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IAClC,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC;CAC5C;AACD,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAwDjC"}
|
|
@@ -1,122 +1,129 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { traverseOutput } from "@alloy-js/core";
|
|
2
|
+
import { compile, createDiagnosticCollector, createSourceFile, getLocationContext, getTypeName, joinPaths, navigateProgram, navigateTypesInNamespace, resolvePath } from "@typespec/compiler";
|
|
2
3
|
import prettier from "prettier";
|
|
3
4
|
import { createDiagnostic } from "../ref-doc/lib.js";
|
|
4
|
-
import {
|
|
5
|
+
import { generateSignatures } from "./components/decorators-signatures.js";
|
|
5
6
|
function createSourceLocation(path) {
|
|
6
|
-
|
|
7
|
+
return {
|
|
8
|
+
file: createSourceFile("", path),
|
|
9
|
+
pos: 0,
|
|
10
|
+
end: 0
|
|
11
|
+
};
|
|
7
12
|
}
|
|
8
13
|
export async function generateExternSignatures(host, libraryPath) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const diagnostics = createDiagnosticCollector();
|
|
15
|
+
const pkgJson = await readPackageJson(host, libraryPath);
|
|
16
|
+
if (!pkgJson.exports) {
|
|
17
|
+
return [createDiagnostic({
|
|
18
|
+
code: "exports-missing",
|
|
19
|
+
target: createSourceLocation(resolvePath(libraryPath, "package.json"))
|
|
20
|
+
})];
|
|
21
|
+
}
|
|
22
|
+
const exportsMap = {};
|
|
23
|
+
for (const [key, value] of Object.entries(pkgJson.exports)) {
|
|
24
|
+
if (typeof value === "object" && "typespec" in value && typeof value.typespec === "string") {
|
|
25
|
+
exportsMap[key] = resolvePath(libraryPath, value.typespec);
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
code: "exports-missing",
|
|
32
|
-
messageId: "missingCondition",
|
|
33
|
-
target: createSourceLocation(resolvePath(libraryPath, "package.json")),
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
return diagnostics.diagnostics;
|
|
27
|
+
}
|
|
28
|
+
const exports = Object.values(exportsMap);
|
|
29
|
+
if (exports.length > 0) {
|
|
30
|
+
diagnostics.pipe(await generateExternSignatureForExports(host, libraryPath, pkgJson, exports));
|
|
31
|
+
} else {
|
|
32
|
+
diagnostics.add(createDiagnostic({
|
|
33
|
+
code: "exports-missing",
|
|
34
|
+
messageId: "missingCondition",
|
|
35
|
+
target: createSourceLocation(resolvePath(libraryPath, "package.json"))
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
return diagnostics.diagnostics;
|
|
37
39
|
}
|
|
38
40
|
export async function generateExternSignatureForExports(host, libraryPath, pkgJson, exports) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const outDir = resolvePath(libraryPath, "generated-defs");
|
|
47
|
-
try {
|
|
48
|
-
await host.rm(outDir, { recursive: true });
|
|
41
|
+
const [main, ...additionalImports] = exports;
|
|
42
|
+
const diagnostics = createDiagnosticCollector();
|
|
43
|
+
const program = await compile(host, main, {
|
|
44
|
+
additionalImports,
|
|
45
|
+
parseOptions: {
|
|
46
|
+
comments: true,
|
|
47
|
+
docs: true
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
});
|
|
50
|
+
const prettierConfig = await prettier.resolveConfig(libraryPath);
|
|
51
|
+
const outDir = resolvePath(libraryPath, "generated-defs");
|
|
52
|
+
try {
|
|
53
|
+
await host.rm(outDir, {
|
|
54
|
+
recursive: true
|
|
54
55
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
} catch (e) {}
|
|
57
|
+
await host.mkdirp(outDir);
|
|
58
|
+
const files = await generateExternDecorators(program, pkgJson.name, {
|
|
59
|
+
prettierConfig: prettierConfig ?? undefined
|
|
60
|
+
});
|
|
61
|
+
for (const [name, content] of Object.entries(files)) {
|
|
62
|
+
await host.writeFile(resolvePath(outDir, name), content);
|
|
63
|
+
}
|
|
64
|
+
return [undefined, diagnostics.diagnostics];
|
|
59
65
|
}
|
|
60
66
|
async function readPackageJson(host, libraryPath) {
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
const file = await host.readFile(joinPaths(libraryPath, "package.json"));
|
|
68
|
+
return JSON.parse(file.text);
|
|
63
69
|
}
|
|
64
70
|
export async function generateExternDecorators(program, packageName, options) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
decoratorForNamespace.push(resolveDecoratorSignature(dec));
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
if (options?.namespaces) {
|
|
82
|
-
for (const namespace of options.namespaces) {
|
|
83
|
-
navigateTypesInNamespace(namespace, listener, { skipSubNamespaces: true });
|
|
84
|
-
}
|
|
71
|
+
const decorators = new Map();
|
|
72
|
+
const listener = {
|
|
73
|
+
decorator(dec) {
|
|
74
|
+
if (packageName !== "@typespec/compiler" && getLocationContext(program, dec).type !== "project") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const namespaceName = getTypeName(dec.namespace);
|
|
78
|
+
let decoratorForNamespace = decorators.get(namespaceName);
|
|
79
|
+
if (!decoratorForNamespace) {
|
|
80
|
+
decoratorForNamespace = [];
|
|
81
|
+
decorators.set(namespaceName, decoratorForNamespace);
|
|
82
|
+
}
|
|
83
|
+
decoratorForNamespace.push(resolveDecoratorSignature(dec));
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
};
|
|
86
|
+
if (options?.namespaces) {
|
|
87
|
+
for (const namespace of options.namespaces) {
|
|
88
|
+
navigateTypesInNamespace(namespace, listener, {
|
|
89
|
+
skipSubNamespaces: true
|
|
90
|
+
});
|
|
88
91
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
} else {
|
|
93
|
+
navigateProgram(program, listener);
|
|
94
|
+
}
|
|
95
|
+
function format(value) {
|
|
96
|
+
try {
|
|
97
|
+
const formatted = prettier.format(value, {
|
|
98
|
+
...options?.prettierConfig,
|
|
99
|
+
parser: "typescript"
|
|
100
|
+
});
|
|
101
|
+
return formatted;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
// eslint-disable-next-line no-console
|
|
104
|
+
console.error("Error formatting", e);
|
|
105
|
+
return value;
|
|
102
106
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
}
|
|
108
|
+
const files = {};
|
|
109
|
+
for (const [ns, nsDecorators] of decorators.entries()) {
|
|
110
|
+
const output = generateSignatures(program, nsDecorators, packageName, ns);
|
|
111
|
+
const rawFiles = [];
|
|
112
|
+
traverseOutput(output, {
|
|
113
|
+
visitDirectory: () => {},
|
|
114
|
+
visitFile: file => rawFiles.push(file)
|
|
115
|
+
});
|
|
116
|
+
for (const file of rawFiles) {
|
|
117
|
+
files[file.path] = await format(file.contents);
|
|
111
118
|
}
|
|
112
|
-
|
|
119
|
+
}
|
|
120
|
+
return files;
|
|
113
121
|
}
|
|
114
122
|
function resolveDecoratorSignature(decorator) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=gen-extern-signatures.js.map
|
|
123
|
+
return {
|
|
124
|
+
decorator,
|
|
125
|
+
name: decorator.name,
|
|
126
|
+
jsName: "$" + decorator.name.slice(1),
|
|
127
|
+
typeName: decorator.name[1].toUpperCase() + decorator.name.slice(2) + "Decorator"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen-extern-signatures.js","sourceRoot":"","sources":["../../../src/gen-extern-signatures/gen-extern-signatures.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,OAAO,EACP,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,eAAe,EACf,wBAAwB,EACxB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"gen-extern-signatures.js","sourceRoot":"","sources":["../../../src/gen-extern-signatures/gen-extern-signatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EASL,OAAO,EACP,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,eA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AAI,CAAC,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,yBAAyB,CAAC,SAAoB;IACrD,OAAO;QACL,SAAS;QACT,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,MAAM,EAAE,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACrC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,WAAW;KAClF,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export {};
|
|
@@ -4,68 +4,68 @@ import { Application, PageEvent, ReflectionKind } from "typedoc";
|
|
|
4
4
|
import { load } from "typedoc-plugin-markdown";
|
|
5
5
|
import { stringify } from "yaml";
|
|
6
6
|
export async function generateJsApiDocs(libraryPath, outputDir) {
|
|
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
|
-
|
|
7
|
+
const markdownPluginOptions = {
|
|
8
|
+
entryFileName: "index.md",
|
|
9
|
+
propertiesFormat: "table",
|
|
10
|
+
parametersFormat: "table",
|
|
11
|
+
enumMembersFormat: "table",
|
|
12
|
+
typeDeclarationFormat: "table",
|
|
13
|
+
hidePageTitle: true,
|
|
14
|
+
hideBreadcrumbs: true,
|
|
15
|
+
hidePageHeader: true,
|
|
16
|
+
useCodeBlocks: true
|
|
17
|
+
};
|
|
18
|
+
const app = await Application.bootstrapWithPlugins({
|
|
19
|
+
entryPoints: [joinPaths(libraryPath, "src/index.ts")],
|
|
20
|
+
tsconfig: joinPaths(libraryPath, "tsconfig.json"),
|
|
21
|
+
entryPointStrategy: "resolve"
|
|
22
|
+
});
|
|
23
|
+
loadRenderer(app);
|
|
24
|
+
load(app);
|
|
25
|
+
setOptions(app, {
|
|
26
|
+
name: "JS API",
|
|
27
|
+
githubPages: false,
|
|
28
|
+
readme: "none",
|
|
29
|
+
hideGenerator: true,
|
|
30
|
+
disableSources: true,
|
|
31
|
+
out: outputDir,
|
|
32
|
+
...markdownPluginOptions
|
|
33
|
+
});
|
|
34
|
+
const project = await app.convert();
|
|
35
|
+
|
|
36
|
+
// if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
|
|
37
|
+
if (!project) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
await app.generateOutputs(project);
|
|
41
|
+
await writeFile(joinPaths(outputDir, "_category_.json"), JSON.stringify({
|
|
42
|
+
label: "JS API",
|
|
43
|
+
link: {
|
|
44
|
+
type: "doc",
|
|
45
|
+
id: "index"
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
await writeFile(joinPaths(outputDir, "_category_.json"), JSON.stringify({
|
|
41
|
-
label: "JS API",
|
|
42
|
-
link: {
|
|
43
|
-
type: "doc",
|
|
44
|
-
id: "index",
|
|
45
|
-
},
|
|
46
|
-
}));
|
|
47
|
+
}));
|
|
47
48
|
}
|
|
48
49
|
function setOptions(app, options, reportErrors = true) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
for (const [key, val] of Object.entries(options)) {
|
|
51
|
+
app.options.setValue(key, val);
|
|
52
|
+
}
|
|
52
53
|
}
|
|
53
54
|
export function loadRenderer(app) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
app.renderer.on(PageEvent.END, page => {
|
|
56
|
+
if (page.contents && page) {
|
|
57
|
+
const frontMatter = createFrontMatter(page.model);
|
|
58
|
+
page.contents = frontMatter + page.contents.replace(/\\</g, "<");
|
|
59
|
+
}
|
|
60
|
+
});
|
|
60
61
|
}
|
|
61
62
|
function createFrontMatter(model) {
|
|
62
|
-
|
|
63
|
+
return ["---", stringify(createFrontMatterData(model)), "---", ""].join("\n");
|
|
63
64
|
}
|
|
64
65
|
function createFrontMatterData(model) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=api-docs.js.map
|
|
66
|
+
const kind = ReflectionKind.singularString(model.kind)[0];
|
|
67
|
+
return {
|
|
68
|
+
jsApi: true,
|
|
69
|
+
title: `[${kind}] ${model.name}`
|
|
70
|
+
};
|
|
71
|
+
}
|