From 51a88634092dbe17985e434572385af4e99d1022 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Sun, 7 Aug 2022 04:54:28 +0800 Subject: docs: use vitepress v1 (#993) --- test/scripts/apidoc/signature.expected.json | 28 ++++++++++++++-------------- test/scripts/apidoc/signature.spec.ts | 11 +++++++++-- 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'test/scripts') diff --git a/test/scripts/apidoc/signature.expected.json b/test/scripts/apidoc/signature.expected.json index f576a342..fc948e55 100644 --- a/test/scripts/apidoc/signature.expected.json +++ b/test/scripts/apidoc/signature.expected.json @@ -12,7 +12,7 @@ } ], "returns": "number", - "examples": "
faker.defaultBooleanParamMethod(c: boolean = true): number\n
\n
", + "examples": "
faker.defaultBooleanParamMethod(c: boolean = true): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -28,7 +28,7 @@ } ], "returns": "number", - "examples": "
faker.functionParamMethod(fn: (a: string) => number): number\n
\n
", + "examples": "
faker.functionParamMethod(fn: (a: string) => number): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -44,7 +44,7 @@ } ], "returns": "string", - "examples": "
faker.literalUnionParamMethod(value: 'a' | 'b' | string): string\n
\n
", + "examples": "
faker.literalUnionParamMethod(value: 'a' | 'b' | string): string\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -54,7 +54,7 @@ "description": "

Test with deprecated and see marker.

\n", "parameters": [], "returns": "number", - "examples": "
faker.methodWithDeprecated(): number\n
\n
", + "examples": "
faker.methodWithDeprecated(): number\n
\n
", "deprecated": true, "seeAlsos": ["test.apidoc.methodWithExample()"] }, @@ -64,7 +64,7 @@ "description": "

Test with example marker.

\n", "parameters": [], "returns": "number", - "examples": "
faker.methodWithExample(): number\ntest.apidoc.methodWithExample() // 0\n
\n
", + "examples": "
faker.methodWithExample(): number\ntest.apidoc.methodWithExample() // 0\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -91,7 +91,7 @@ } ], "returns": "number", - "examples": "
faker.multiParamMethod(a: number, b?: string, c: boolean = true): number\n
\n
", + "examples": "
faker.multiParamMethod(a: number, b?: string, c: boolean = true): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -101,7 +101,7 @@ "description": "

Test with no parameters.

\n", "parameters": [], "returns": "number", - "examples": "
faker.noParamMethod(): number\n
\n
", + "examples": "
faker.noParamMethod(): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -117,7 +117,7 @@ } ], "returns": "number", - "examples": "
faker.optionalStringParamMethod(b?: string): number\n
\n
", + "examples": "
faker.optionalStringParamMethod(b?: string): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -161,7 +161,7 @@ } ], "returns": "number", - "examples": "
faker.optionsInlineParamMethodWithDefaults(a: {\n  value: number\n} = { value: 1 }, b: {\n  value: number\n} = { value: 1 }, c: {\n  value: number\n}): number\n
\n
", + "examples": "
faker.optionsInlineParamMethodWithDefaults(a: {\n  value: number\n} = { value: 1 }, b: {\n  value: number\n} = { value: 1 }, c: {\n  value: number\n}): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -189,7 +189,7 @@ } ], "returns": "number", - "examples": "
faker.optionsInterfaceParamMethodWithDefaults(a: ParameterOptionsInterfaceA = { value: 1 }, b: ParameterOptionsInterfaceB = { value: 1 }, c: ParameterOptionsInterfaceC): number\n
\n
", + "examples": "
faker.optionsInterfaceParamMethodWithDefaults(a: ParameterOptionsInterfaceA = { value: 1 }, b: ParameterOptionsInterfaceB = { value: 1 }, c: ParameterOptionsInterfaceC): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -225,7 +225,7 @@ } ], "returns": "number", - "examples": "
faker.optionsParamMethod(options: {\n  a: number,\n  b: string,\n  c: boolean,\n  d: () => string\n}): number\n
\n
", + "examples": "
faker.optionsParamMethod(options: {\n  a: number,\n  b: string,\n  c: boolean,\n  d: () => string\n}): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -253,7 +253,7 @@ } ], "returns": "number", - "examples": "
faker.optionsTypeParamMethodWithDefaults(a: ParameterOptionsTypeA = { value: 1 }, b: ParameterOptionsTypeB = { value: 1 }, c: ParameterOptionsTypeC): number\n
\n
", + "examples": "
faker.optionsTypeParamMethodWithDefaults(a: ParameterOptionsTypeA = { value: 1 }, b: ParameterOptionsTypeB = { value: 1 }, c: ParameterOptionsTypeC): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -269,7 +269,7 @@ } ], "returns": "number", - "examples": "
faker.requiredNumberParamMethod(a: number): number\n
\n
", + "examples": "
faker.requiredNumberParamMethod(a: number): number\n
\n
", "deprecated": false, "seeAlsos": [] }, @@ -285,7 +285,7 @@ } ], "returns": "string", - "examples": "
faker.stringUnionParamMethod(value: 'a' | 'b'): string\n
\n
", + "examples": "
faker.stringUnionParamMethod(value: 'a' | 'b'): string\n
\n
", "deprecated": false, "seeAlsos": [] } diff --git a/test/scripts/apidoc/signature.spec.ts b/test/scripts/apidoc/signature.spec.ts index 427ed923..f55c10f8 100644 --- a/test/scripts/apidoc/signature.spec.ts +++ b/test/scripts/apidoc/signature.spec.ts @@ -1,8 +1,11 @@ import { writeFileSync } from 'fs'; import { resolve } from 'path'; -import { afterAll, describe, expect, it } from 'vitest'; +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import type { Method } from '../../../docs/.vitepress/components/api-docs/method'; -import { analyzeSignature } from '../../../scripts/apidoc/signature'; +import { + analyzeSignature, + initMarkdownRenderer, +} from '../../../scripts/apidoc/signature'; import { SignatureTest } from './signature.example'; import expected_ from './signature.expected.json'; import { loadExampleMethods } from './utils'; @@ -18,6 +21,10 @@ describe('signature', () => { const actuals = {}; const methods = loadExampleMethods(); + beforeAll(async () => { + await initMarkdownRenderer(); + }); + it('dummy dependency to rerun the test if the example changes', () => { expect(new SignatureTest()).toBeTruthy(); }); -- cgit v1.2.3