aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-12-30 20:04:03 +0100
committerGitHub <[email protected]>2022-12-30 19:04:03 +0000
commite296ff2d4f6f1aa56fe7c80722257bd0b316b30a (patch)
tree199d89a678b7f7fd2623f1ebca48e5aa0616a80e
parent7f7e4428893284efd2df49405e8c98e0eac4b190 (diff)
downloadfaker-e296ff2d4f6f1aa56fe7c80722257bd0b316b30a.tar.xz
faker-e296ff2d4f6f1aa56fe7c80722257bd0b316b30a.zip
docs: fix param check (#1694)
-rw-r--r--scripts/apidoc/signature.ts2
-rw-r--r--src/modules/helpers/index.ts3
-rw-r--r--test/scripts/apidoc/examplesAndDeprecations.spec.ts28
3 files changed, 31 insertions, 2 deletions
diff --git a/scripts/apidoc/signature.ts b/scripts/apidoc/signature.ts
index 72036a43..3b97a2ef 100644
--- a/scripts/apidoc/signature.ts
+++ b/scripts/apidoc/signature.ts
@@ -243,7 +243,7 @@ function analyzeParameterOptions(
description: mdToHtml(
toBlock(
property.comment ??
- (property.type as ReflectionType)?.declaration.signatures?.[0]
+ (property.type as ReflectionType)?.declaration?.signatures?.[0]
.comment
)
),
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts
index 2ccc311e..a1a845cd 100644
--- a/src/modules/helpers/index.ts
+++ b/src/modules/helpers/index.ts
@@ -396,6 +396,7 @@ export class HelpersModule {
/**
* Returns a random key from given object or `undefined` if no key could be found.
*
+ * @template T The type of the object to select from.
* @param object The object to be used.
*
* @example
@@ -411,6 +412,7 @@ export class HelpersModule {
/**
* Returns a random value from given object or `undefined` if no key could be found.
*
+ * @template T The type of object to select from.
* @param object The object to be used.
*
* @example
@@ -788,6 +790,7 @@ export class HelpersModule {
/**
* Generates an array containing values returned by the given method.
*
+ * @template T The type of elements.
* @param method The method used to generate the values.
* @param options The optional options object.
* @param options.count The number or range of elements to generate. Defaults to `3`.
diff --git a/test/scripts/apidoc/examplesAndDeprecations.spec.ts b/test/scripts/apidoc/examplesAndDeprecations.spec.ts
index 772307a9..df1769b4 100644
--- a/test/scripts/apidoc/examplesAndDeprecations.spec.ts
+++ b/test/scripts/apidoc/examplesAndDeprecations.spec.ts
@@ -3,9 +3,21 @@ import { resolve } from 'node:path';
import type { DeclarationReflection, SignatureReflection } from 'typedoc';
import { ReflectionKind } from 'typedoc';
import type { SpyInstance } from 'vitest';
-import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import {
+ afterAll,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ it,
+ vi,
+} from 'vitest';
import { selectApiModules } from '../../../scripts/apidoc/moduleMethods';
import {
+ analyzeSignature,
+ initMarkdownRenderer,
+} from '../../../scripts/apidoc/signature';
+import {
extractRawExamples,
extractSeeAlsos,
extractSince,
@@ -27,6 +39,8 @@ const locales: Record<string, string> = {
DE: 'de',
};
+beforeAll(initMarkdownRenderer);
+
describe('examples and deprecations', () => {
const project = loadProject();
@@ -107,6 +121,18 @@ describe('examples and deprecations', () => {
}
}
+ // 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');
+ }
+ );
+
// Verify @see tag
extractSeeAlsos(signature).forEach((link) => {
if (link.startsWith('faker.')) {