rspress-plugin-api-extractor 0.8.9 → 0.9.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/README.md +11 -11
- package/build-program.js +3 -3
- package/build-stages.js +30 -31
- package/config-helpers.js +61 -21
- package/errors.js +1 -7
- package/frontmatter.js +149 -0
- package/index.d.ts +11 -2
- package/layers/ConfigServiceLive.js +53 -39
- package/layers/TypeRegistryServiceLive.js +10 -5
- package/markdown/helpers.js +40 -69
- package/markdown/index.js +2 -2
- package/markdown/page-generators/class-page.js +40 -42
- package/markdown/page-generators/enum-page.js +15 -15
- package/markdown/page-generators/function-page.js +18 -20
- package/markdown/page-generators/interface-page.js +41 -43
- package/markdown/page-generators/namespace-page.js +22 -24
- package/markdown/page-generators/type-alias-page.js +14 -16
- package/markdown/page-generators/variable-page.js +14 -16
- package/markdown/prose-linker.js +22 -0
- package/model-loader.js +59 -113
- package/package.json +11 -5
- package/plugin.js +1 -5
- package/shiki-transformer.js +3 -3
- package/sync-node-fs.js +80 -0
- package/twoslash-transformer.js +1 -1
- package/content-hash.js +0 -79
- package/formatter.js +0 -69
- package/layers/SnapshotServiceLive.js +0 -92
- package/loader.js +0 -200
- package/markdown/cross-linker.js +0 -157
- package/migrations/001_create_snapshots.js +0 -25
- package/multi-entry-resolver.js +0 -70
- package/route-collisions.js +0 -44
- package/services/SnapshotService.js +0 -7
- package/synthetic-bases.js +0 -74
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ApiParser } from "../../loader.js";
|
|
2
1
|
import { escapeMdxGenerics, formatExampleCode, generateAvailableFrom, generateFrontmatter, prepareExampleCode, stripTwoslashDirectives } from "../helpers.js";
|
|
3
|
-
import {
|
|
2
|
+
import { linkProse } from "../prose-linker.js";
|
|
3
|
+
import { ApiItems, Tsdoc } from "@tsdoctor/model";
|
|
4
4
|
|
|
5
5
|
//#region src/markdown/page-generators/enum-page.ts
|
|
6
6
|
/**
|
|
@@ -23,9 +23,9 @@ import { markdownCrossLinker } from "../cross-linker.js";
|
|
|
23
23
|
*
|
|
24
24
|
* **Relationships:**
|
|
25
25
|
* - Created and invoked by {@link ApiExtractorPlugin} during page generation
|
|
26
|
-
* - Uses
|
|
27
|
-
* - Uses
|
|
28
|
-
* - Uses
|
|
26
|
+
* - Uses `Signature.format` from `@tsdoctor/model` for formatting type signatures
|
|
27
|
+
* - Uses the `Tsdoc` / `ApiItems` modules from `@tsdoctor/model` for extracting documentation
|
|
28
|
+
* - Uses the per-build prose linker (`linkProse`) for adding type reference links
|
|
29
29
|
*
|
|
30
30
|
* @see {@link TypeAliasPageGenerator} for type alias documentation
|
|
31
31
|
* @see {@link VariablePageGenerator} for variable/constant documentation
|
|
@@ -39,22 +39,22 @@ var EnumPageGenerator = class {
|
|
|
39
39
|
async generate(apiEnum, baseRoute, packageName, singularName, apiScope, apiName, sourceConfig, suppressExampleErrors, llmsPlugin, availableFrom) {
|
|
40
40
|
const shouldSuppressErrors = suppressExampleErrors ?? true;
|
|
41
41
|
const name = apiEnum.displayName;
|
|
42
|
-
const summary =
|
|
43
|
-
const releaseTag =
|
|
42
|
+
const summary = Tsdoc.summary(apiEnum) || "No description available.";
|
|
43
|
+
const releaseTag = Tsdoc.releaseTag(apiEnum);
|
|
44
44
|
let content = generateFrontmatter(name, summary, singularName, apiName);
|
|
45
45
|
content += `import { SourceCode } from "@rspress/core/theme";\n`;
|
|
46
46
|
content += `import { EnumMembersTable } from "rspress-plugin-api-extractor/runtime";\n`;
|
|
47
47
|
content += `import { ApiSignature, ApiExample } from "rspress-plugin-api-extractor/runtime";\n\n`;
|
|
48
48
|
content += `# ${name}\n\n`;
|
|
49
|
-
const deprecation =
|
|
49
|
+
const deprecation = Tsdoc.deprecation(apiEnum);
|
|
50
50
|
if (deprecation) {
|
|
51
|
-
const message = escapeMdxGenerics(
|
|
51
|
+
const message = escapeMdxGenerics(linkProse(deprecation.message));
|
|
52
52
|
content += `> ⚠️ **Deprecated:** ${message}\n\n`;
|
|
53
53
|
}
|
|
54
54
|
if (releaseTag !== "Public") content += `\`${releaseTag}\`\n\n`;
|
|
55
55
|
content += `${summary}\n\n`;
|
|
56
56
|
content += generateAvailableFrom(packageName, availableFrom);
|
|
57
|
-
const sourceLink =
|
|
57
|
+
const sourceLink = ApiItems.sourceLink(apiEnum, sourceConfig);
|
|
58
58
|
if (sourceLink) {
|
|
59
59
|
content += `<div className="api-docs-toolbar">\n`;
|
|
60
60
|
content += ` <div className="api-docs-toolbar-left">\n`;
|
|
@@ -76,7 +76,7 @@ var EnumPageGenerator = class {
|
|
|
76
76
|
if (hasMembers) {
|
|
77
77
|
const membersData = apiEnum.members.map((member) => {
|
|
78
78
|
const memberItem = member;
|
|
79
|
-
const memberSummary =
|
|
79
|
+
const memberSummary = Tsdoc.summary(member) || "";
|
|
80
80
|
let value;
|
|
81
81
|
if (memberItem.excerpt?.text) {
|
|
82
82
|
const excerptText = memberItem.excerpt.text.trim();
|
|
@@ -86,12 +86,12 @@ var EnumPageGenerator = class {
|
|
|
86
86
|
return {
|
|
87
87
|
name: member.displayName,
|
|
88
88
|
value,
|
|
89
|
-
description:
|
|
89
|
+
description: linkProse(memberSummary)
|
|
90
90
|
};
|
|
91
91
|
});
|
|
92
92
|
content += `<EnumMembersTable members={${JSON.stringify(membersData)}} />\n\n`;
|
|
93
93
|
}
|
|
94
|
-
const examples =
|
|
94
|
+
const examples = Tsdoc.examples(apiEnum);
|
|
95
95
|
if (examples.length > 0) {
|
|
96
96
|
content += `## Examples\n\n`;
|
|
97
97
|
for (const example of examples) {
|
|
@@ -106,11 +106,11 @@ var EnumPageGenerator = class {
|
|
|
106
106
|
} else content += `\`\`\`${prepared.language}\n${formattedCode}\n\`\`\`\n\n`;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const seeReferences =
|
|
109
|
+
const seeReferences = Tsdoc.seeReferences(apiEnum);
|
|
110
110
|
if (seeReferences.length > 0) {
|
|
111
111
|
content += `## See Also\n\n`;
|
|
112
112
|
for (const reference of seeReferences) {
|
|
113
|
-
const refText = escapeMdxGenerics(
|
|
113
|
+
const refText = escapeMdxGenerics(linkProse(reference.text));
|
|
114
114
|
content += `- ${refText}\n`;
|
|
115
115
|
}
|
|
116
116
|
content += `\n`;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ApiParser } from "../../loader.js";
|
|
2
1
|
import { TypeReferenceExtractor } from "../../type-reference-extractor.js";
|
|
3
2
|
import { escapeMdxGenerics, formatExampleCode, generateAvailableFrom, generateFrontmatter, prepareExampleCode, prependHiddenImports, stripTwoslashDirectives } from "../helpers.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { linkProse } from "../prose-linker.js";
|
|
4
|
+
import { ApiItems, Signature, Tsdoc } from "@tsdoctor/model";
|
|
6
5
|
|
|
7
6
|
//#region src/markdown/page-generators/function-page.ts
|
|
8
7
|
/**
|
|
@@ -25,15 +24,14 @@ import { TypeSignatureFormatter } from "../../formatter.js";
|
|
|
25
24
|
*
|
|
26
25
|
* **Relationships:**
|
|
27
26
|
* - Created and invoked by {@link ApiExtractorPlugin} during page generation
|
|
28
|
-
* - Uses
|
|
29
|
-
* - Uses
|
|
30
|
-
* - Uses
|
|
27
|
+
* - Uses `Signature.format` from `@tsdoctor/model` for formatting type signatures
|
|
28
|
+
* - Uses the `Tsdoc` / `ApiItems` modules from `@tsdoctor/model` for extracting documentation
|
|
29
|
+
* - Uses the per-build prose linker (`linkProse`) for adding type reference links
|
|
31
30
|
*
|
|
32
31
|
* @see {@link ClassPageGenerator} for class documentation
|
|
33
32
|
* @see {@link TypeAliasPageGenerator} for type alias documentation
|
|
34
33
|
*/
|
|
35
34
|
var FunctionPageGenerator = class {
|
|
36
|
-
typeFormatter = new TypeSignatureFormatter();
|
|
37
35
|
/**
|
|
38
36
|
* Generate a markdown page for a function
|
|
39
37
|
*
|
|
@@ -42,22 +40,22 @@ var FunctionPageGenerator = class {
|
|
|
42
40
|
async generate(apiFunction, baseRoute, packageName, singularName, apiScope, apiName, sourceConfig, suppressExampleErrors, llmsPlugin, availableFrom) {
|
|
43
41
|
const shouldSuppressErrors = suppressExampleErrors ?? true;
|
|
44
42
|
const name = apiFunction.displayName;
|
|
45
|
-
const summary =
|
|
46
|
-
const releaseTag =
|
|
43
|
+
const summary = Tsdoc.summary(apiFunction) || "No description available.";
|
|
44
|
+
const releaseTag = Tsdoc.releaseTag(apiFunction);
|
|
47
45
|
let content = generateFrontmatter(name, summary, singularName, apiName);
|
|
48
46
|
content += `import { SourceCode } from "@rspress/core/theme";\n`;
|
|
49
47
|
content += `import { ParametersTable } from "rspress-plugin-api-extractor/runtime";\n`;
|
|
50
48
|
content += `import { ApiSignature, ApiExample } from "rspress-plugin-api-extractor/runtime";\n\n`;
|
|
51
49
|
content += `# ${name}\n\n`;
|
|
52
|
-
const deprecation =
|
|
50
|
+
const deprecation = Tsdoc.deprecation(apiFunction);
|
|
53
51
|
if (deprecation) {
|
|
54
|
-
const message = escapeMdxGenerics(
|
|
52
|
+
const message = escapeMdxGenerics(linkProse(deprecation.message));
|
|
55
53
|
content += `> ⚠️ **Deprecated:** ${message}\n\n`;
|
|
56
54
|
}
|
|
57
55
|
if (releaseTag !== "Public") content += `\`${releaseTag}\`\n\n`;
|
|
58
56
|
content += `${summary}\n\n`;
|
|
59
57
|
content += generateAvailableFrom(packageName, availableFrom);
|
|
60
|
-
const sourceLink =
|
|
58
|
+
const sourceLink = ApiItems.sourceLink(apiFunction, sourceConfig);
|
|
61
59
|
if (sourceLink) {
|
|
62
60
|
content += `<div className="api-docs-toolbar">\n`;
|
|
63
61
|
content += ` <div className="api-docs-toolbar-left">\n`;
|
|
@@ -69,10 +67,10 @@ var FunctionPageGenerator = class {
|
|
|
69
67
|
}
|
|
70
68
|
content += `</div>\n\n`;
|
|
71
69
|
}
|
|
72
|
-
const params =
|
|
70
|
+
const params = Tsdoc.params(apiFunction);
|
|
73
71
|
const hasParameters = params.length > 0;
|
|
74
72
|
if (apiFunction.excerpt.text) {
|
|
75
|
-
const signature =
|
|
73
|
+
const signature = Signature.format(apiFunction.excerpt).trim();
|
|
76
74
|
let signatureWithImports = signature;
|
|
77
75
|
const apiPackage = apiFunction.getAssociatedPackage?.();
|
|
78
76
|
if (apiPackage) {
|
|
@@ -86,16 +84,16 @@ var FunctionPageGenerator = class {
|
|
|
86
84
|
const parametersData = params.map((param) => ({
|
|
87
85
|
name: param.name,
|
|
88
86
|
type: param.type,
|
|
89
|
-
description: escapeMdxGenerics(
|
|
87
|
+
description: escapeMdxGenerics(linkProse(param.description))
|
|
90
88
|
}));
|
|
91
89
|
content += `<ParametersTable parameters={${JSON.stringify(parametersData)}} />\n\n`;
|
|
92
90
|
}
|
|
93
|
-
const returns =
|
|
91
|
+
const returns = Tsdoc.returns(apiFunction);
|
|
94
92
|
if (returns) {
|
|
95
|
-
const description = escapeMdxGenerics(
|
|
93
|
+
const description = escapeMdxGenerics(linkProse(returns.description));
|
|
96
94
|
content += `## Returns\n\n${description}\n\n`;
|
|
97
95
|
}
|
|
98
|
-
const examples =
|
|
96
|
+
const examples = Tsdoc.examples(apiFunction);
|
|
99
97
|
if (examples.length > 0) {
|
|
100
98
|
content += `## Examples\n\n`;
|
|
101
99
|
for (const example of examples) {
|
|
@@ -110,11 +108,11 @@ var FunctionPageGenerator = class {
|
|
|
110
108
|
} else content += `\`\`\`${prepared.language}\n${formattedCode}\n\`\`\`\n\n`;
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
|
-
const seeReferences =
|
|
111
|
+
const seeReferences = Tsdoc.seeReferences(apiFunction);
|
|
114
112
|
if (seeReferences.length > 0) {
|
|
115
113
|
content += `## See Also\n\n`;
|
|
116
114
|
for (const reference of seeReferences) {
|
|
117
|
-
const refText = escapeMdxGenerics(
|
|
115
|
+
const refText = escapeMdxGenerics(linkProse(reference.text));
|
|
118
116
|
content += `- ${refText}\n`;
|
|
119
117
|
}
|
|
120
118
|
content += `\n`;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ApiParser } from "../../loader.js";
|
|
2
1
|
import { TypeReferenceExtractor } from "../../type-reference-extractor.js";
|
|
3
2
|
import { escapeMdxGenerics, formatExampleCode, generateAvailableFrom, generateFrontmatter, prepareExampleCode, prependHiddenImports, sanitizeId, stripTwoslashDirectives } from "../helpers.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { linkProse } from "../prose-linker.js";
|
|
4
|
+
import { ApiItems, Signature, Tsdoc } from "@tsdoctor/model";
|
|
6
5
|
|
|
7
6
|
//#region src/markdown/page-generators/interface-page.ts
|
|
8
7
|
/**
|
|
@@ -32,9 +31,9 @@ import { TypeSignatureFormatter } from "../../formatter.js";
|
|
|
32
31
|
*
|
|
33
32
|
* **Relationships:**
|
|
34
33
|
* - Created and invoked by {@link ApiExtractorPlugin} during page generation
|
|
35
|
-
* - Uses
|
|
36
|
-
* - Uses
|
|
37
|
-
* - Uses
|
|
34
|
+
* - Uses `Signature.format` from `@tsdoctor/model` for formatting type signatures
|
|
35
|
+
* - Uses the `Tsdoc` / `ApiItems` modules from `@tsdoctor/model` for extracting documentation
|
|
36
|
+
* - Uses the per-build prose linker (`linkProse`) for adding type reference links
|
|
38
37
|
*
|
|
39
38
|
* @example
|
|
40
39
|
* ```ts
|
|
@@ -56,7 +55,6 @@ import { TypeSignatureFormatter } from "../../formatter.js";
|
|
|
56
55
|
* @see {@link TypeAliasPageGenerator} for type alias documentation
|
|
57
56
|
*/
|
|
58
57
|
var InterfacePageGenerator = class {
|
|
59
|
-
typeFormatter = new TypeSignatureFormatter();
|
|
60
58
|
/**
|
|
61
59
|
* Generate a markdown page for an interface
|
|
62
60
|
*
|
|
@@ -65,22 +63,22 @@ var InterfacePageGenerator = class {
|
|
|
65
63
|
async generate(apiInterface, baseRoute, packageName, singularName, apiScope, apiName, sourceConfig, suppressExampleErrors, llmsPlugin, availableFrom) {
|
|
66
64
|
const shouldSuppressErrors = suppressExampleErrors ?? true;
|
|
67
65
|
const name = apiInterface.displayName;
|
|
68
|
-
const summary =
|
|
69
|
-
const releaseTag =
|
|
66
|
+
const summary = Tsdoc.summary(apiInterface) || "No description available.";
|
|
67
|
+
const releaseTag = Tsdoc.releaseTag(apiInterface);
|
|
70
68
|
let content = generateFrontmatter(name, summary, singularName, apiName);
|
|
71
69
|
content += `import { SourceCode } from "@rspress/core/theme";\n`;
|
|
72
70
|
content += `import { ParametersTable } from "rspress-plugin-api-extractor/runtime";\n`;
|
|
73
71
|
content += `import { ApiSignature, ApiMember, ApiExample } from "rspress-plugin-api-extractor/runtime";\n\n`;
|
|
74
72
|
content += `# ${name}\n\n`;
|
|
75
|
-
const deprecation =
|
|
73
|
+
const deprecation = Tsdoc.deprecation(apiInterface);
|
|
76
74
|
if (deprecation) {
|
|
77
|
-
const message = escapeMdxGenerics(
|
|
75
|
+
const message = escapeMdxGenerics(linkProse(deprecation.message));
|
|
78
76
|
content += `> ⚠️ **Deprecated:** ${message}\n\n`;
|
|
79
77
|
}
|
|
80
78
|
if (releaseTag !== "Public") content += `\`${releaseTag}\`\n\n`;
|
|
81
79
|
content += `${summary}\n\n`;
|
|
82
80
|
content += generateAvailableFrom(packageName, availableFrom);
|
|
83
|
-
const sourceLink =
|
|
81
|
+
const sourceLink = ApiItems.sourceLink(apiInterface, sourceConfig);
|
|
84
82
|
if (sourceLink) {
|
|
85
83
|
content += `<div className="api-docs-toolbar">\n`;
|
|
86
84
|
content += ` <div className="api-docs-toolbar-left">\n`;
|
|
@@ -99,13 +97,13 @@ var InterfacePageGenerator = class {
|
|
|
99
97
|
if (callSignatures.length > 0) {
|
|
100
98
|
content += `## Call Signatures\n\n`;
|
|
101
99
|
for (const callSig of callSignatures) {
|
|
102
|
-
const callSigSummary =
|
|
100
|
+
const callSigSummary = Tsdoc.summary(callSig);
|
|
103
101
|
const callSigId = sanitizeId("call-signature");
|
|
104
102
|
const callSigItem = callSig;
|
|
105
103
|
if (callSigItem.excerpt?.text) {
|
|
106
|
-
const memberSignature =
|
|
104
|
+
const memberSignature = Signature.format(callSigItem.excerpt).trim();
|
|
107
105
|
const skeletonWithContext = this.generateInterfaceMemberWithContext(apiInterface, callSig, packageName);
|
|
108
|
-
const summaryMd = callSigSummary ? escapeMdxGenerics(
|
|
106
|
+
const summaryMd = callSigSummary ? escapeMdxGenerics(linkProse(callSigSummary)) : void 0;
|
|
109
107
|
content += `<ApiMember code={${JSON.stringify(memberSignature)}} source={${JSON.stringify(skeletonWithContext)}} apiScope={${JSON.stringify(apiScope)}} memberName="Call Signature"${summaryMd ? ` summary={${JSON.stringify(summaryMd)}}` : ""} id={${JSON.stringify(callSigId)}} />\n\n`;
|
|
110
108
|
}
|
|
111
109
|
}
|
|
@@ -114,13 +112,13 @@ var InterfacePageGenerator = class {
|
|
|
114
112
|
if (constructSignatures.length > 0) {
|
|
115
113
|
content += `## Construct Signatures\n\n`;
|
|
116
114
|
for (const constructSig of constructSignatures) {
|
|
117
|
-
const constructSigSummary =
|
|
115
|
+
const constructSigSummary = Tsdoc.summary(constructSig);
|
|
118
116
|
const constructSigId = sanitizeId("construct-signature");
|
|
119
117
|
const constructSigItem = constructSig;
|
|
120
118
|
if (constructSigItem.excerpt?.text) {
|
|
121
|
-
const memberSignature =
|
|
119
|
+
const memberSignature = Signature.format(constructSigItem.excerpt).trim();
|
|
122
120
|
const skeletonWithContext = this.generateInterfaceMemberWithContext(apiInterface, constructSig, packageName);
|
|
123
|
-
const summaryMd = constructSigSummary ? escapeMdxGenerics(
|
|
121
|
+
const summaryMd = constructSigSummary ? escapeMdxGenerics(linkProse(constructSigSummary)) : void 0;
|
|
124
122
|
content += `<ApiMember code={${JSON.stringify(memberSignature)}} source={${JSON.stringify(skeletonWithContext)}} apiScope={${JSON.stringify(apiScope)}} memberName="Construct Signature"${summaryMd ? ` summary={${JSON.stringify(summaryMd)}}` : ""} id={${JSON.stringify(constructSigId)}} />\n\n`;
|
|
125
123
|
}
|
|
126
124
|
}
|
|
@@ -129,13 +127,13 @@ var InterfacePageGenerator = class {
|
|
|
129
127
|
if (indexSignatures.length > 0) {
|
|
130
128
|
content += `## Index Signature\n\n`;
|
|
131
129
|
for (const indexSig of indexSignatures) {
|
|
132
|
-
const indexSigSummary =
|
|
130
|
+
const indexSigSummary = Tsdoc.summary(indexSig);
|
|
133
131
|
const indexSigId = sanitizeId("index-signature");
|
|
134
132
|
const indexSigItem = indexSig;
|
|
135
133
|
if (indexSigItem.excerpt?.text) {
|
|
136
|
-
const memberSignature =
|
|
134
|
+
const memberSignature = Signature.format(indexSigItem.excerpt).trim();
|
|
137
135
|
const skeletonWithContext = this.generateInterfaceMemberWithContext(apiInterface, indexSig, packageName);
|
|
138
|
-
const summaryMd = indexSigSummary ? escapeMdxGenerics(
|
|
136
|
+
const summaryMd = indexSigSummary ? escapeMdxGenerics(linkProse(indexSigSummary)) : void 0;
|
|
139
137
|
content += `<ApiMember code={${JSON.stringify(memberSignature)}} source={${JSON.stringify(skeletonWithContext)}} apiScope={${JSON.stringify(apiScope)}} memberName="Index Signature"${summaryMd ? ` summary={${JSON.stringify(summaryMd)}}` : ""} id={${JSON.stringify(indexSigId)}} />\n\n`;
|
|
140
138
|
}
|
|
141
139
|
}
|
|
@@ -144,13 +142,13 @@ var InterfacePageGenerator = class {
|
|
|
144
142
|
if (properties.length > 0) {
|
|
145
143
|
content += `## Properties\n\n`;
|
|
146
144
|
for (const prop of properties) {
|
|
147
|
-
const propSummary =
|
|
145
|
+
const propSummary = Tsdoc.summary(prop);
|
|
148
146
|
const propId = sanitizeId(prop.displayName);
|
|
149
147
|
const propItem = prop;
|
|
150
148
|
if (propItem.excerpt?.text) {
|
|
151
|
-
const memberSignature =
|
|
149
|
+
const memberSignature = Signature.format(propItem.excerpt).trim();
|
|
152
150
|
const skeletonWithContext = this.generateInterfaceMemberWithContext(apiInterface, prop, packageName);
|
|
153
|
-
const summaryMd = propSummary ? escapeMdxGenerics(
|
|
151
|
+
const summaryMd = propSummary ? escapeMdxGenerics(linkProse(propSummary)) : void 0;
|
|
154
152
|
content += `<ApiMember code={${JSON.stringify(memberSignature)}} source={${JSON.stringify(skeletonWithContext)}} apiScope={${JSON.stringify(apiScope)}} memberName={${JSON.stringify(prop.displayName)}}${summaryMd ? ` summary={${JSON.stringify(summaryMd)}}` : ""} id={${JSON.stringify(propId)}} />\n\n`;
|
|
155
153
|
}
|
|
156
154
|
}
|
|
@@ -159,30 +157,30 @@ var InterfacePageGenerator = class {
|
|
|
159
157
|
if (methods.length > 0) {
|
|
160
158
|
content += `## Methods\n\n`;
|
|
161
159
|
for (const method of methods) {
|
|
162
|
-
const methodSummary =
|
|
160
|
+
const methodSummary = Tsdoc.summary(method);
|
|
163
161
|
const methodId = sanitizeId(method.displayName);
|
|
164
162
|
const methodItem = method;
|
|
165
163
|
if (methodItem.excerpt?.text) {
|
|
166
|
-
const memberSignature =
|
|
164
|
+
const memberSignature = Signature.format(methodItem.excerpt).trim();
|
|
167
165
|
const skeletonWithContext = this.generateInterfaceMemberWithContext(apiInterface, method, packageName);
|
|
168
|
-
const hasParameters =
|
|
169
|
-
const summaryMd = methodSummary ? escapeMdxGenerics(
|
|
166
|
+
const hasParameters = Tsdoc.params(method).length > 0;
|
|
167
|
+
const summaryMd = methodSummary ? escapeMdxGenerics(linkProse(methodSummary)) : void 0;
|
|
170
168
|
content += `<ApiMember code={${JSON.stringify(memberSignature)}} source={${JSON.stringify(skeletonWithContext)}} apiScope={${JSON.stringify(apiScope)}} memberName={${JSON.stringify(method.displayName)}}${summaryMd ? ` summary={${JSON.stringify(summaryMd)}}` : ""} id={${JSON.stringify(methodId)}} hasParameters={${hasParameters}} />\n\n`;
|
|
171
169
|
}
|
|
172
|
-
const params =
|
|
170
|
+
const params = Tsdoc.params(method);
|
|
173
171
|
if (params.length > 0) content += `<ParametersTable parameters={${JSON.stringify(params.map((p) => ({
|
|
174
172
|
name: p.name,
|
|
175
173
|
type: p.type,
|
|
176
|
-
description:
|
|
174
|
+
description: linkProse(p.description)
|
|
177
175
|
})))}} />\n\n`;
|
|
178
|
-
const returns =
|
|
176
|
+
const returns = Tsdoc.returns(method);
|
|
179
177
|
if (returns) {
|
|
180
|
-
const description = escapeMdxGenerics(
|
|
178
|
+
const description = escapeMdxGenerics(linkProse(returns.description));
|
|
181
179
|
content += `**Returns:** ${description}\n\n`;
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
|
-
const examples =
|
|
183
|
+
const examples = Tsdoc.examples(apiInterface);
|
|
186
184
|
if (examples.length > 0) {
|
|
187
185
|
content += `## Examples\n\n`;
|
|
188
186
|
for (const example of examples) {
|
|
@@ -197,11 +195,11 @@ var InterfacePageGenerator = class {
|
|
|
197
195
|
} else content += `\`\`\`${prepared.language}\n${formattedCode}\n\`\`\`\n\n`;
|
|
198
196
|
}
|
|
199
197
|
}
|
|
200
|
-
const seeReferences =
|
|
198
|
+
const seeReferences = Tsdoc.seeReferences(apiInterface);
|
|
201
199
|
if (seeReferences.length > 0) {
|
|
202
200
|
content += `## See Also\n\n`;
|
|
203
201
|
for (const reference of seeReferences) {
|
|
204
|
-
const refText = escapeMdxGenerics(
|
|
202
|
+
const refText = escapeMdxGenerics(linkProse(reference.text));
|
|
205
203
|
content += `- ${refText}\n`;
|
|
206
204
|
}
|
|
207
205
|
content += `\n`;
|
|
@@ -218,7 +216,7 @@ var InterfacePageGenerator = class {
|
|
|
218
216
|
*/
|
|
219
217
|
generateInterfaceMemberWithContext(apiInterface, targetMember, packageName) {
|
|
220
218
|
const interfaceName = apiInterface.displayName;
|
|
221
|
-
const inheritance =
|
|
219
|
+
const inheritance = ApiItems.inheritance(apiInterface);
|
|
222
220
|
let declaration = `interface ${interfaceName}`;
|
|
223
221
|
if (apiInterface.typeParameters && apiInterface.typeParameters.length > 0) {
|
|
224
222
|
const typeParams = apiInterface.typeParameters.map((tp) => tp.name).join(", ");
|
|
@@ -227,7 +225,7 @@ var InterfacePageGenerator = class {
|
|
|
227
225
|
if (inheritance.extends && inheritance.extends.length > 0) declaration += ` extends ${inheritance.extends.join(", ")}`;
|
|
228
226
|
declaration += " {";
|
|
229
227
|
const memberItem = targetMember;
|
|
230
|
-
const memberSignature = memberItem.excerpt?.text ?
|
|
228
|
+
const memberSignature = memberItem.excerpt?.text ? Signature.format(memberItem.excerpt).trim() : "";
|
|
231
229
|
const skeleton = `${declaration}\n${memberSignature}\n}`;
|
|
232
230
|
const apiPackage = apiInterface.getAssociatedPackage?.();
|
|
233
231
|
if (apiPackage) {
|
|
@@ -255,7 +253,7 @@ var InterfacePageGenerator = class {
|
|
|
255
253
|
generateInterfaceSkeleton(apiInterface) {
|
|
256
254
|
const lines = [];
|
|
257
255
|
const interfaceName = apiInterface.displayName;
|
|
258
|
-
const inheritance =
|
|
256
|
+
const inheritance = ApiItems.inheritance(apiInterface);
|
|
259
257
|
let declaration = `interface ${interfaceName}`;
|
|
260
258
|
if (apiInterface.typeParameters && apiInterface.typeParameters.length > 0) {
|
|
261
259
|
const typeParams = apiInterface.typeParameters.map((tp) => tp.name).join(", ");
|
|
@@ -268,7 +266,7 @@ var InterfacePageGenerator = class {
|
|
|
268
266
|
if (callSignatures.length > 0) for (const callSig of callSignatures) {
|
|
269
267
|
const callSigItem = callSig;
|
|
270
268
|
if (callSigItem.excerpt?.text) {
|
|
271
|
-
const signature =
|
|
269
|
+
const signature = Signature.format(callSigItem.excerpt).trim();
|
|
272
270
|
lines.push(` ${signature}`);
|
|
273
271
|
}
|
|
274
272
|
}
|
|
@@ -276,7 +274,7 @@ var InterfacePageGenerator = class {
|
|
|
276
274
|
if (constructSignatures.length > 0) for (const constructSig of constructSignatures) {
|
|
277
275
|
const constructSigItem = constructSig;
|
|
278
276
|
if (constructSigItem.excerpt?.text) {
|
|
279
|
-
const signature =
|
|
277
|
+
const signature = Signature.format(constructSigItem.excerpt).trim();
|
|
280
278
|
lines.push(` ${signature}`);
|
|
281
279
|
}
|
|
282
280
|
}
|
|
@@ -284,7 +282,7 @@ var InterfacePageGenerator = class {
|
|
|
284
282
|
if (indexSignatures.length > 0) for (const indexSig of indexSignatures) {
|
|
285
283
|
const indexSigItem = indexSig;
|
|
286
284
|
if (indexSigItem.excerpt?.text) {
|
|
287
|
-
const signature =
|
|
285
|
+
const signature = Signature.format(indexSigItem.excerpt).trim();
|
|
288
286
|
lines.push(` ${signature}`);
|
|
289
287
|
}
|
|
290
288
|
}
|
|
@@ -292,7 +290,7 @@ var InterfacePageGenerator = class {
|
|
|
292
290
|
if (properties.length > 0) for (const prop of properties) {
|
|
293
291
|
const propItem = prop;
|
|
294
292
|
if (propItem.excerpt?.text) {
|
|
295
|
-
const signature =
|
|
293
|
+
const signature = Signature.format(propItem.excerpt).trim();
|
|
296
294
|
lines.push(` ${signature}`);
|
|
297
295
|
}
|
|
298
296
|
}
|
|
@@ -300,7 +298,7 @@ var InterfacePageGenerator = class {
|
|
|
300
298
|
if (methods.length > 0) for (const method of methods) {
|
|
301
299
|
const methodItem = method;
|
|
302
300
|
if (methodItem.excerpt?.text) {
|
|
303
|
-
const signature =
|
|
301
|
+
const signature = Signature.format(methodItem.excerpt).trim();
|
|
304
302
|
lines.push(` ${signature}`);
|
|
305
303
|
}
|
|
306
304
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ApiParser } from "../../loader.js";
|
|
2
1
|
import { TypeReferenceExtractor } from "../../type-reference-extractor.js";
|
|
3
2
|
import { escapeMdxGenerics, formatExampleCode, generateAvailableFrom, generateFrontmatter, prepareExampleCode, prependHiddenImports, stripTwoslashDirectives } from "../helpers.js";
|
|
4
|
-
import {
|
|
5
|
-
import { TypeSignatureFormatter } from "../../formatter.js";
|
|
3
|
+
import { linkProse } from "../prose-linker.js";
|
|
6
4
|
import { ApiItemKind } from "@microsoft/api-extractor-model";
|
|
5
|
+
import { ApiItems, Signature, Tsdoc } from "@tsdoctor/model";
|
|
7
6
|
|
|
8
7
|
//#region src/markdown/page-generators/namespace-page.ts
|
|
9
8
|
/**
|
|
@@ -28,9 +27,9 @@ import { ApiItemKind } from "@microsoft/api-extractor-model";
|
|
|
28
27
|
*
|
|
29
28
|
* **Relationships:**
|
|
30
29
|
* - Created and invoked by {@link ApiExtractorPlugin} during page generation
|
|
31
|
-
* - Uses
|
|
32
|
-
* - Uses
|
|
33
|
-
* - Uses
|
|
30
|
+
* - Uses `Signature.format` from `@tsdoctor/model` for formatting type signatures
|
|
31
|
+
* - Uses the `Tsdoc` / `ApiItems` modules from `@tsdoctor/model` for extracting documentation
|
|
32
|
+
* - Uses the per-build prose linker (`linkProse`) for adding type reference links
|
|
34
33
|
*
|
|
35
34
|
* @example
|
|
36
35
|
* ```ts
|
|
@@ -52,7 +51,6 @@ import { ApiItemKind } from "@microsoft/api-extractor-model";
|
|
|
52
51
|
* @see {@link InterfacePageGenerator} for interface documentation
|
|
53
52
|
*/
|
|
54
53
|
var NamespacePageGenerator = class {
|
|
55
|
-
typeFormatter = new TypeSignatureFormatter();
|
|
56
54
|
/**
|
|
57
55
|
* Generate a markdown page for a namespace
|
|
58
56
|
*
|
|
@@ -61,21 +59,21 @@ var NamespacePageGenerator = class {
|
|
|
61
59
|
async generate(apiNamespace, baseRoute, packageName, singularName, apiScope, apiName, sourceConfig, suppressExampleErrors, llmsPlugin, availableFrom) {
|
|
62
60
|
const shouldSuppressErrors = suppressExampleErrors ?? true;
|
|
63
61
|
const name = apiNamespace.displayName;
|
|
64
|
-
const summary =
|
|
65
|
-
const releaseTag =
|
|
62
|
+
const summary = Tsdoc.summary(apiNamespace) || "No description available.";
|
|
63
|
+
const releaseTag = Tsdoc.releaseTag(apiNamespace);
|
|
66
64
|
let content = generateFrontmatter(name, summary, singularName, apiName);
|
|
67
65
|
content += `import { SourceCode } from "@rspress/core/theme";\n`;
|
|
68
66
|
content += `import { ApiSignature, ApiExample } from "rspress-plugin-api-extractor/runtime";\n\n`;
|
|
69
67
|
content += `# ${name}\n\n`;
|
|
70
|
-
const deprecation =
|
|
68
|
+
const deprecation = Tsdoc.deprecation(apiNamespace);
|
|
71
69
|
if (deprecation) {
|
|
72
|
-
const message = escapeMdxGenerics(
|
|
70
|
+
const message = escapeMdxGenerics(linkProse(deprecation.message));
|
|
73
71
|
content += `> **Deprecated:** ${message}\n\n`;
|
|
74
72
|
}
|
|
75
73
|
if (releaseTag !== "Public") content += `\`${releaseTag}\`\n\n`;
|
|
76
74
|
content += `${summary}\n\n`;
|
|
77
75
|
content += generateAvailableFrom(packageName, availableFrom);
|
|
78
|
-
const sourceLink =
|
|
76
|
+
const sourceLink = ApiItems.sourceLink(apiNamespace, sourceConfig);
|
|
79
77
|
if (sourceLink) {
|
|
80
78
|
content += `<div className="api-docs-toolbar">\n`;
|
|
81
79
|
content += ` <div className="api-docs-toolbar-left">\n`;
|
|
@@ -98,7 +96,7 @@ var NamespacePageGenerator = class {
|
|
|
98
96
|
content += this.renderMemberSection("Types", grouped.typeAliases, baseRoute, "type", name);
|
|
99
97
|
content += this.renderMemberSection("Enums", grouped.enums, baseRoute, "enum", name);
|
|
100
98
|
content += this.renderMemberSection("Namespaces", grouped.namespaces, baseRoute, "namespace", name);
|
|
101
|
-
const examples =
|
|
99
|
+
const examples = Tsdoc.examples(apiNamespace);
|
|
102
100
|
if (examples.length > 0) {
|
|
103
101
|
content += `## Examples\n\n`;
|
|
104
102
|
for (const example of examples) {
|
|
@@ -113,11 +111,11 @@ var NamespacePageGenerator = class {
|
|
|
113
111
|
} else content += `\`\`\`${prepared.language}\n${formattedCode}\n\`\`\`\n\n`;
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
|
-
const seeReferences =
|
|
114
|
+
const seeReferences = Tsdoc.seeReferences(apiNamespace);
|
|
117
115
|
if (seeReferences.length > 0) {
|
|
118
116
|
content += `## See Also\n\n`;
|
|
119
117
|
for (const reference of seeReferences) {
|
|
120
|
-
const refText = escapeMdxGenerics(
|
|
118
|
+
const refText = escapeMdxGenerics(linkProse(reference.text));
|
|
121
119
|
content += `- ${refText}\n`;
|
|
122
120
|
}
|
|
123
121
|
content += `\n`;
|
|
@@ -182,10 +180,10 @@ var NamespacePageGenerator = class {
|
|
|
182
180
|
let section = `## ${title}\n\n`;
|
|
183
181
|
for (const member of members) {
|
|
184
182
|
const memberName = member.displayName;
|
|
185
|
-
const memberSummary =
|
|
183
|
+
const memberSummary = Tsdoc.summary(member);
|
|
186
184
|
const memberRoute = `${baseRoute}/${categoryFolder}/${`${namespaceName}.${memberName}`.toLowerCase()}`;
|
|
187
185
|
if (memberSummary) {
|
|
188
|
-
const escapedSummary = escapeMdxGenerics(
|
|
186
|
+
const escapedSummary = escapeMdxGenerics(linkProse(memberSummary));
|
|
189
187
|
section += `- [${memberName}](${memberRoute}) - ${escapedSummary}\n`;
|
|
190
188
|
} else section += `- [${memberName}](${memberRoute})\n`;
|
|
191
189
|
}
|
|
@@ -216,49 +214,49 @@ var NamespacePageGenerator = class {
|
|
|
216
214
|
for (const cls of grouped.classes) {
|
|
217
215
|
const clsItem = cls;
|
|
218
216
|
if (clsItem.excerpt?.text) {
|
|
219
|
-
const signature =
|
|
217
|
+
const signature = Signature.format(clsItem.excerpt).trim();
|
|
220
218
|
lines.push(` ${this.abbreviateDeclaration(signature, "class")} { }`);
|
|
221
219
|
}
|
|
222
220
|
}
|
|
223
221
|
for (const iface of grouped.interfaces) {
|
|
224
222
|
const ifaceItem = iface;
|
|
225
223
|
if (ifaceItem.excerpt?.text) {
|
|
226
|
-
const signature =
|
|
224
|
+
const signature = Signature.format(ifaceItem.excerpt).trim();
|
|
227
225
|
lines.push(` ${this.abbreviateDeclaration(signature, "interface")} { }`);
|
|
228
226
|
}
|
|
229
227
|
}
|
|
230
228
|
for (const func of grouped.functions) {
|
|
231
229
|
const funcItem = func;
|
|
232
230
|
if (funcItem.excerpt?.text) {
|
|
233
|
-
const signature =
|
|
231
|
+
const signature = Signature.format(funcItem.excerpt).trim();
|
|
234
232
|
lines.push(` ${signature}`);
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
for (const variable of grouped.variables) {
|
|
238
236
|
const varItem = variable;
|
|
239
237
|
if (varItem.excerpt?.text) {
|
|
240
|
-
const signature =
|
|
238
|
+
const signature = Signature.format(varItem.excerpt).trim();
|
|
241
239
|
lines.push(` ${signature}`);
|
|
242
240
|
}
|
|
243
241
|
}
|
|
244
242
|
for (const typeAlias of grouped.typeAliases) {
|
|
245
243
|
const typeItem = typeAlias;
|
|
246
244
|
if (typeItem.excerpt?.text) {
|
|
247
|
-
const signature =
|
|
245
|
+
const signature = Signature.format(typeItem.excerpt).trim();
|
|
248
246
|
lines.push(` ${signature}`);
|
|
249
247
|
}
|
|
250
248
|
}
|
|
251
249
|
for (const enumItem of grouped.enums) {
|
|
252
250
|
const enumDeclItem = enumItem;
|
|
253
251
|
if (enumDeclItem.excerpt?.text) {
|
|
254
|
-
const signature =
|
|
252
|
+
const signature = Signature.format(enumDeclItem.excerpt).trim();
|
|
255
253
|
lines.push(` ${this.abbreviateDeclaration(signature, "enum")} { }`);
|
|
256
254
|
}
|
|
257
255
|
}
|
|
258
256
|
for (const ns of grouped.namespaces) {
|
|
259
257
|
const nsItem = ns;
|
|
260
258
|
if (nsItem.excerpt?.text) {
|
|
261
|
-
const signature =
|
|
259
|
+
const signature = Signature.format(nsItem.excerpt).trim();
|
|
262
260
|
lines.push(` ${this.abbreviateDeclaration(signature, "namespace")} { }`);
|
|
263
261
|
}
|
|
264
262
|
}
|