diff options
| author | Matt Mayer <[email protected]> | 2023-09-20 02:47:34 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-19 21:47:34 +0200 |
| commit | 8e4172ba28381fd20eaa598234c63186631fd6fc (patch) | |
| tree | cbfc9f3b7f574036fa4a98f3d788b4c19540b6bc /scripts/apidoc/moduleMethods.ts | |
| parent | d264100c80698ffdb471c39798420c98b1fa3c97 (diff) | |
| download | faker-8e4172ba28381fd20eaa598234c63186631fd6fc.tar.xz faker-8e4172ba28381fd20eaa598234c63186631fd6fc.zip | |
docs: show examples for modules (#2406)
Co-authored-by: ST-DDT <[email protected]>
Diffstat (limited to 'scripts/apidoc/moduleMethods.ts')
| -rw-r--r-- | scripts/apidoc/moduleMethods.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/apidoc/moduleMethods.ts b/scripts/apidoc/moduleMethods.ts index 359282dc..89f234db 100644 --- a/scripts/apidoc/moduleMethods.ts +++ b/scripts/apidoc/moduleMethods.ts @@ -5,10 +5,12 @@ import type { } 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, @@ -41,7 +43,7 @@ async function processModule( const moduleName = extractModuleName(module); console.log(`Processing Module ${moduleName}`); const moduleFieldName = extractModuleFieldName(module); - const { comment, deprecated } = analyzeModule(module); + const { comment, deprecated, examples } = analyzeModule(module); const methods = await processModuleMethods( module, `faker.${moduleFieldName}.` @@ -51,6 +53,7 @@ async function processModule( moduleName, moduleFieldName, comment, + examples, deprecated, methods ); @@ -65,10 +68,15 @@ async function processModule( 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, }; } |
