diff options
| author | ST-DDT <[email protected]> | 2023-02-03 09:25:55 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-03 09:25:55 +0100 |
| commit | d35da058322121a4cd44159164f657814bcc62a7 (patch) | |
| tree | 8484dfbbd9bcfc1a951083e60931424ba3ccc902 /scripts/apidoc/apiDocsWriter.ts | |
| parent | 32b9034a7b27de2bf29668710542b1f1dc254bcb (diff) | |
| download | faker-d35da058322121a4cd44159164f657814bcc62a7.tar.xz faker-d35da058322121a4cd44159164f657814bcc62a7.zip | |
docs: show source link (#1780)
Co-authored-by: Shinigami92 <[email protected]>
Diffstat (limited to 'scripts/apidoc/apiDocsWriter.ts')
| -rw-r--r-- | scripts/apidoc/apiDocsWriter.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/apidoc/apiDocsWriter.ts b/scripts/apidoc/apiDocsWriter.ts index d40dec34..146c7923 100644 --- a/scripts/apidoc/apiDocsWriter.ts +++ b/scripts/apidoc/apiDocsWriter.ts @@ -6,6 +6,7 @@ import type { APIGroup, APIItem } from '../../docs/api/api-types'; import { formatMarkdown, formatTypescript } from './format'; import { extractModuleName, + extractSourceBaseUrl, selectApiMethods, selectApiModules, } from './typedoc'; @@ -120,10 +121,20 @@ export function writeApiPagesIndex(pages: PageIndex): void { writeFileSync(pathDocsApiPages, apiPagesContent); } +/** + * Writes the api diff index to the correct location. + * + * @param diffIndex The diff index project to write. + */ export function writeApiDiffIndex(diffIndex: DocsApiDiffIndex): void { writeFileSync(pathDocsDiffIndexFile, JSON.stringify(diffIndex)); } +/** + * Writes the api search index to the correct location. + * + * @param project The typedoc project. + */ export function writeApiSearchIndex(project: ProjectReflection): void { const apiIndex: APIGroup[] = []; @@ -154,3 +165,22 @@ export function writeApiSearchIndex(project: ProjectReflection): void { writeFileSync(pathDocsApiSearchIndex, JSON.stringify(apiIndex)); } + +/** + * Writes the source base url to the correct location. + * + * @param project The typedoc project. + */ +export function writeSourceBaseUrl(project: ProjectReflection): void { + const baseUrl = extractSourceBaseUrl(project); + + let content = ` + // This file is automatically generated. + // Run '${scriptCommand}' to update + export const sourceBaseUrl = '${baseUrl}'; + `.replace(/\n +/, '\n'); + + content = formatTypescript(content); + + writeFileSync(resolve(pathOutputDir, 'source-base-url.ts'), content); +} |
