aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/.vitepress/components/api-docs/method.vue2
-rw-r--r--docs/api/.gitignore2
-rw-r--r--scripts/apidoc/apiDocsWriter.ts74
-rw-r--r--scripts/apidoc/directMethods.ts8
-rw-r--r--scripts/apidoc/moduleMethods.ts7
5 files changed, 52 insertions, 41 deletions
diff --git a/docs/.vitepress/components/api-docs/method.vue b/docs/.vitepress/components/api-docs/method.vue
index a5c8586a..83e29aca 100644
--- a/docs/.vitepress/components/api-docs/method.vue
+++ b/docs/.vitepress/components/api-docs/method.vue
@@ -12,8 +12,6 @@ function seeAlsoToUrl(see: string): string {
<template>
<div>
- <h2 :id="props.method.name">{{ props.method.title }}</h2>
-
<div v-if="props.method.deprecated" class="warning custom-block">
<p class="custom-block-title">Deprecated</p>
<p>This method is deprecated and will be removed in a future version.</p>
diff --git a/docs/api/.gitignore b/docs/api/.gitignore
index 0b938bbe..3d5066c5 100644
--- a/docs/api/.gitignore
+++ b/docs/api/.gitignore
@@ -1,3 +1,3 @@
*.md
!localization.md
-*.ts
+*.json
diff --git a/scripts/apidoc/apiDocsWriter.ts b/scripts/apidoc/apiDocsWriter.ts
index cb803499..76edc3c3 100644
--- a/scripts/apidoc/apiDocsWriter.ts
+++ b/scripts/apidoc/apiDocsWriter.ts
@@ -26,40 +26,41 @@ editLink: false
* @param moduleName The name of the module to write the docs for.
* @param lowerModuleName The lowercase name of the module.
* @param comment The module comments.
+ * @param methods The methods of the module.
*/
export function writeApiDocsModulePage(
moduleName: string,
lowerModuleName: string,
- comment: string
+ comment: string,
+ methods: Method[]
): void {
// Write api docs page
let content = `
<script setup>
- import ApiDocsMethod from '../.vitepress/components/api-docs/method.vue'
- import { ${lowerModuleName} } from './${lowerModuleName}'
- import { ref } from 'vue';
-
- const methods = ref(${lowerModuleName});
+ import ApiDocsMethod from '../.vitepress/components/api-docs/method.vue';
+ import ${lowerModuleName} from './${lowerModuleName}.json';
</script>
- # ${moduleName}
-
<!-- This file is automatically generated. -->
<!-- Run '${scriptCommand}' to update -->
+ # ${moduleName}
+
::: v-pre
${comment}
:::
- <ul>
- <li v-for="method of methods" :key="method.name">
- <a :href="'#' + method.name">{{ method.title }}</a>
- </li>
- </ul>
+ ${methods
+ .map(
+ (method) => `
+ ## ${method.name}
- <ApiDocsMethod v-for="method of methods" :key="method.name" :method="method" v-once />
+ <ApiDocsMethod :method="${lowerModuleName}.${method.name}" v-once />
+ `
+ )
+ .join('')}
`.replace(/\n +/g, '\n');
content = vitePressInFileOptions + formatMarkdown(content);
@@ -71,18 +72,26 @@ export function writeApiDocsModulePage(
* Writes the api page for the given method to the correct location.
*
* @param methodName The name of the method to write the docs for.
+ * @param capitalizedMethodName The capitalized name of the method.
*/
-export function writeApiDocsDirectPage(methodName: string): void {
+export function writeApiDocsDirectPage(
+ methodName: string,
+ capitalizedMethodName: string
+): void {
let content = `
<script setup>
- import ApiDocsMethod from '../.vitepress/components/api-docs/method.vue'
- import { ${methodName} } from './${methodName}'
- import { ref } from 'vue';
-
- const methods = ref(${methodName});
+ import ApiDocsMethod from '../.vitepress/components/api-docs/method.vue';
+ import ${methodName} from './${methodName}.json';
</script>
- <ApiDocsMethod v-for="method of methods" :key="method.name" :method="method" v-once />
+ <!-- This file is automatically generated. -->
+ <!-- Run '${scriptCommand}' to update -->
+
+ # ${capitalizedMethodName}
+
+ ## ${methodName}
+
+ <ApiDocsMethod :method="${methodName}.${methodName}" v-once />
`.replace(/\n +/g, '\n');
content = vitePressInFileOptions + formatMarkdown(content);
@@ -100,18 +109,17 @@ export function writeApiDocsData(
lowerModuleName: string,
methods: Method[]
): void {
- let contentTs = `
-import type { Method } from '../.vitepress/components/api-docs/method';
-
-export const ${lowerModuleName}: Method[] = ${JSON.stringify(
- methods,
- null,
- 2
- )}`;
-
- contentTs = formatTypescript(contentTs);
-
- writeFileSync(resolve(pathOutputDir, `${lowerModuleName}.ts`), contentTs);
+ const content = JSON.stringify(
+ methods.reduce<Record<string, Method>>(
+ (map, method) => ({
+ ...map,
+ [method.name]: method,
+ }),
+ {}
+ )
+ );
+
+ writeFileSync(resolve(pathOutputDir, `${lowerModuleName}.json`), content);
}
/**
diff --git a/scripts/apidoc/directMethods.ts b/scripts/apidoc/directMethods.ts
index 159ad848..fbdd094e 100644
--- a/scripts/apidoc/directMethods.ts
+++ b/scripts/apidoc/directMethods.ts
@@ -37,21 +37,21 @@ export function processDirectMethod(
direct: TypeDoc.DeclarationReflection
): Page {
const methodName = direct.name;
- const upperMethodName =
+ const capitalizedMethodName =
methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
- console.log(`Processing Direct: ${upperMethodName}`);
+ console.log(`Processing Direct: ${capitalizedMethodName}`);
const signatures = (direct.type as TypeDoc.ReflectionType).declaration
.signatures;
const signature = signatures[signatures.length - 1];
- writeApiDocsDirectPage(methodName);
+ writeApiDocsDirectPage(methodName, capitalizedMethodName);
writeApiDocsData(methodName, [
analyzeSignature(signature, undefined, methodName),
]);
return {
- text: upperMethodName,
+ text: capitalizedMethodName,
link: `/api/${methodName}.html`,
};
}
diff --git a/scripts/apidoc/moduleMethods.ts b/scripts/apidoc/moduleMethods.ts
index 3d81c2db..64f6ed1b 100644
--- a/scripts/apidoc/moduleMethods.ts
+++ b/scripts/apidoc/moduleMethods.ts
@@ -56,7 +56,12 @@ function processModuleMethod(module: TypeDoc.DeclarationReflection): PageIndex {
methods.push(analyzeSignature(signature, lowerModuleName, methodName));
}
- writeApiDocsModulePage(moduleName, lowerModuleName, toBlock(module.comment));
+ writeApiDocsModulePage(
+ moduleName,
+ lowerModuleName,
+ toBlock(module.comment),
+ methods
+ );
writeApiDocsData(lowerModuleName, methods);
return [