typedoc-plugin-markdown
Version:
A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
16 lines (15 loc) • 678 B
JavaScript
import { ReflectionType } from 'typedoc';
export function unionType(model) {
const useCodeBlocks = this.options.getValue('useCodeBlocks');
const typesOut = model.types.map((unionType) => {
const type = this.partials.someType(unionType, { forceCollapse: true });
return unionType instanceof ReflectionType &&
unionType.declaration?.signatures?.length
? `(${type})`
: type;
});
const shouldFormat = useCodeBlocks &&
(typesOut?.join('').length > 70 || typesOut?.join('').includes('\n'));
const md = typesOut.join(shouldFormat ? `\n \\| ` : ` \\| `);
return shouldFormat ? `\n \\| ` + md : md;
}