From 859292878b55c572e5b841e67aee5e9da660989e Mon Sep 17 00:00:00 2001 From: Matt Mayer Date: Sun, 5 Mar 2023 03:48:49 +0700 Subject: docs: show deprecation message (#1889) --- scripts/apidoc/signature.ts | 9 ++++++--- scripts/apidoc/typedoc.ts | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'scripts') 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; } /** -- cgit v1.2.3