aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-03-01 21:00:25 +0100
committerGitHub <[email protected]>2022-03-01 21:00:25 +0100
commit102ff9f5c4b80ff65b3ed7f5ed7ac6097faea98e (patch)
treeb153b03ecb840feb1365eb3ee9e89b0b312fe87e
parent54520277ccd732080b950a5083694073c2459995 (diff)
downloadfaker-102ff9f5c4b80ff65b3ed7f5ed7ac6097faea98e.tar.xz
faker-102ff9f5c4b80ff65b3ed7f5ed7ac6097faea98e.zip
docs: add toc and hide edit link (#571)
-rw-r--r--scripts/apidoc/apiDocsWriter.ts17
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/apidoc/apiDocsWriter.ts b/scripts/apidoc/apiDocsWriter.ts
index e2b42816..1282ad4c 100644
--- a/scripts/apidoc/apiDocsWriter.ts
+++ b/scripts/apidoc/apiDocsWriter.ts
@@ -11,6 +11,13 @@ const pathDocsApiPages = resolve(pathDocsDir, '.vitepress', 'api-pages.mjs');
const scriptCommand = 'pnpm run generate:api-docs';
+// Moved here because this must not be formatted by prettier
+const vitePressInFileOptions = `---
+editLink: false
+---
+
+`;
+
const prettierMarkdown: Options = {
...prettierConfig,
parser: 'markdown',
@@ -59,10 +66,16 @@ export function writeApiDocsModulePage(
:::
+ <ul>
+ <li v-for="method of methods" :key="method.name">
+ <a :href="'#' + method.name">{{ method.title }}</a>
+ </li>
+ </ul>
+
<ApiDocsMethod v-for="method of methods" :key="method.name" :method="method" v-once />
`.replace(/\n +/g, '\n');
- content = format(content, prettierMarkdown);
+ content = vitePressInFileOptions + format(content, prettierMarkdown);
writeFileSync(resolve(pathOutputDir, lowerModuleName + '.md'), content);
}
@@ -85,7 +98,7 @@ export function writeApiDocsDirectPage(methodName: string): void {
<ApiDocsMethod v-for="method of methods" :key="method.name" :method="method" v-once />
`.replace(/\n +/g, '\n');
- content = format(content, prettierMarkdown);
+ content = vitePressInFileOptions + format(content, prettierMarkdown);
writeFileSync(resolve(pathOutputDir, methodName + '.md'), content);
}