diff options
| author | Matt Mayer <[email protected]> | 2023-03-05 03:48:49 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-04 21:48:49 +0100 |
| commit | 859292878b55c572e5b841e67aee5e9da660989e (patch) | |
| tree | 05abad59baac09f256452f53d59a1b3b406df75b /scripts | |
| parent | 8a97cac30f94bf7c29bfd6ffbad6ebf9c05fa2b1 (diff) | |
| download | faker-859292878b55c572e5b841e67aee5e9da660989e.tar.xz faker-859292878b55c572e5b841e67aee5e9da660989e.zip | |
docs: show deprecation message (#1889)
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/apidoc/signature.ts | 9 | ||||
| -rw-r--r-- | scripts/apidoc/typedoc.ts | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/scripts/apidoc/signature.ts b/scripts/apidoc/signature.ts index d9e1cc44..7403e492 100644 --- a/scripts/apidoc/signature.ts +++ b/scripts/apidoc/signature.ts @@ -20,11 +20,11 @@ import vitepressConfig from '../../docs/.vitepress/config'; import { faker } from '../../src'; import { formatTypescript } from './format'; import { + extractDeprecated, extractRawExamples, extractSeeAlsos, extractSince, extractSourcePath, - isDeprecated, joinTagParts, } from './typedoc'; import { pathOutputDir } from './utils'; @@ -178,7 +178,10 @@ export function analyzeSignature( const seeAlsos = extractSeeAlsos(signature).map((seeAlso) => mdToHtml(seeAlso, true) ); - + const deprecatedMessage = extractDeprecated(signature); + const deprecated = deprecatedMessage + ? mdToHtml(deprecatedMessage) + : undefined; return { name: methodName, title: prettifyMethodName(methodName), @@ -188,7 +191,7 @@ export function analyzeSignature( sourcePath: extractSourcePath(signature), returns: typeToText(signature.type), examples: mdToHtml(`${code}ts\n${examples}${code}`), - deprecated: isDeprecated(signature), + deprecated, seeAlsos, }; } diff --git a/scripts/apidoc/typedoc.ts b/scripts/apidoc/typedoc.ts index cc5132a9..43b2ac88 100644 --- a/scripts/apidoc/typedoc.ts +++ b/scripts/apidoc/typedoc.ts @@ -245,10 +245,13 @@ export function joinTagParts(parts?: CommentDisplayPart[]): string | undefined { * * @param signature The signature to check. * - * @returns `true` if it is deprecated, otherwise `false`. + * @returns The message explaining the deprecation if deprecated, otherwise `undefined`. */ -export function isDeprecated(signature: SignatureReflection): boolean { - return extractTagContent('@deprecated', signature).length > 0; +export function extractDeprecated( + signature: SignatureReflection +): string | undefined { + const deprecated = extractTagContent('@deprecated', signature).join().trim(); + return deprecated.length === 0 ? undefined : deprecated; } /** |
