UNPKG

typedoc-plugin-markdown

Version:

A TypeDoc plugin that generates TypeScript API documentation as Markdown.

37 lines (36 loc) • 1.36 kB
import { heading, unorderedList } from '../../../libs/markdown/index.js'; import { i18n } from 'typedoc'; export function hierarchy(model, options) { const md = []; const getHierarchy = (hModel) => { // Each parent is its own list item (`interface C extends A, B`). const parents = !hModel.isTarget ? hModel.types.map((hierarchyType) => { return this.helpers.getHierarchyType(hierarchyType, { isTarget: hModel.isTarget || false, }); }) : null; if (hModel.next) { if (parents) { md.push(heading(options.headingLevel, i18n.theme_extends())); md.push(unorderedList(parents)); } else { md.push(heading(options.headingLevel, i18n.theme_extended_by())); const lines = []; hModel.next.types.forEach((hierarchyType) => { lines.push(this.helpers.getHierarchyType(hierarchyType, { isTarget: hModel.next?.isTarget || false, })); }); md.push(unorderedList(lines)); } if (hModel.next?.next) { getHierarchy(hModel.next); } } }; getHierarchy(model); return md.join('\n\n'); }