diff options
| author | ST-DDT <[email protected]> | 2023-01-23 18:47:09 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-23 17:47:09 +0000 |
| commit | 23aa08800ac66a5b16e405d04d07ea538d16dd6b (patch) | |
| tree | d031ddeff74354b9064b4b32ceb5f5e2bf5f0ac4 /scripts/apidoc/apiDocsWriter.ts | |
| parent | 826cb0b2db247fde4d0ee93933dfecd4f3a656dd (diff) | |
| download | faker-23aa08800ac66a5b16e405d04d07ea538d16dd6b.tar.xz faker-23aa08800ac66a5b16e405d04d07ea538d16dd6b.zip | |
refactor: reorganize apidoc scripts and reuse them for tests (#1759)
Diffstat (limited to 'scripts/apidoc/apiDocsWriter.ts')
| -rw-r--r-- | scripts/apidoc/apiDocsWriter.ts | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/scripts/apidoc/apiDocsWriter.ts b/scripts/apidoc/apiDocsWriter.ts index cd8dd2e5..f18b7cd9 100644 --- a/scripts/apidoc/apiDocsWriter.ts +++ b/scripts/apidoc/apiDocsWriter.ts @@ -1,17 +1,16 @@ import { writeFileSync } from 'node:fs'; import { resolve } from 'node:path'; 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 { extractModuleName, selectApiModules } from './moduleMethods'; -import type { PageIndex } from './utils'; +import { formatMarkdown, formatTypescript } from './format'; import { - formatMarkdown, - formatTypescript, - pathDocsDir, - pathOutputDir, -} from './utils'; + extractModuleName, + selectApiMethods, + selectApiModules, +} from './typedoc'; +import type { PageIndex } from './utils'; +import { pathDocsDir, pathOutputDir } from './utils'; const pathDocsApiPages = resolve(pathDocsDir, '.vitepress', 'api-pages.ts'); const pathDocsApiSearchIndex = resolve( @@ -139,28 +138,11 @@ export function writeApiSearchIndex(project: ProjectReflection): void { const apiSection: APIItem = { text: moduleName, link: moduleName.toLowerCase(), - headers: [], + headers: selectApiMethods(module).map((child) => ({ + anchor: child.name, + text: child.name, + })), }; - if (module.kind !== ReflectionKind.Property) { - apiSection.headers = module - .getChildrenByKind(ReflectionKind.Method) - .map((child) => ({ - anchor: child.name, - text: child.name, - })); - } else { - // TODO @Shinigami92 2022-08-17: Extract capitalization into own function - apiSection.text = - apiSection.text.substring(0, 1).toUpperCase() + - apiSection.text.substring(1); - - apiSection.headers = [ - { - anchor: module.name, - text: module.name, - }, - ]; - } return apiSection; }) |
