aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-10-15 03:29:21 +0800
committerGitHub <[email protected]>2022-10-14 21:29:21 +0200
commit9c1437d6034ef5537c079746761c4c71347f768b (patch)
tree0a20ebb6b8e2501f15208600b58e5bfc587bbff3 /scripts
parent1ab33c5caf323d25bd21b3b3afaf8af3686207b4 (diff)
downloadfaker-9c1437d6034ef5537c079746761c4c71347f768b.tar.xz
faker-9c1437d6034ef5537c079746761c4c71347f768b.zip
refactor!: cleanup deprecations (#1440)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/apidoc.ts2
-rw-r--r--scripts/apidoc/apiDocsWriter.ts35
-rw-r--r--scripts/apidoc/directMethods.ts68
3 files changed, 1 insertions, 104 deletions
diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts
index 0ad01248..921859e7 100644
--- a/scripts/apidoc.ts
+++ b/scripts/apidoc.ts
@@ -3,7 +3,6 @@ import {
writeApiPagesIndex,
writeApiSearchIndex,
} from './apidoc/apiDocsWriter';
-import { processDirectMethods } from './apidoc/directMethods';
import { processModuleMethods } from './apidoc/moduleMethods';
import { initMarkdownRenderer } from './apidoc/signature';
import type { PageIndex } from './apidoc/utils';
@@ -35,7 +34,6 @@ async function build(): Promise<void> {
const modulesPages: PageIndex = [];
modulesPages.push(...processModuleMethods(project));
- modulesPages.push(...processDirectMethods(project));
writeApiPagesIndex(modulesPages);
writeApiSearchIndex(project);
diff --git a/scripts/apidoc/apiDocsWriter.ts b/scripts/apidoc/apiDocsWriter.ts
index 74caa425..1f0709bb 100644
--- a/scripts/apidoc/apiDocsWriter.ts
+++ b/scripts/apidoc/apiDocsWriter.ts
@@ -4,7 +4,6 @@ import type { ProjectReflection } from 'typedoc';
import { ReflectionKind } from 'typedoc';
import type { Method } from '../../docs/.vitepress/components/api-docs/method';
import type { APIGroup, APIItem } from '../../docs/api/api-types';
-import { selectDirectMethods } from './directMethods';
import { extractModuleName, selectApiModules } from './moduleMethods';
import type { PageIndex } from './utils';
import {
@@ -79,37 +78,6 @@ 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,
- capitalizedMethodName: string
-): void {
- let content = `
- <script setup>
- import ApiDocsMethod from '../.vitepress/components/api-docs/method.vue';
- import ${methodName} from './${methodName}.json';
- </script>
-
- <!-- 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);
-
- writeFileSync(resolve(pathOutputDir, `${methodName}.md`), content);
-}
-
-/**
* Writes the api docs data to correct location.
*
* @param lowerModuleName The lowercase name of the module.
@@ -164,9 +132,8 @@ export function writeApiSearchIndex(project: ProjectReflection): void {
apiIndex.push(moduleApiSection);
const apiModules = selectApiModules(project);
- const directMethods = selectDirectMethods(project);
- moduleApiSection.items = [...apiModules, ...directMethods]
+ moduleApiSection.items = apiModules
.map((module) => {
const moduleName = extractModuleName(module);
const apiSection: APIItem = {
diff --git a/scripts/apidoc/directMethods.ts b/scripts/apidoc/directMethods.ts
deleted file mode 100644
index f8268f5c..00000000
--- a/scripts/apidoc/directMethods.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import type {
- DeclarationReflection,
- ProjectReflection,
- ReflectionType,
-} from 'typedoc';
-import { ReflectionKind } from 'typedoc';
-import { writeApiDocsData, writeApiDocsDirectPage } from './apiDocsWriter';
-import { analyzeSignature } from './signature';
-import type { Page, PageIndex } from './utils';
-
-/**
- * Selects the direct methods from the project that needs to be documented.
- *
- * @param project The project used to extract the direct methods.
- * @returns The direct methods to document.
- */
-export function selectDirectMethods(
- project: ProjectReflection
-): DeclarationReflection[] {
- return project
- .getChildrenByKind(ReflectionKind.Class)
- .filter((ref) => ref.name === 'Faker')[0]
- .getChildrenByKind(ReflectionKind.Property)
- .filter((ref) => ['fake', 'unique'].includes(ref.name));
-}
-
-/**
- * Analyzes and writes the documentation for direct methods such as `faker.fake()`.
- *
- * @param project The project used to extract the direct methods.
- * @returns The generated pages.
- */
-export function processDirectMethods(project: ProjectReflection): PageIndex {
- const pages: PageIndex = [];
-
- // Generate direct method files
- for (const direct of selectDirectMethods(project)) {
- pages.push(processDirectMethod(direct));
- }
-
- return pages;
-}
-
-/**
- * Analyzes and writes the documentation for a direct method such as `faker.fake()`.
- *
- * @param direct The direct method to process.
- * @returns The generated pages.
- */
-export function processDirectMethod(direct: DeclarationReflection): Page {
- const methodName = direct.name;
- const capitalizedMethodName =
- methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
- console.log(`Processing Direct: ${capitalizedMethodName}`);
-
- const signatures = (direct.type as ReflectionType).declaration.signatures;
- const signature = signatures[signatures.length - 1];
-
- writeApiDocsDirectPage(methodName, capitalizedMethodName);
- writeApiDocsData(methodName, [
- analyzeSignature(signature, undefined, methodName),
- ]);
-
- return {
- text: capitalizedMethodName,
- link: `/api/${methodName}.html`,
- };
-}