Skip to content

Commit

Permalink
chore(docs): add a few tweaks in type extraction functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamr committed Oct 20, 2021
1 parent db93464 commit 62c013a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
5 changes: 1 addition & 4 deletions apps/website/src/typeui/reduceReflectionsWith.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import Indent from './Indent';
export default function reduceReflectionsWith(
punct: string | null,
params: Params,
renderCurrent: (
curr: JSONOutput.DeclarationReflection,
params: Params
) => any,
renderCurrent: (curr: JSONOutput.DeclarationReflection, p: Params) => any,
shouldBreak?: boolean
) {
return (prev: any, curr: JSONOutput.DeclarationReflection) => (
Expand Down
17 changes: 8 additions & 9 deletions apps/website/src/typeui/renderReflection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,14 @@ export default function renderReflection(
}
return ret;
case ReflectionKind.Method:
return renderAttribute(
reflection.name,
renderArrowSignatures(
reflection.signatures,
params.withoutMemberLinks()
),
reflection.flags,
params
);
return reflection.signatures.map((s) => {
return renderAttribute(
reflection.name,
renderArrowSignatures([s], params.withoutMemberLinks()),
reflection.flags,
params
);
});
case ReflectionKind.Function:
return renderArrowSignatures(
(reflection as JSONOutput.DeclarationReflection).signatures,
Expand Down
4 changes: 2 additions & 2 deletions apps/website/src/typeui/renderType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function renderType(pt: DeclarationType, params: Params) {
</>
);
case 'mapped':
const mapped = (pt as unknown) as JSONOutput.MappedType;
const mapped = pt as unknown as JSONOutput.MappedType;
nextParams = params.withIndent();
return (
<>
Expand Down Expand Up @@ -192,7 +192,7 @@ export default function renderType(pt: DeclarationType, params: Params) {
</>
);
case 'indexedAccess':
const acc = (pt as unknown) as JSONOutput.IndexedAccessType;
const acc = pt as unknown as JSONOutput.IndexedAccessType;
return (
<>
{renderType(acc.objectType, params)}
Expand Down
26 changes: 23 additions & 3 deletions doc-tools/doc-docusaurus-typedoc-plugin/src/gen-pages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unused-vars */
const { ReflectionKind } = require('typedoc');
const { writeFile, readdir, unlink } = require('fs/promises');
Expand Down Expand Up @@ -87,6 +88,21 @@ ${parseLinks(remarks.text)}
`;
}

/**
*
* @param {import('typedoc').JSONOutput.CommentTag} remarks
*/
function extractDeprecated(deprecated) {
return `
:::warning Deprecated
This feature will be removed in the next major release.
${parseLinks(deprecated.text)}
:::
`;
}

/**
*
* @param {import('typedoc').JSONOutput.CommentTag} warnings
Expand Down Expand Up @@ -136,9 +152,13 @@ function extractAdmonitions(comment, isHeader) {
const remarks = comment.tags && comment.tags.find((t) => t.tag === 'remarks');
const warning = comment.tags && comment.tags.find((t) => t.tag === 'warning');
const example = comment.tags && comment.tags.find((t) => t.tag === 'example');
return `\n${remarks ? extractRemarks(remarks) : ''}${
warning ? extractWarning(warning) : ''
}${example ? extractExample(example, isHeader) : ''}\n\n`;
const deprecated =
comment.tags && comment.tags.find((t) => t.tag === 'deprecated');
return `\n${deprecated ? extractDeprecated(deprecated) : ''}${
remarks ? extractRemarks(remarks) : ''
}${warning ? extractWarning(warning) : ''}${
example ? extractExample(example, isHeader) : ''
}\n\n`;
}

/**
Expand Down

0 comments on commit 62c013a

Please sign in to comment.