Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix param check #1694

Merged
merged 2 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/apidoc/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
),
Expand Down
3 changes: 3 additions & 0 deletions src/modules/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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`.
Expand Down
28 changes: 27 additions & 1 deletion test/scripts/apidoc/examplesAndDeprecations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ 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,
Expand All @@ -27,6 +39,8 @@ const locales: Record<string, string> = {
DE: 'de',
};

beforeAll(initMarkdownRenderer);

describe('examples and deprecations', () => {
const project = loadProject();

Expand Down Expand Up @@ -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.')) {
Expand Down