Skip to content

Commit 2bb73c4

Browse files
committed
docs: add toc and hide edit link
1 parent 4230cfc commit 2bb73c4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts/apidoc/apiDocsWriter.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ const pathDocsApiPages = resolve(pathDocsDir, '.vitepress', 'api-pages.mjs');
1111

1212
const scriptCommand = 'pnpm run generate:api-docs';
1313

14+
// Moved here because this must not be formatted by prettier
15+
const vitePressInFileOptions = `---
16+
editLink: false
17+
---
18+
19+
`;
20+
1421
const prettierMarkdown: Options = {
1522
...prettierConfig,
1623
parser: 'markdown',
@@ -59,10 +66,16 @@ export function writeApiDocsModulePage(
5966
6067
:::
6168
69+
<ul>
70+
<li v-for="method of methods" :key="method.name">
71+
<a :href="'#' + method.name">{{ method.title }}</a>
72+
</li>
73+
</ul>
74+
6275
<ApiDocsMethod v-for="method of methods" :key="method.name" :method="method" v-once />
6376
`.replace(/\n +/g, '\n');
6477

65-
content = format(content, prettierMarkdown);
78+
content = vitePressInFileOptions + format(content, prettierMarkdown);
6679

6780
writeFileSync(resolve(pathOutputDir, lowerModuleName + '.md'), content);
6881
}
@@ -85,7 +98,7 @@ export function writeApiDocsDirectPage(methodName: string): void {
8598
<ApiDocsMethod v-for="method of methods" :key="method.name" :method="method" v-once />
8699
`.replace(/\n +/g, '\n');
87100

88-
content = format(content, prettierMarkdown);
101+
content = vitePressInFileOptions + format(content, prettierMarkdown);
89102

90103
writeFileSync(resolve(pathOutputDir, methodName + '.md'), content);
91104
}

0 commit comments

Comments
 (0)