Skip to content

Commit 032ea64

Browse files
committed
Merge remote-tracking branch 'origin/next' into refactor/remove-locale-changing
2 parents d404b3b + 8592928 commit 032ea64

8 files changed

Lines changed: 37 additions & 29 deletions

File tree

docs/.vitepress/components/api-docs/method.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface Method {
55
readonly parameters: MethodParameter[];
66
readonly returns: string;
77
readonly examples: string; // HTML
8-
readonly deprecated: boolean;
8+
readonly deprecated?: string; // HTML
99
readonly since: string;
1010
readonly sourcePath: string; // URL-Suffix
1111
readonly seeAlsos: string[];

docs/.vitepress/components/api-docs/method.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function seeAlsoToUrl(see: string): string {
1717
<div v-if="props.method.deprecated" class="warning custom-block">
1818
<p class="custom-block-title">Deprecated</p>
1919
<p>This method is deprecated and will be removed in a future version.</p>
20+
<span v-html="props.method.deprecated" />
2021
</div>
2122

2223
<div v-html="props.method.description"></div>

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
[[redirects]]
3131
from = "/chat"
32-
to = "https://discord.gg/faker-js"
32+
to = "https://discord.gg/wq78qyhdSZ"
3333
status = 301
3434
force = true
3535

scripts/apidoc/signature.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import vitepressConfig from '../../docs/.vitepress/config';
2020
import { faker } from '../../src';
2121
import { formatTypescript } from './format';
2222
import {
23+
extractDeprecated,
2324
extractRawExamples,
2425
extractSeeAlsos,
2526
extractSince,
2627
extractSourcePath,
27-
isDeprecated,
2828
joinTagParts,
2929
} from './typedoc';
3030
import { pathOutputDir } from './utils';
@@ -178,7 +178,10 @@ export function analyzeSignature(
178178
const seeAlsos = extractSeeAlsos(signature).map((seeAlso) =>
179179
mdToHtml(seeAlso, true)
180180
);
181-
181+
const deprecatedMessage = extractDeprecated(signature);
182+
const deprecated = deprecatedMessage
183+
? mdToHtml(deprecatedMessage)
184+
: undefined;
182185
return {
183186
name: methodName,
184187
title: prettifyMethodName(methodName),
@@ -188,7 +191,7 @@ export function analyzeSignature(
188191
sourcePath: extractSourcePath(signature),
189192
returns: typeToText(signature.type),
190193
examples: mdToHtml(`${code}ts\n${examples}${code}`),
191-
deprecated: isDeprecated(signature),
194+
deprecated,
192195
seeAlsos,
193196
};
194197
}

scripts/apidoc/typedoc.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,13 @@ export function joinTagParts(parts?: CommentDisplayPart[]): string | undefined {
247247
*
248248
* @param signature The signature to check.
249249
*
250-
* @returns `true` if it is deprecated, otherwise `false`.
250+
* @returns The message explaining the deprecation if deprecated, otherwise `undefined`.
251251
*/
252-
export function isDeprecated(signature: SignatureReflection): boolean {
253-
return extractTagContent('@deprecated', signature).length > 0;
252+
export function extractDeprecated(
253+
signature: SignatureReflection
254+
): string | undefined {
255+
const deprecated = extractTagContent('@deprecated', signature).join().trim();
256+
return deprecated.length === 0 ? undefined : deprecated;
254257
}
255258

256259
/**

test/scripts/apidoc/__snapshots__/signature.spec.ts.snap

Lines changed: 19 additions & 18 deletions
Large diffs are not rendered by default.

test/scripts/apidoc/examplesAndDeprecations.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {
1515
initMarkdownRenderer,
1616
} from '../../../scripts/apidoc/signature';
1717
import {
18+
extractDeprecated,
1819
extractRawExamples,
1920
extractSeeAlsos,
2021
extractSince,
2122
extractTagContent,
22-
isDeprecated,
2323
} from '../../../scripts/apidoc/typedoc';
2424
import { loadProjectModules } from './utils';
2525

@@ -79,7 +79,7 @@ describe('examples and deprecations', () => {
7979
await import(path);
8080

8181
// Verify logging
82-
const deprecatedFlag = isDeprecated(signature);
82+
const deprecatedFlag = extractDeprecated(signature) !== undefined;
8383
if (deprecatedFlag) {
8484
expect(consoleSpies[1]).toHaveBeenCalled();
8585
expect(

test/scripts/apidoc/signature.example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export class SignatureTest {
249249
*
250250
* @see test.apidoc.methodWithExample()
251251
*
252-
* @deprecated
252+
* @deprecated do something else
253253
*/
254254
methodWithDeprecated(): number {
255255
return 0;

0 commit comments

Comments
 (0)