diff options
| author | ST-DDT <[email protected]> | 2022-02-20 19:52:19 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-02-20 19:52:19 +0100 |
| commit | 1058e17ebb24207a5aad959b5613cc2d1de849d7 (patch) | |
| tree | 8d504049ee7c550d8dfa928f4969d671da05dee8 /scripts | |
| parent | 4e066e8e1a43f47450d264a9c3af8a8620f70055 (diff) | |
| download | faker-1058e17ebb24207a5aad959b5613cc2d1de849d7.tar.xz faker-1058e17ebb24207a5aad959b5613cc2d1de849d7.zip | |
docs: show deprecation warnings in api docs (#524)
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/apidoc.ts | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts index 93563248..fd9ebcd0 100644 --- a/scripts/apidoc.ts +++ b/scripts/apidoc.ts @@ -54,6 +54,14 @@ const htmlSanitizeOptions: sanitizeHtml.IOptions = { selfClosing: [], }; +export 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') + ); +} + function toBlock(comment?: TypeDoc.Comment): string { return ( (comment?.shortText.trim() || 'Missing') + @@ -127,9 +135,7 @@ async function build(): Promise<void> { TypeDoc.ReflectionKind.Method )) { const methodName = method.name; - const prettyMethodName = - methodName.substring(0, 1).toUpperCase() + - methodName.substring(1).replace(/([A-Z]+)/g, ' $1'); + const prettyMethodName = prettifyMethodName(methodName); console.debug(`- method ${prettyMethodName}`); const signature = method.signatures[0]; @@ -214,12 +220,20 @@ async function build(): Promise<void> { examples += exampleTags.join('\n').trim() + '\n'; } + const seeAlsos = + signature.comment?.tags + .filter((t) => t.tagName === 'see') + .map((t) => t.text.trim()) ?? []; + methods.push({ - name: prettyMethodName, + name: methodName, + title: prettyMethodName, description: mdToHtml(toBlock(signature.comment)), parameters: parameters, returns: signature.type.toString(), examples: mdToHtml('```ts\n' + examples + '```'), + deprecated: signature.comment?.hasTag('deprecated') ?? false, + seeAlsos, }); } |
