diff options
| author | ST-DDT <[email protected]> | 2023-10-28 22:06:33 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-28 22:06:33 +0200 |
| commit | fdafaa4681da85c416098256654fe96c171a850b (patch) | |
| tree | 5b548e87c9acd89be949a27caa01eeab9452a7ab /scripts/apidoc/moduleMethods.ts | |
| parent | 9297e5b654d3aa44ec5d8601c8947ee707687e17 (diff) | |
| download | faker-fdafaa4681da85c416098256654fe96c171a850b.tar.xz faker-fdafaa4681da85c416098256654fe96c171a850b.zip | |
infra(unicorn): filename-case (#2492)
Diffstat (limited to 'scripts/apidoc/moduleMethods.ts')
| -rw-r--r-- | scripts/apidoc/moduleMethods.ts | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/scripts/apidoc/moduleMethods.ts b/scripts/apidoc/moduleMethods.ts deleted file mode 100644 index 33255a17..00000000 --- a/scripts/apidoc/moduleMethods.ts +++ /dev/null @@ -1,121 +0,0 @@ -import type { - DeclarationReflection, - ProjectReflection, - SignatureReflection, -} from 'typedoc'; -import type { Method } from '../../docs/.vitepress/components/api-docs/method'; -import { writeApiDocsModule } from './apiDocsWriter'; -import { codeToHtml } from './markdown'; -import { analyzeSignature } from './signature'; -import { - extractDeprecated, - extractDescription, - extractJoinedRawExamples, - extractModuleFieldName, - extractModuleName, - selectApiMethodSignatures, - selectApiModules, -} from './typedoc'; -import type { ModuleSummary } from './utils'; -import { adjustUrls } from './utils'; - -/** - * Analyzes and writes the documentation for modules and their methods such as `faker.animal.cat()`. - * - * @param project The project used to extract the modules. - * - * @returns The generated pages. - */ -export async function processModules( - project: ProjectReflection -): Promise<ModuleSummary[]> { - return Promise.all(selectApiModules(project).map(processModule)); -} - -/** - * Analyzes and writes the documentation for a module and its methods such as `faker.animal.cat()`. - * - * @param module The module to process. - * - * @returns The generated pages. - */ -async function processModule( - module: DeclarationReflection -): Promise<ModuleSummary> { - const moduleName = extractModuleName(module); - console.log(`Processing Module ${moduleName}`); - const moduleFieldName = extractModuleFieldName(module); - const { comment, deprecated, examples } = analyzeModule(module); - const methods = await processModuleMethods( - module, - `faker.${moduleFieldName}.` - ); - - return writeApiDocsModule( - moduleName, - moduleFieldName, - comment, - examples, - deprecated, - methods - ); -} - -/** - * Analyzes the documentation for a class. - * - * @param module The class to process. - * - * @returns The class information. - */ -export function analyzeModule(module: DeclarationReflection): { - comment: string; - deprecated: string | undefined; - examples: string | undefined; -} { - const examplesRaw = extractJoinedRawExamples(module); - const examples = examplesRaw ? codeToHtml(examplesRaw) : undefined; - - return { - comment: adjustUrls(extractDescription(module)), - deprecated: extractDeprecated(module), - examples, - }; -} - -/** - * Processes all api methods of the given class. This does not include the constructor. - * - * @param module The module to process. - * @param accessor The code used to access the methods within the module. - * - * @returns A list containing the documentation for the api methods in the given module. - */ -export async function processModuleMethods( - module: DeclarationReflection, - accessor: string -): Promise<Method[]> { - return processMethods(selectApiMethodSignatures(module), accessor); -} - -/** - * Processes all api methods. - * - * @param signatures The signatures to process. - * @param accessor The code used to access the methods. - * - * @returns A list containing the documentation for the api methods. - */ -export async function processMethods( - signatures: Record<string, SignatureReflection>, - accessor: string = '' -): Promise<Method[]> { - const methods: Method[] = []; - - for (const [methodName, signature] of Object.entries(signatures)) { - console.debug(`- ${methodName}`); - methods.push(await analyzeSignature(signature, accessor, methodName)); - } - - return methods; -} |
