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) --- .../apidoc/__snapshots__/signature.spec.ts.snap | 37 +++++++++++----------- .../scripts/apidoc/examplesAndDeprecations.spec.ts | 4 +-- test/scripts/apidoc/signature.example.ts | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) (limited to 'test/scripts') diff --git a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap index 23b3867a..8d7f4ca4 100644 --- a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap +++ b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap @@ -2,7 +2,7 @@ exports[`signature > analyzeSignature() > complexArrayParameter 1`] = ` { - "deprecated": false, + "deprecated": undefined, "description": "

Complex array parameter.

", "examples": "
ts
faker.complexArrayParameter<T>(array: readonly Array<{
@@ -51,7 +51,7 @@ exports[`signature > analyzeSignature() > complexArrayParameter 1`] = `
 
 exports[`signature > analyzeSignature() > defaultBooleanParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with a default parameter.

", "examples": "
ts
faker.defaultBooleanParamMethod(c: boolean = true): number
@@ -100,7 +100,7 @@ exports[`signature > analyzeSignature() > expected and actual methods are equal
 
 exports[`signature > analyzeSignature() > functionParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with a function parameters.

", "examples": "
ts
faker.functionParamMethod(fn: (a: string) => number): number
@@ -126,7 +126,7 @@ exports[`signature > analyzeSignature() > functionParamMethod 1`] = `
 
 exports[`signature > analyzeSignature() > literalUnionParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with LiteralUnion.

", "examples": "
ts
faker.literalUnionParamMethod(value: 'a' | 'b' | string, namedValue: AB | string, array: readonly Array<'a' | 'b' | string>, namedArray: readonly Array<AB | string>, mixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>, namedMixed: AB | string | readonly Array<AB | string>): string
@@ -187,7 +187,8 @@ exports[`signature > analyzeSignature() > literalUnionParamMethod 1`] = `
 
 exports[`signature > analyzeSignature() > methodWithDeprecated 1`] = `
 {
-  "deprecated": true,
+  "deprecated": "

do something else

+", "description": "

Test with deprecated and see marker.

", "examples": "
ts
faker.methodWithDeprecated(): number
@@ -207,7 +208,7 @@ exports[`signature > analyzeSignature() > methodWithDeprecated 1`] = `
 
 exports[`signature > analyzeSignature() > methodWithExample 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with example marker.

", "examples": "
ts
faker.methodWithExample(): number
@@ -226,7 +227,7 @@ exports[`signature > analyzeSignature() > methodWithExample 1`] = `
 
 exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkers 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with multiple see markers.

", "examples": "
ts
faker.methodWithMultipleSeeMarkers(): number
@@ -247,7 +248,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkers 1`] = `
 
 exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkersAndBackticks 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with multiple see markers and backticks.

", "examples": "
ts
faker.methodWithMultipleSeeMarkersAndBackticks(): number
@@ -268,7 +269,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkersAndBacktic
 
 exports[`signature > analyzeSignature() > methodWithSinceMarker 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with since marker.

", "examples": "
ts
faker.methodWithSinceMarker(): number
@@ -286,7 +287,7 @@ exports[`signature > analyzeSignature() > methodWithSinceMarker 1`] = `
 
 exports[`signature > analyzeSignature() > multiParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with multiple parameters.

", "examples": "
ts
faker.multiParamMethod(a: number, b?: string, c: boolean = true): number
@@ -326,7 +327,7 @@ exports[`signature > analyzeSignature() > multiParamMethod 1`] = `
 
 exports[`signature > analyzeSignature() > noParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with no parameters.

", "examples": "
ts
faker.noParamMethod(): number
@@ -344,7 +345,7 @@ exports[`signature > analyzeSignature() > noParamMethod 1`] = `
 
 exports[`signature > analyzeSignature() > optionalStringParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with an optional parameter.

", "examples": "
ts
faker.optionalStringParamMethod(b?: string): number
@@ -370,7 +371,7 @@ exports[`signature > analyzeSignature() > optionalStringParamMethod 1`] = `
 
 exports[`signature > analyzeSignature() > optionsInlineParamMethodWithDefaults 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with a function parameters (inline types) with defaults.

", "examples": "
ts
faker.optionsInlineParamMethodWithDefaults(a: {
@@ -439,7 +440,7 @@ It also has a more complex description.

exports[`signature > analyzeSignature() > optionsInterfaceParamMethodWithDefaults 1`] = ` { - "deprecated": false, + "deprecated": undefined, "description": "

Test with a function parameters with defaults.

", "examples": "
ts
faker.optionsInterfaceParamMethodWithDefaults(a: ParameterOptionsInterfaceA = { value: 1 }, b: ParameterOptionsInterfaceB = { value: 1 }, c: ParameterOptionsInterfaceC): number
@@ -479,7 +480,7 @@ exports[`signature > analyzeSignature() > optionsInterfaceParamMethodWithDefault
 
 exports[`signature > analyzeSignature() > optionsParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with a function parameters.

", "examples": "
ts
faker.optionsParamMethod(options: {
@@ -538,7 +539,7 @@ exports[`signature > analyzeSignature() > optionsParamMethod 1`] = `
 
 exports[`signature > analyzeSignature() > optionsTypeParamMethodWithDefaults 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with a function parameters with defaults.

", "examples": "
ts
faker.optionsTypeParamMethodWithDefaults(a: ParameterOptionsTypeA = { value: 1 }, b: ParameterOptionsTypeB = { value: 1 }, c: ParameterOptionsTypeC): number
@@ -578,7 +579,7 @@ exports[`signature > analyzeSignature() > optionsTypeParamMethodWithDefaults 1`]
 
 exports[`signature > analyzeSignature() > requiredNumberParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with a required parameter.

", "examples": "
ts
faker.requiredNumberParamMethod(a: number): number
@@ -604,7 +605,7 @@ exports[`signature > analyzeSignature() > requiredNumberParamMethod 1`] = `
 
 exports[`signature > analyzeSignature() > stringUnionParamMethod 1`] = `
 {
-  "deprecated": false,
+  "deprecated": undefined,
   "description": "

Test with string union.

", "examples": "
ts
faker.stringUnionParamMethod(value: 'a' | 'b'): string
diff --git a/test/scripts/apidoc/examplesAndDeprecations.spec.ts b/test/scripts/apidoc/examplesAndDeprecations.spec.ts
index 8d6124e0..d8fc7361 100644
--- a/test/scripts/apidoc/examplesAndDeprecations.spec.ts
+++ b/test/scripts/apidoc/examplesAndDeprecations.spec.ts
@@ -15,11 +15,11 @@ import {
   initMarkdownRenderer,
 } from '../../../scripts/apidoc/signature';
 import {
+  extractDeprecated,
   extractRawExamples,
   extractSeeAlsos,
   extractSince,
   extractTagContent,
-  isDeprecated,
 } from '../../../scripts/apidoc/typedoc';
 import { faker } from '../../../src';
 import { loadProjectModules } from './utils';
@@ -89,7 +89,7 @@ describe('examples and deprecations', () => {
         await import(path);
 
         // Verify logging
-        const deprecatedFlag = isDeprecated(signature);
+        const deprecatedFlag = extractDeprecated(signature) !== undefined;
         if (deprecatedFlag) {
           expect(consoleSpies[1]).toHaveBeenCalled();
           expect(
diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts
index 26c35923..13372ffb 100644
--- a/test/scripts/apidoc/signature.example.ts
+++ b/test/scripts/apidoc/signature.example.ts
@@ -249,7 +249,7 @@ export class SignatureTest {
    *
    * @see test.apidoc.methodWithExample()
    *
-   * @deprecated
+   * @deprecated do something else
    */
   methodWithDeprecated(): number {
     return 0;
-- 
cgit v1.2.3