diff --git a/cypress/e2e/api.cy.ts b/cypress/e2e/api.cy.ts index e67ac2135be..be61f5dfc5b 100644 --- a/cypress/e2e/api.cy.ts +++ b/cypress/e2e/api.cy.ts @@ -43,7 +43,7 @@ describe('API Test', () => { cy.request({ method: 'HEAD', - url: `/api/${link}`, + url: link, failOnStatusCode: false, }) .should(({ status }) => { diff --git a/docs/.vitepress/api-pages.ts b/docs/.vitepress/api-pages.ts index dc62235786b..f0858635356 100644 --- a/docs/.vitepress/api-pages.ts +++ b/docs/.vitepress/api-pages.ts @@ -2,6 +2,7 @@ // Run 'pnpm run generate:api-docs' to update export const apiPages = [ { text: 'Overview', link: '/api/' }, + { text: 'Faker', link: '/api/faker.html' }, { text: 'Airline', link: '/api/airline.html' }, { text: 'Animal', link: '/api/animal.html' }, { text: 'Color', link: '/api/color.html' }, @@ -28,4 +29,5 @@ export const apiPages = [ { text: 'System', link: '/api/system.html' }, { text: 'Vehicle', link: '/api/vehicle.html' }, { text: 'Word', link: '/api/word.html' }, + { text: 'Utilities', link: '/api/utils.html' }, ]; diff --git a/docs/.vitepress/components/api-docs/method.ts b/docs/.vitepress/components/api-docs/method.ts index 562d1ecf8d9..6601a5ca047 100644 --- a/docs/.vitepress/components/api-docs/method.ts +++ b/docs/.vitepress/components/api-docs/method.ts @@ -1,6 +1,5 @@ export interface Method { readonly name: string; - readonly title: string; readonly description: string; // HTML readonly parameters: MethodParameter[]; readonly returns: string; diff --git a/docs/.vitepress/components/api-docs/method.vue b/docs/.vitepress/components/api-docs/method.vue index 6753cefd733..38d105868ce 100644 --- a/docs/.vitepress/components/api-docs/method.vue +++ b/docs/.vitepress/components/api-docs/method.vue @@ -8,6 +8,9 @@ const props = defineProps<{ method: Method }>(); function seeAlsoToUrl(see: string): string { const [, module, method] = see.replace(/\(.*/, '').split('\.'); + if (!method) { + return 'faker.html#' + slugify(module); + } return module + '.html#' + slugify(method); } diff --git a/docs/api/ApiIndex.vue b/docs/api/ApiIndex.vue index 55efaeca6c6..6500ae697e7 100644 --- a/docs/api/ApiIndex.vue +++ b/docs/api/ApiIndex.vue @@ -97,13 +97,11 @@ onUnmounted(() => window.removeEventListener('keydown', apiSearchFocusHandler));

- {{ item.text }} + {{ item.text }}

diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts index 3c448f8b38a..ecb1f8fe02c 100644 --- a/scripts/apidoc.ts +++ b/scripts/apidoc.ts @@ -1,10 +1,8 @@ -import { faker } from '../src'; import { generate } from './apidoc/generate'; import { initMarkdownRenderer } from './apidoc/signature'; async function build(): Promise { await initMarkdownRenderer(); - faker.setDefaultRefDate(Date.UTC(2023, 0, 1)); await generate(); } diff --git a/scripts/apidoc/apiDocsWriter.ts b/scripts/apidoc/apiDocsWriter.ts index 6f00f64a313..ba1e43671f4 100644 --- a/scripts/apidoc/apiDocsWriter.ts +++ b/scripts/apidoc/apiDocsWriter.ts @@ -2,16 +2,17 @@ import { writeFileSync } from 'node:fs'; import { resolve } from 'node:path'; import type { ProjectReflection } from 'typedoc'; import type { Method } from '../../docs/.vitepress/components/api-docs/method'; -import type { APIGroup, APIItem } from '../../docs/api/api-types'; +import type { APIGroup } from '../../docs/api/api-types'; import { formatMarkdown, formatTypescript } from './format'; +import { extractSourceBaseUrl } from './typedoc'; +import type { DocsApiDiffIndex, ModuleSummary, Page } from './utils'; import { - extractModuleName, - extractSourceBaseUrl, - selectApiMethods, - selectApiModules, -} from './typedoc'; -import type { DocsApiDiffIndex, PageIndex } from './utils'; -import { pathDocsDiffIndexFile, pathDocsDir, pathOutputDir } from './utils'; + diffHash, + methodDiffHash, + pathDocsDiffIndexFile, + pathDocsDir, + pathOutputDir, +} from './utils'; const pathDocsApiPages = resolve(pathDocsDir, '.vitepress', 'api-pages.ts'); const pathDocsApiSearchIndex = resolve( @@ -29,6 +30,52 @@ editLink: false `; +/** + * Writes the api docs for the given modules. + * + * @param moduleName The name of the module to write the docs for. + * @param lowerModuleName The lowercase name of the module. + * @param comment The module comments. + * @param deprecated The deprecation message. + * @param methods The methods of the module. + */ +export function writeApiDocsModule( + moduleName: string, + lowerModuleName: string, + comment: string, + deprecated: string | undefined, + methods: Method[] +): ModuleSummary { + writeApiDocsModulePage( + moduleName, + lowerModuleName, + comment, + deprecated, + methods + ); + writeApiDocsModuleData(lowerModuleName, methods); + + return { + text: moduleName, + link: `/api/${lowerModuleName}.html`, + methods, + diff: methods.reduce( + (data, method) => ({ + ...data, + [method.name]: methodDiffHash(method), + }), + { + moduleHash: diffHash({ + name: moduleName, + field: lowerModuleName, + deprecated, + comment, + }), + } + ), + }; +} + /** * Writes the api page for the given module to the correct location. * @@ -37,7 +84,7 @@ editLink: false * @param comment The module comments. * @param methods The methods of the module. */ -export function writeApiDocsModulePage( +function writeApiDocsModulePage( moduleName: string, lowerModuleName: string, comment: string, @@ -94,7 +141,7 @@ export function writeApiDocsModulePage( * @param lowerModuleName The lowercase name of the module. * @param methods The methods data to save. */ -export function writeApiDocsData( +function writeApiDocsModuleData( lowerModuleName: string, methods: Method[] ): void { @@ -116,10 +163,9 @@ export function writeApiDocsData( * * @param pages The pages to write into the index. */ -export function writeApiPagesIndex(pages: PageIndex): void { +export function writeApiPagesIndex(pages: Page[]): void { // Write api-pages.ts console.log('Updating api-pages.ts'); - pages.sort((a, b) => a.text.localeCompare(b.text)); pages.splice(0, 0, { text: 'Overview', link: '/api/' }); let apiPagesContent = ` // This file is automatically generated. @@ -146,33 +192,20 @@ export function writeApiDiffIndex(diffIndex: DocsApiDiffIndex): void { * * @param project The typedoc project. */ -export function writeApiSearchIndex(project: ProjectReflection): void { - const apiIndex: APIGroup[] = []; - - const moduleApiSection: APIGroup = { - text: 'Module API', - items: [], - }; - - apiIndex.push(moduleApiSection); - - const apiModules = selectApiModules(project); - - moduleApiSection.items = apiModules - .map((module) => { - const moduleName = extractModuleName(module); - const apiSection: APIItem = { - text: moduleName, - link: moduleName.toLowerCase(), - headers: selectApiMethods(module).map((child) => ({ - anchor: child.name, - text: child.name, +export function writeApiSearchIndex(pages: ModuleSummary[]): void { + const apiIndex: APIGroup[] = [ + { + text: 'Module API', + items: pages.map((module) => ({ + text: module.text, + link: module.link, + headers: module.methods.map((method) => ({ + anchor: method.name, + text: method.name, })), - }; - - return apiSection; - }) - .sort((a, b) => a.text.localeCompare(b.text)); + })), + }, + ]; writeFileSync(pathDocsApiSearchIndex, JSON.stringify(apiIndex)); } diff --git a/scripts/apidoc/fakerClass.ts b/scripts/apidoc/fakerClass.ts new file mode 100644 index 00000000000..9d11815f0a3 --- /dev/null +++ b/scripts/apidoc/fakerClass.ts @@ -0,0 +1,48 @@ +import type { DeclarationReflection, ProjectReflection } from 'typedoc'; +import { ReflectionKind } from 'typedoc'; +import type { Method } from '../../docs/.vitepress/components/api-docs/method'; +import { writeApiDocsModule } from './apiDocsWriter'; +import { processModuleMethods } from './moduleMethods'; +import { analyzeSignature, toBlock } from './signature'; +import { selectApiSignature } from './typedoc'; +import type { ModuleSummary } from './utils'; + +export function processFakerClass(project: ProjectReflection): ModuleSummary { + const fakerClass = project + .getChildrenByKind(ReflectionKind.Class) + .filter((clazz) => clazz.name === 'Faker')[0]; + + if (!fakerClass) { + throw new Error('Faker class not found'); + } + + return processClass(fakerClass); +} + +function processClass(fakerClass: DeclarationReflection): ModuleSummary { + console.log(`Processing Faker class`); + const comment = toBlock(fakerClass.comment); + const methods: Method[] = []; + + console.debug(`- constructor`); + methods.push(processConstructor(fakerClass)); + + methods.push(...processModuleMethods(fakerClass, 'faker.')); + + return writeApiDocsModule('Faker', 'faker', comment, undefined, methods); +} + +function processConstructor(fakerClass: DeclarationReflection): Method { + const constructor = fakerClass.getChildrenByKind( + ReflectionKind.Constructor + )[0]; + + const signature = selectApiSignature(constructor); + + const method = analyzeSignature(signature, '', 'new Faker'); + + return { + ...method, + name: 'constructor', + }; +} diff --git a/scripts/apidoc/fakerUtilities.ts b/scripts/apidoc/fakerUtilities.ts new file mode 100644 index 00000000000..f033eadc6e3 --- /dev/null +++ b/scripts/apidoc/fakerUtilities.ts @@ -0,0 +1,32 @@ +import type { DeclarationReflection, ProjectReflection } from 'typedoc'; +import { ReflectionKind } from 'typedoc'; +import type { Method } from '../../docs/.vitepress/components/api-docs/method'; +import { writeApiDocsModule } from './apiDocsWriter'; +import { processMethods } from './moduleMethods'; +import { selectApiSignature } from './typedoc'; +import type { ModuleSummary } from './utils'; + +export function processFakerUtilities( + project: ProjectReflection +): ModuleSummary { + const fakerUtilities = project + .getChildrenByKind(ReflectionKind.Function) + .filter((method) => !method.flags.isPrivate); + + return processUtilities(fakerUtilities); +} + +function processUtilities( + fakerUtilities: DeclarationReflection[] +): ModuleSummary { + console.log(`Processing Faker Utilities`); + const comment = 'A list of all the utilities available in Faker.js.'; + + const methods: Method[] = processMethods( + Object.fromEntries( + fakerUtilities.map((method) => [method.name, selectApiSignature(method)]) + ) + ); + + return writeApiDocsModule('Utilities', 'utils', comment, undefined, methods); +} diff --git a/scripts/apidoc/generate.ts b/scripts/apidoc/generate.ts index b5ccb3f34d7..408ab76a60c 100644 --- a/scripts/apidoc/generate.ts +++ b/scripts/apidoc/generate.ts @@ -5,7 +5,9 @@ import { writeApiSearchIndex, writeSourceBaseUrl, } from './apiDocsWriter'; -import { processModuleMethods } from './moduleMethods'; +import { processFakerClass } from './fakerClass'; +import { processFakerUtilities } from './fakerUtilities'; +import { processModules } from './moduleMethods'; import { loadProject } from './typedoc'; import { pathOutputDir } from './utils'; @@ -20,12 +22,16 @@ export async function generate(): Promise { // Useful for manually analyzing the content await app.generateJson(project, pathOutputJson); - const modules = processModuleMethods(project); - writeApiPagesIndex(modules.map(({ text, link }) => ({ text, link }))); + const pages = [ + processFakerClass(project), + ...processModules(project).sort((a, b) => a.text.localeCompare(b.text)), + processFakerUtilities(project), + ]; + writeApiPagesIndex(pages.map(({ text, link }) => ({ text, link }))); writeApiDiffIndex( - modules.reduce((data, { text, diff }) => ({ ...data, [text]: diff }), {}) + pages.reduce((data, { text, diff }) => ({ ...data, [text]: diff }), {}) ); + writeApiSearchIndex(pages); - writeApiSearchIndex(project); writeSourceBaseUrl(project); } diff --git a/scripts/apidoc/moduleMethods.ts b/scripts/apidoc/moduleMethods.ts index 20cbc2b8056..9c902dd7038 100644 --- a/scripts/apidoc/moduleMethods.ts +++ b/scripts/apidoc/moduleMethods.ts @@ -1,6 +1,10 @@ -import type { DeclarationReflection, ProjectReflection } from 'typedoc'; +import type { + DeclarationReflection, + ProjectReflection, + SignatureReflection, +} from 'typedoc'; import type { Method } from '../../docs/.vitepress/components/api-docs/method'; -import { writeApiDocsData, writeApiDocsModulePage } from './apiDocsWriter'; +import { writeApiDocsModule } from './apiDocsWriter'; import { analyzeSignature, stripAbsoluteFakerUrls, toBlock } from './signature'; import { extractDeprecated, @@ -9,8 +13,7 @@ import { selectApiMethodSignatures, selectApiModules, } from './typedoc'; -import type { PageAndDiffIndex } from './utils'; -import { diffHash, methodDiffHash } from './utils'; +import type { ModuleSummary } from './utils'; /** * Analyzes and writes the documentation for modules and their methods such as `faker.animal.cat()`. @@ -18,17 +21,8 @@ import { diffHash, methodDiffHash } from './utils'; * @param project The project used to extract the modules. * @returns The generated pages. */ -export function processModuleMethods( - project: ProjectReflection -): PageAndDiffIndex { - const pages: PageAndDiffIndex = []; - - // Generate module files - for (const module of selectApiModules(project)) { - pages.push(...processModuleMethod(module)); - } - - return pages; +export function processModules(project: ProjectReflection): ModuleSummary[] { + return selectApiModules(project).map(processModule); } /** @@ -37,48 +31,54 @@ export function processModuleMethods( * @param module The module to process. * @returns The generated pages. */ -function processModuleMethod(module: DeclarationReflection): PageAndDiffIndex { +function processModule(module: DeclarationReflection): ModuleSummary { const moduleName = extractModuleName(module); const moduleFieldName = extractModuleFieldName(module); console.log(`Processing Module ${moduleName}`); const comment = stripAbsoluteFakerUrls(toBlock(module.comment)); const deprecated = extractDeprecated(module); - const methods: Method[] = []; - - // Generate method section - for (const [methodName, signature] of Object.entries( - selectApiMethodSignatures(module) - )) { - console.debug(`- ${methodName}`); - methods.push(analyzeSignature(signature, moduleFieldName, methodName)); - } + const methods = processModuleMethods(module, `faker.${moduleFieldName}.`); - writeApiDocsModulePage( + return writeApiDocsModule( moduleName, moduleFieldName, comment, deprecated, methods ); - writeApiDocsData(moduleFieldName, methods); +} + +/** + * Processes all api methods of the given class. This does not include the constructor. + * + * @param module The module to process. + * @param accessor The code used to access the methods within the module. + * @returns A list containing the documentation for the api methods in the given module. + */ +export function processModuleMethods( + module: DeclarationReflection, + accessor: string +): Method[] { + return processMethods(selectApiMethodSignatures(module), accessor); +} + +/** + * Processes all api methods. + * + * @param signatures The signatures to process. + * @param accessor The code used to access the methods. + * @returns A list containing the documentation for the api methods. + */ +export function processMethods( + signatures: Record, + accessor: string = '' +): Method[] { + const methods: Method[] = []; + + for (const [methodName, signature] of Object.entries(signatures)) { + console.debug(`- ${methodName}`); + methods.push(analyzeSignature(signature, accessor, methodName)); + } - return [ - { - text: moduleName, - link: `/api/${moduleFieldName}.html`, - diff: methods.reduce( - (data, method) => ({ - ...data, - [method.name]: methodDiffHash(method), - }), - { - moduleHash: diffHash({ - name: moduleName, - field: moduleFieldName, - comment, - }), - } - ), - }, - ]; + return methods; } diff --git a/scripts/apidoc/signature.ts b/scripts/apidoc/signature.ts index f9364a04eb1..113aba1d300 100644 --- a/scripts/apidoc/signature.ts +++ b/scripts/apidoc/signature.ts @@ -17,7 +17,6 @@ import type { MethodParameter, } from '../../docs/.vitepress/components/api-docs/method'; import vitepressConfig from '../../docs/.vitepress/config'; -import { faker } from '../../src'; import { formatTypescript } from './format'; import { extractDeprecated, @@ -32,14 +31,6 @@ import { pathOutputDir } from './utils'; const code = '```'; -function prettifyMethodName(method: string): string { - return ( - // Capitalize and insert space before upper case characters - method.substring(0, 1).toUpperCase() + - method.substring(1).replace(/([A-Z]+)/g, ' $1') - ); -} - export const MISSING_DESCRIPTION = 'Missing'; export function toBlock(comment?: Comment): string { @@ -115,7 +106,7 @@ function mdToHtml(md: string, inline: boolean = false): string { export function analyzeSignature( signature: SignatureReflection, - moduleName: string | null, + accessor: string, methodName: string ): Method { const parameters: MethodParameter[] = []; @@ -155,27 +146,7 @@ export function analyzeSignature( const signatureParametersString = signatureParameters.join(', '); - let examples: string; - if (moduleName) { - examples = `faker.${moduleName}.${methodName}${signatureTypeParametersString}(${signatureParametersString}): ${signature.type?.toString()}\n`; - } else { - examples = `faker.${methodName}${signatureTypeParametersString}(${signatureParametersString}): ${signature.type?.toString()}\n`; - } - - faker.seed(0); - if (moduleName) { - try { - let example = JSON.stringify(faker[moduleName][methodName]()); - if (example.length > 50) { - example = `${example.substring(0, 47)}...`; - } - - examples += `faker.${moduleName}.${methodName}()`; - examples += `${example ? ` // => ${example}` : ''}\n`; - } catch (error) { - // Ignore the error => hide the example call + result. - } - } + let examples = `${accessor}${methodName}${signatureTypeParametersString}(${signatureParametersString}): ${signature.type?.toString()}\n`; const exampleTags = extractRawExamples(signature); if (exampleTags.length > 0) { @@ -191,7 +162,6 @@ export function analyzeSignature( : undefined; return { name: methodName, - title: prettifyMethodName(methodName), description: mdToHtml(toBlock(signature.comment)), parameters: parameters, since: extractSince(signature), diff --git a/scripts/apidoc/utils.ts b/scripts/apidoc/utils.ts index 4c9c322d7cf..79e475070d7 100644 --- a/scripts/apidoc/utils.ts +++ b/scripts/apidoc/utils.ts @@ -5,12 +5,11 @@ import type { Method } from '../../docs/.vitepress/components/api-docs/method'; // Types export type Page = { text: string; link: string }; -export type PageIndex = Page[]; -export type PageAndDiff = Page & { +export type ModuleSummary = Page & { + methods: Method[]; diff: DocsApiDiff; }; -export type PageAndDiffIndex = PageAndDiff[]; export interface DocsApiDiffIndex { /** diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index 56b298eb043..579bd89bcd9 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -135,19 +135,9 @@ export class FinanceModule { options = { length: options }; } - let { length = 8 } = options; - if (length === 0) { - length = 8; - } - - let template = ''; + const { length = 8 } = options; - for (let i = 0; i < length; i++) { - template += '#'; - } - - length = null; - return this.faker.helpers.replaceSymbolWithNumber(template); + return this.faker.string.numeric({ length, allowLeadingZeros: true }); } /** diff --git a/test/finance.spec.ts b/test/finance.spec.ts index c71b3d38528..864ddb3bf23 100644 --- a/test/finance.spec.ts +++ b/test/finance.spec.ts @@ -123,16 +123,6 @@ describe('finance', () => { ).toHaveLength(8); }); - it('should supply a default length if a zero is passed', () => { - const accountNum = faker.finance.account(0); - - expect(accountNum).toBeTruthy(); - expect( - accountNum, - 'The length of the account number should be 8 characters long' - ).toHaveLength(8); - }); - it('should be the the length fo given number', () => { const accountNum = faker.finance.account(16); diff --git a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap index f93bcd497e9..715c85aa1fa 100644 --- a/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap +++ b/test/scripts/apidoc/__snapshots__/signature.spec.ts.snap @@ -5,7 +5,7 @@ exports[`signature > analyzeSignature() > complexArrayParameter 1`] = ` "deprecated": undefined, "description": "

Complex array parameter.

", - "examples": "
ts
faker.complexArrayParameter<T>(array: readonly Array<{
+  "examples": "
ts
complexArrayParameter<T>(array: readonly Array<{
   value: T,
   weight: number
 }>): T
@@ -45,7 +45,6 @@ exports[`signature > analyzeSignature() > complexArrayParameter 1`] = `
   "seeAlsos": [],
   "since": "",
   "sourcePath": "test/scripts/apidoc/signature.example.ts#L343",
-  "title": "Complex Array Parameter",
 }
 `;
 
@@ -54,7 +53,7 @@ exports[`signature > analyzeSignature() > defaultBooleanParamMethod 1`] = `
   "deprecated": undefined,
   "description": "

Test with a default parameter.

", - "examples": "
ts
faker.defaultBooleanParamMethod(c: boolean = true): number
+  "examples": "
ts
defaultBooleanParamMethod(c: boolean = true): number
 
", "name": "defaultBooleanParamMethod", @@ -71,7 +70,6 @@ exports[`signature > analyzeSignature() > defaultBooleanParamMethod 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L101", - "title": "Default Boolean Param Method", } `; @@ -104,7 +102,7 @@ exports[`signature > analyzeSignature() > functionParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with a function parameters.

", - "examples": "
ts
faker.functionParamMethod(fn: (a: string) => number): number
+  "examples": "
ts
functionParamMethod(fn: (a: string) => number): number
 
", "name": "functionParamMethod", @@ -121,7 +119,6 @@ exports[`signature > analyzeSignature() > functionParamMethod 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L121", - "title": "Function Param Method", } `; @@ -130,7 +127,7 @@ exports[`signature > analyzeSignature() > literalUnionParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with LiteralUnion.

", - "examples": "
ts
faker.literalUnionParamMethod(value: 'a' | 'b' | string, namedValue: 'a' | 'b' | string, array: readonly Array<'a' | 'b' | string>, namedArray: readonly Array<'a' | 'b' | string>, mixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>, namedMixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>): string
+  "examples": "
ts
literalUnionParamMethod(value: 'a' | 'b' | string, namedValue: 'a' | 'b' | string, array: readonly Array<'a' | 'b' | string>, namedArray: readonly Array<'a' | 'b' | string>, mixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>, namedMixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>): string
 
", "name": "literalUnionParamMethod", @@ -182,7 +179,6 @@ exports[`signature > analyzeSignature() > literalUnionParamMethod 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L155", - "title": "Literal Union Param Method", } `; @@ -192,7 +188,7 @@ exports[`signature > analyzeSignature() > methodWithDeprecated 1`] = ` ", "description": "

Test with deprecated and see marker.

", - "examples": "
ts
faker.methodWithDeprecated(): number
+  "examples": "
ts
methodWithDeprecated(): number
 
", "name": "methodWithDeprecated", @@ -203,7 +199,6 @@ exports[`signature > analyzeSignature() > methodWithDeprecated 1`] = ` ], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L273", - "title": "Method With Deprecated", } `; @@ -212,7 +207,7 @@ exports[`signature > analyzeSignature() > methodWithDeprecatedOption 1`] = ` "deprecated": undefined, "description": "

Test with deprecated option.

", - "examples": "
ts
faker.methodWithDeprecatedOption(option: {
+  "examples": "
ts
methodWithDeprecatedOption(option: {
   a: string,
   b: () => number,
   c: number
@@ -256,7 +251,6 @@ exports[`signature > analyzeSignature() > methodWithDeprecatedOption 1`] = `
   "seeAlsos": [],
   "since": "",
   "sourcePath": "test/scripts/apidoc/signature.example.ts#L285",
-  "title": "Method With Deprecated Option",
 }
 `;
 
@@ -265,7 +259,7 @@ exports[`signature > analyzeSignature() > methodWithExample 1`] = `
   "deprecated": undefined,
   "description": "

Test with example marker.

", - "examples": "
ts
faker.methodWithExample(): number
+  "examples": "
ts
methodWithExample(): number
 test.apidoc.methodWithExample() // 0
 
", @@ -275,7 +269,6 @@ exports[`signature > analyzeSignature() > methodWithExample 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L262", - "title": "Method With Example", } `; @@ -284,7 +277,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkers 1`] = ` "deprecated": undefined, "description": "

Test with multiple see markers.

", - "examples": "
ts
faker.methodWithMultipleSeeMarkers(): number
+  "examples": "
ts
methodWithMultipleSeeMarkers(): number
 
", "name": "methodWithMultipleSeeMarkers", @@ -296,7 +289,6 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkers 1`] = ` ], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L312", - "title": "Method With Multiple See Markers", } `; @@ -305,7 +297,7 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkersAndBacktic "deprecated": undefined, "description": "

Test with multiple see markers and backticks.

", - "examples": "
ts
faker.methodWithMultipleSeeMarkersAndBackticks(): number
+  "examples": "
ts
methodWithMultipleSeeMarkersAndBackticks(): number
 
", "name": "methodWithMultipleSeeMarkersAndBackticks", @@ -317,7 +309,6 @@ exports[`signature > analyzeSignature() > methodWithMultipleSeeMarkersAndBacktic ], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L322", - "title": "Method With Multiple See Markers And Backticks", } `; @@ -326,7 +317,7 @@ exports[`signature > analyzeSignature() > methodWithSinceMarker 1`] = ` "deprecated": undefined, "description": "

Test with since marker.

", - "examples": "
ts
faker.methodWithSinceMarker(): number
+  "examples": "
ts
methodWithSinceMarker(): number
 
", "name": "methodWithSinceMarker", @@ -335,7 +326,6 @@ exports[`signature > analyzeSignature() > methodWithSinceMarker 1`] = ` "seeAlsos": [], "since": "1.0.0", "sourcePath": "test/scripts/apidoc/signature.example.ts#L331", - "title": "Method With Since Marker", } `; @@ -344,7 +334,7 @@ exports[`signature > analyzeSignature() > multiParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with multiple parameters.

", - "examples": "
ts
faker.multiParamMethod(a: number, b?: string, c: boolean = true): number
+  "examples": "
ts
multiParamMethod(a: number, b?: string, c: boolean = true): number
 
", "name": "multiParamMethod", @@ -375,7 +365,6 @@ exports[`signature > analyzeSignature() > multiParamMethod 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L112", - "title": "Multi Param Method", } `; @@ -384,7 +373,7 @@ exports[`signature > analyzeSignature() > noParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with no parameters.

", - "examples": "
ts
faker.noParamMethod(): number
+  "examples": "
ts
noParamMethod(): number
 
", "name": "noParamMethod", @@ -393,7 +382,6 @@ exports[`signature > analyzeSignature() > noParamMethod 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L74", - "title": "No Param Method", } `; @@ -402,7 +390,7 @@ exports[`signature > analyzeSignature() > optionalStringParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with an optional parameter.

", - "examples": "
ts
faker.optionalStringParamMethod(b?: string): number
+  "examples": "
ts
optionalStringParamMethod(b?: string): number
 
", "name": "optionalStringParamMethod", @@ -419,7 +407,6 @@ exports[`signature > analyzeSignature() > optionalStringParamMethod 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L92", - "title": "Optional String Param Method", } `; @@ -428,7 +415,7 @@ exports[`signature > analyzeSignature() > optionsInlineParamMethodWithDefaults 1 "deprecated": undefined, "description": "

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

", - "examples": "
ts
faker.optionsInlineParamMethodWithDefaults(a: {
+  "examples": "
ts
optionsInlineParamMethodWithDefaults(a: {
   value: number
 } = { value: 1 }, b: {
   value: number
@@ -488,7 +475,6 @@ It also has a more complex description.

"seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L212", - "title": "Options Inline Param Method With Defaults", } `; @@ -497,7 +483,7 @@ exports[`signature > analyzeSignature() > optionsInterfaceParamMethodWithDefault "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
+  "examples": "
ts
optionsInterfaceParamMethodWithDefaults(a: ParameterOptionsInterfaceA = { value: 1 }, b: ParameterOptionsInterfaceB = { value: 1 }, c: ParameterOptionsInterfaceC): number
 
", "name": "optionsInterfaceParamMethodWithDefaults", @@ -528,7 +514,6 @@ exports[`signature > analyzeSignature() > optionsInterfaceParamMethodWithDefault "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L248", - "title": "Options Interface Param Method With Defaults", } `; @@ -537,7 +522,7 @@ exports[`signature > analyzeSignature() > optionsParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with a function parameters.

", - "examples": "
ts
faker.optionsParamMethod(options: {
+  "examples": "
ts
optionsParamMethod(options: {
   a: number,
   b: string,
   c: boolean,
@@ -595,7 +580,6 @@ exports[`signature > analyzeSignature() > optionsParamMethod 1`] = `
   "seeAlsos": [],
   "since": "",
   "sourcePath": "test/scripts/apidoc/signature.example.ts#L182",
-  "title": "Options Param Method",
 }
 `;
 
@@ -604,7 +588,7 @@ exports[`signature > analyzeSignature() > optionsTypeParamMethodWithDefaults 1`]
   "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
+  "examples": "
ts
optionsTypeParamMethodWithDefaults(a: ParameterOptionsTypeA = { value: 1 }, b: ParameterOptionsTypeB = { value: 1 }, c: ParameterOptionsTypeC): number
 
", "name": "optionsTypeParamMethodWithDefaults", @@ -635,7 +619,6 @@ exports[`signature > analyzeSignature() > optionsTypeParamMethodWithDefaults 1`] "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L230", - "title": "Options Type Param Method With Defaults", } `; @@ -644,7 +627,7 @@ exports[`signature > analyzeSignature() > requiredNumberParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with a required parameter.

", - "examples": "
ts
faker.requiredNumberParamMethod(a: number): number
+  "examples": "
ts
requiredNumberParamMethod(a: number): number
 
", "name": "requiredNumberParamMethod", @@ -661,7 +644,6 @@ exports[`signature > analyzeSignature() > requiredNumberParamMethod 1`] = ` "seeAlsos": [], "since": "", "sourcePath": "test/scripts/apidoc/signature.example.ts#L83", - "title": "Required Number Param Method", } `; @@ -670,7 +652,7 @@ exports[`signature > analyzeSignature() > stringUnionParamMethod 1`] = ` "deprecated": undefined, "description": "

Test with string union.

", - "examples": "
ts
faker.stringUnionParamMethod(value: 'a' | 'b', options?: {
+  "examples": "
ts
stringUnionParamMethod(value: 'a' | 'b', options?: {
   casing: 'lower' | 'mixed' | 'upper',
   excludes: readonly AlphaNumericChar[],
   format: 'binary' | 'css' | 'decimal' | 'hex'
@@ -719,6 +701,5 @@ exports[`signature > analyzeSignature() > stringUnionParamMethod 1`] = `
   "seeAlsos": [],
   "since": "",
   "sourcePath": "test/scripts/apidoc/signature.example.ts#L134",
-  "title": "String Union Param Method",
 }
 `;
diff --git a/test/scripts/apidoc/signature.debug.ts b/test/scripts/apidoc/signature.debug.ts
index 6be0e49fd0c..0076dfa74e3 100644
--- a/test/scripts/apidoc/signature.debug.ts
+++ b/test/scripts/apidoc/signature.debug.ts
@@ -16,7 +16,7 @@ initMarkdownRenderer()
   .then(() => {
     Object.entries(methods).forEach(([name, method]) => {
       console.log('Analyzing: ', name);
-      const result = analyzeSignature(method, null, method.name);
+      const result = analyzeSignature(method, '', method.name);
       console.log('Result: ', result);
     });
   })
diff --git a/test/scripts/apidoc/signature.spec.ts b/test/scripts/apidoc/signature.spec.ts
index d90370a27c2..3a48c29b7dd 100644
--- a/test/scripts/apidoc/signature.spec.ts
+++ b/test/scripts/apidoc/signature.spec.ts
@@ -23,7 +23,7 @@ describe('signature', () => {
     });
 
     it.each(Object.entries(methods))('%s', (name, signature) => {
-      const actual = analyzeSignature(signature, null, name);
+      const actual = analyzeSignature(signature, '', name);
 
       expect(actual).toMatchSnapshot();
     });
diff --git a/test/scripts/apidoc/verify-jsdoc-tags.spec.ts b/test/scripts/apidoc/verify-jsdoc-tags.spec.ts
index 410bffc206d..68692fabc7a 100644
--- a/test/scripts/apidoc/verify-jsdoc-tags.spec.ts
+++ b/test/scripts/apidoc/verify-jsdoc-tags.spec.ts
@@ -109,18 +109,18 @@ describe('verify JSDoc tags', () => {
         });
 
         it('verify @param tags', () => {
-          analyzeSignature(
-            signature,
-            moduleName,
-            methodName
-          ).parameters.forEach((param) => {
-            const { name, description } = param;
-            const plainDescription = description.replace(/<[^>]+>/g, '').trim();
-            expect(
-              plainDescription,
-              `Expect param ${name} to have a description`
-            ).not.toBe(MISSING_DESCRIPTION);
-          });
+          analyzeSignature(signature, '', methodName).parameters.forEach(
+            (param) => {
+              const { name, description } = param;
+              const plainDescription = description
+                .replace(/<[^>]+>/g, '')
+                .trim();
+              expect(
+                plainDescription,
+                `Expect param ${name} to have a description`
+              ).not.toBe(MISSING_DESCRIPTION);
+            }
+          );
         });
 
         it('verify @see tags', () => {