typedoc-plugin-markdown
Advanced tools
Comparing version 4.0.0-next.38 to 4.0.0-next.39
/** | ||
* Exposes the public API of the plugin | ||
*/ | ||
export { PluginOptions } from './options/models'; | ||
export { load } from './plugin/bootstrap'; | ||
export { MarkdownPageEvent, MarkdownRendererEvent } from './plugin/events'; | ||
export { PluginOptions } from './plugin/options/models'; | ||
export { MarkdownTheme, MarkdownThemeRenderContext } from './theme'; | ||
export { NavigationItem } from './theme/models'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MarkdownThemeRenderContext = exports.MarkdownTheme = exports.MarkdownRendererEvent = exports.MarkdownPageEvent = exports.load = void 0; | ||
/** | ||
* Exposes the public API of the plugin | ||
*/ | ||
var bootstrap_1 = require("./plugin/bootstrap"); | ||
@@ -8,0 +5,0 @@ Object.defineProperty(exports, "load", { enumerable: true, get: function () { return bootstrap_1.load; } }); |
@@ -32,4 +32,4 @@ "use strict"; | ||
const typedoc_1 = require("typedoc"); | ||
const options = __importStar(require("../options/declarations")); | ||
const theme_1 = require("../theme"); | ||
const options = __importStar(require("./options/config")); | ||
const renderer_1 = require("./renderer"); | ||
@@ -44,6 +44,6 @@ /** | ||
*/ | ||
Object.values(options).forEach((option) => { | ||
Object.entries(options).forEach(([name, option]) => { | ||
app.options.addDeclaration({ | ||
name, | ||
...option, | ||
help: `[typedoc-plugin-markdown] ${option.help}`, | ||
}); | ||
@@ -50,0 +50,0 @@ }); |
@@ -17,3 +17,3 @@ import { Event, ProjectReflection, Reflection } from 'typedoc'; | ||
} | ||
export declare class MarkdownPageEvent<out Model = unknown> extends Event { | ||
export declare class MarkdownPageEvent<out Model = Reflection> extends Event { | ||
project: ProjectReflection; | ||
@@ -23,2 +23,3 @@ filename: string; | ||
contents?: string; | ||
frontmatter?: any; | ||
pageHeadings: any; | ||
@@ -25,0 +26,0 @@ readonly model: Model; |
@@ -12,4 +12,5 @@ /** | ||
export declare function isAbsoluteIndex(reflection: DeclarationReflection | ProjectReflection): boolean | undefined; | ||
export declare function hasToc(reflection: DeclarationReflection, isMembers: boolean): boolean | undefined; | ||
export declare function isGroupKind(reflection: DeclarationReflection | SignatureReflection): boolean; | ||
export declare function getModifier(reflection: DeclarationReflection): "private" | "readonly" | "static" | "abstract" | "get" | "set" | null; | ||
export declare function getModifier(reflection: DeclarationReflection): "private" | "public" | "readonly" | "protected" | "static" | "abstract" | "get" | "set" | null; | ||
export declare const KEYWORD_MAP: { | ||
@@ -26,3 +27,3 @@ 128: string; | ||
export declare function getSignatureParameters(parameters: ParameterReflection[], format?: boolean): string; | ||
export declare function getIndexFileName(reflection: ProjectReflection | DeclarationReflection, isPackages?: boolean): "packages.md" | "modules.md" | "exports.md"; | ||
export declare function getIndexLabel(reflection: ProjectReflection | DeclarationReflection, isPackages?: boolean): "Packages" | "Modules" | "Exports"; | ||
export declare function getIndexFileName(reflection: ProjectReflection | DeclarationReflection, isPackages?: boolean): "packages.md" | "modules.md" | "globals.md"; | ||
export declare function getIndexLabel(reflection: ProjectReflection | DeclarationReflection, isPackages?: boolean): "Modules" | "Packages" | "Globals"; |
@@ -9,3 +9,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getIndexLabel = exports.getIndexFileName = exports.getSignatureParameters = exports.flattenDeclarations = exports.declarationHasParent = exports.getMemberTitle = exports.KEYWORD_MAP = exports.getModifier = exports.isGroupKind = exports.isAbsoluteIndex = exports.hasIndex = exports.getProjectDisplayName = exports.getDeclarationType = void 0; | ||
exports.getIndexLabel = exports.getIndexFileName = exports.getSignatureParameters = exports.flattenDeclarations = exports.declarationHasParent = exports.getMemberTitle = exports.KEYWORD_MAP = exports.getModifier = exports.isGroupKind = exports.hasToc = exports.isAbsoluteIndex = exports.hasIndex = exports.getProjectDisplayName = exports.getDeclarationType = void 0; | ||
const typedoc_1 = require("typedoc"); | ||
@@ -29,3 +29,3 @@ const elements_1 = require("../support/elements"); | ||
const version = includeVersion && project.packageVersion | ||
? ` - v${project.packageVersion}` | ||
? ` v${project.packageVersion}` | ||
: ''; | ||
@@ -45,2 +45,18 @@ return `${project.name}${version ? version : ''}`; | ||
exports.isAbsoluteIndex = isAbsoluteIndex; | ||
function hasToc(reflection, isMembers) { | ||
var _a; | ||
return ((reflection.kindOf([ | ||
typedoc_1.ReflectionKind.Project, | ||
typedoc_1.ReflectionKind.Module, | ||
typedoc_1.ReflectionKind.Namespace, | ||
]) || | ||
(reflection.kindOf([ | ||
typedoc_1.ReflectionKind.Enum, | ||
typedoc_1.ReflectionKind.Class, | ||
typedoc_1.ReflectionKind.Interface, | ||
]) && | ||
isMembers)) && | ||
((_a = reflection.groups) === null || _a === void 0 ? void 0 : _a.some((group) => !group.allChildrenHaveOwnDocument()))); | ||
} | ||
exports.hasToc = hasToc; | ||
function isGroupKind(reflection) { | ||
@@ -70,2 +86,8 @@ return reflection.kindOf([ | ||
} | ||
if (reflection.flags.isProtected) { | ||
return 'protected'; | ||
} | ||
if (reflection.flags.isPublic) { | ||
return 'public'; | ||
} | ||
if (reflection.getSignature) { | ||
@@ -210,3 +232,3 @@ return 'get'; | ||
const isModules = (_a = reflection.children) === null || _a === void 0 ? void 0 : _a.every((child) => child.kindOf(typedoc_1.ReflectionKind.Module)); | ||
return isModules ? 'modules.md' : 'exports.md'; | ||
return isModules ? 'modules.md' : 'globals.md'; | ||
} | ||
@@ -220,4 +242,4 @@ exports.getIndexFileName = getIndexFileName; | ||
const isModules = (_a = reflection.children) === null || _a === void 0 ? void 0 : _a.every((child) => child.kindOf(typedoc_1.ReflectionKind.Module)); | ||
return isModules ? 'Modules' : 'Exports'; | ||
return isModules ? 'Modules' : 'Globals'; | ||
} | ||
exports.getIndexLabel = getIndexLabel; |
@@ -7,3 +7,3 @@ /** | ||
import { ReflectionKind } from 'typedoc'; | ||
import { OutputFileStrategy } from '../plugin/options/custom-maps'; | ||
import { OutputFileStrategy } from '../options/maps'; | ||
export interface UrlOption { | ||
@@ -10,0 +10,0 @@ parentUrl?: string; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const typedoc_1 = require("typedoc"); | ||
const custom_maps_1 = require("../plugin/options/custom-maps"); | ||
const maps_1 = require("../options/maps"); | ||
class NavigationContext { | ||
@@ -19,3 +19,3 @@ constructor(theme, options) { | ||
if (!containsOnlyModules && | ||
this.options.outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
this.options.outputFileStrategy === maps_1.OutputFileStrategy.Members && | ||
this.options.entryPointStrategy !== typedoc_1.EntryPointStrategy.Packages) { | ||
@@ -37,3 +37,3 @@ this.navigation.push({ | ||
(project.groups.length === 1 && | ||
this.options.outputFileStrategy === custom_maps_1.OutputFileStrategy.Modules)) { | ||
this.options.outputFileStrategy === maps_1.OutputFileStrategy.Modules)) { | ||
const children = this.getGroupChildren(project.groups[0]); | ||
@@ -40,0 +40,0 @@ if (children) { |
@@ -1,3 +0,5 @@ | ||
import { Options, Reflection } from 'typedoc'; | ||
import { Options, Reflection, ReflectionKind } from 'typedoc'; | ||
import { TextContentMappings } from '../options/models'; | ||
import { MarkdownPageEvent } from '../plugin/events'; | ||
import { MarkdownTheme } from './theme'; | ||
/** | ||
@@ -8,7 +10,12 @@ * The render context of the {@link MarkdownTheme}. | ||
export declare class MarkdownThemeRenderContext { | ||
private theme; | ||
page: MarkdownPageEvent<Reflection> | null; | ||
options: Options; | ||
constructor(page: MarkdownPageEvent<Reflection> | null, options: Options); | ||
constructor(theme: MarkdownTheme, page: MarkdownPageEvent<Reflection> | null, options: Options); | ||
urlTo: (reflection: Reflection) => string | null; | ||
relativeURL: (url: string | undefined) => string | null; | ||
getTextContent(key: keyof TextContentMappings): string; | ||
groupTitle(title: string): string; | ||
kindString(kind: ReflectionKind): string; | ||
indexTitle(textContent: string, name: string, version?: string): string; | ||
parseUrl(url: string): string; | ||
@@ -34,3 +41,3 @@ /** @hidden */ | ||
/** @hidden */ | ||
pageIndex: (page: import("typedoc").PageEvent<import("typedoc").DeclarationReflection | import("typedoc").ProjectReflection>, headingLevel: number) => string; | ||
pageIndex: (page: MarkdownPageEvent<import("typedoc").DeclarationReflection | import("typedoc").ProjectReflection>, headingLevel: number) => string; | ||
/** @hidden */ | ||
@@ -84,3 +91,3 @@ reflectionIndex: (reflection: import("typedoc").DeclarationReflection | import("typedoc").ProjectReflection, inline: boolean | undefined, headingLevel: number) => string; | ||
/** @hidden */ | ||
propertiesTable: (props: import("typedoc").DeclarationReflection[]) => string; | ||
propertiesTable: (props: import("typedoc").DeclarationReflection[], isEventProps?: boolean | undefined) => string; | ||
/** @hidden */ | ||
@@ -87,0 +94,0 @@ typeDeclarationTable: (props: import("typedoc").DeclarationReflection[]) => string; |
@@ -28,2 +28,4 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
const typedoc_1 = require("typedoc"); | ||
const kinds_1 = require("./constants/kinds"); | ||
/* start_imports */ | ||
@@ -93,3 +95,4 @@ const breadcrumbs_1 = require("./resources/partials/breadcrumbs"); | ||
class MarkdownThemeRenderContext { | ||
constructor(page, options) { | ||
constructor(theme, page, options) { | ||
this.theme = theme; | ||
this.page = page; | ||
@@ -230,2 +233,21 @@ this.options = options; | ||
} | ||
getTextContent(key) { | ||
return this.theme.textMappings[key]; | ||
} | ||
groupTitle(title) { | ||
const key = kinds_1.PLURAL_KIND_KEY_MAP[title]; | ||
return this.getTextContent(key) || title; | ||
} | ||
kindString(kind) { | ||
const singularString = typedoc_1.ReflectionKind.singularString(kind); | ||
const key = kinds_1.SINGULAR_KIND_KEY_MAP[singularString]; | ||
return this.getTextContent(key) || singularString; | ||
} | ||
indexTitle(textContent, name, version) { | ||
return textContent | ||
.replace('{projectName}', name) | ||
.replace('{version}', version ? `v${version}` : '') | ||
.replace(/\s+/g, ' ') | ||
.trim(); | ||
} | ||
parseUrl(url) { | ||
@@ -232,0 +254,0 @@ return encodeURI(url); |
@@ -30,2 +30,3 @@ "use strict"; | ||
const utils_1 = require("../../../support/utils"); | ||
const helpers_1 = require("../../helpers"); | ||
/** | ||
@@ -43,3 +44,6 @@ * Renders the breadcrumbs | ||
} | ||
md.push((0, elements_1.link)((0, utils_1.escapeChars)(page.project.name), context.relativeURL(page.project.url))); | ||
const homeLabel = context | ||
.getTextContent('breadcrumbs.home') | ||
.replace('{projectName}', (0, helpers_1.getProjectDisplayName)(page.project, false)); | ||
md.push((0, elements_1.link)(homeLabel, context.relativeURL(page.project.url))); | ||
const breadcrumb = (model) => { | ||
@@ -46,0 +50,0 @@ var _a; |
@@ -6,3 +6,2 @@ "use strict"; | ||
const elements_1 = require("../../../support/elements"); | ||
const helpers_1 = require("../../helpers"); | ||
/** | ||
@@ -20,32 +19,38 @@ * @category Partials | ||
} | ||
return projectHeader(context, page, isPackages); | ||
return projectHeader(context, page); | ||
} | ||
exports.header = header; | ||
function projectHeader(context, page, isPackages = false) { | ||
var _a, _b, _c, _d, _e; | ||
function projectHeader(context, page) { | ||
var _a, _b, _c; | ||
const entryFileName = context.options.getValue('entryFileName'); | ||
const titleLink = context.options.getValue('titleLink'); | ||
const md = []; | ||
const readmeLabel = 'Readme'; | ||
const documentationLabel = (0, helpers_1.getIndexLabel)(page.project, isPackages); | ||
md.push((0, elements_1.bold)(getProjectName(page.project, context, context.options.getValue('titleLink')))); | ||
const title = context.indexTitle(context.getTextContent('header.title'), page.project.name, page.project.packageVersion); | ||
const readmeLabel = context.getTextContent('header.readme'); | ||
const documentationLabel = context.getTextContent('header.docs'); | ||
md.push(titleLink ? (0, elements_1.bold)((0, elements_1.link)(title, titleLink)) : (0, elements_1.bold)(title)); | ||
md.push('•'); | ||
const preserveReadme = Boolean(page.project.readme) && !context.options.getValue('mergeReadme'); | ||
const isSinglePage = ((_a = page.project) === null || _a === void 0 ? void 0 : _a.groups) && | ||
((_b = page.project) === null || _b === void 0 ? void 0 : _b.groups.every((group) => !group.allChildrenHaveOwnDocument())); | ||
const preserveModulesPage = (((_c = page.project) === null || _c === void 0 ? void 0 : _c.groups) && | ||
Boolean((_e = (_d = page.project) === null || _d === void 0 ? void 0 : _d.groups[0]) === null || _e === void 0 ? void 0 : _e.children.find((child) => child.name === context.options.getValue('entryModule')))) || | ||
const preserveModulesPage = (((_a = page.project) === null || _a === void 0 ? void 0 : _a.groups) && | ||
Boolean((_c = (_b = page.project) === null || _b === void 0 ? void 0 : _b.groups[0]) === null || _c === void 0 ? void 0 : _c.children.find((child) => child.name === context.options.getValue('entryModule')))) || | ||
false; | ||
if (preserveReadme) { | ||
const links = []; | ||
links.push((0, elements_1.link)(readmeLabel, context.relativeURL(preserveModulesPage ? 'readme_.md' : entryFileName))); | ||
if (page.url === entryFileName) { | ||
links.push(readmeLabel); | ||
} | ||
else { | ||
links.push((0, elements_1.link)(readmeLabel, context.relativeURL(preserveModulesPage ? 'readme_.md' : entryFileName))); | ||
} | ||
links.push('\\|'); | ||
links.push((0, elements_1.link)(documentationLabel, context.relativeURL(page.project.url))); | ||
md.push(links.join(' ')); | ||
if (page.url === entryFileName) { | ||
links.push((0, elements_1.link)(documentationLabel, context.relativeURL(page.project.url))); | ||
} | ||
else { | ||
links.push(documentationLabel); | ||
} | ||
md.push(`${links.join(' ')}`); | ||
} | ||
else { | ||
md.push(isSinglePage | ||
? documentationLabel | ||
: (0, elements_1.link)(documentationLabel, preserveModulesPage | ||
? context.relativeURL(page.project.url) | ||
: context.relativeURL(entryFileName))); | ||
md.push(`${documentationLabel}`); | ||
} | ||
@@ -60,11 +65,7 @@ return `${md.join(' ')}\n\n***\n`; | ||
const md = []; | ||
const readmeLabel = 'Readme'; | ||
const documentationLabel = (0, helpers_1.getIndexLabel)(packageItem); | ||
const isSinglePage = (packageItem === null || packageItem === void 0 ? void 0 : packageItem.groups) && | ||
(packageItem === null || packageItem === void 0 ? void 0 : packageItem.groups.every((group) => !group.allChildrenHaveOwnDocument())); | ||
const readmeLabel = context.getTextContent('header.readme'); | ||
const documentationLabel = context.getTextContent('header.docs'); | ||
const entryFileName = context.options.getValue('entryFileName'); | ||
md.push(getProjectName(page.project, context, page.project.url)); | ||
md.push('•'); | ||
const packageItemName = packageItem.packageVersion | ||
? `${packageItem.name} - v${packageItem.packageVersion}` | ||
? `${packageItem.name} v${packageItem.packageVersion}` | ||
: packageItem.name; | ||
@@ -77,23 +78,22 @@ md.push((0, elements_1.bold)(packageItemName)); | ||
const readmeUrl = `${packageItem.name}/${entryFileName}`; | ||
links.push((0, elements_1.link)(readmeLabel, context.relativeURL(readmeUrl))); | ||
if (page.url === readmeUrl) { | ||
links.push(readmeLabel); | ||
} | ||
else { | ||
links.push((0, elements_1.link)(readmeLabel, context.relativeURL(readmeUrl))); | ||
} | ||
links.push('\\|'); | ||
links.push((0, elements_1.link)(documentationLabel, context.relativeURL(packageItem.url))); | ||
md.push(links.join(' ')); | ||
if (page.url === readmeUrl) { | ||
links.push((0, elements_1.link)(documentationLabel, context.relativeURL(packageItem.url))); | ||
} | ||
else { | ||
links.push(documentationLabel); | ||
} | ||
md.push(`${links.join(' ')}`); | ||
} | ||
else { | ||
md.push(isSinglePage | ||
? documentationLabel | ||
: (0, elements_1.link)(documentationLabel, context.relativeURL(packageItem.url))); | ||
md.push(documentationLabel); | ||
} | ||
return `${md.join(' ')}\n\n***\n`; | ||
} | ||
function getProjectName(project, context, url) { | ||
const projectName = (0, helpers_1.getProjectDisplayName)(project, context.options.getValue('includeVersion')); | ||
if (url) { | ||
return (0, elements_1.link)(projectName, context.relativeURL(url)); | ||
} | ||
else { | ||
return projectName; | ||
} | ||
} | ||
function findPackage(model) { | ||
@@ -100,0 +100,0 @@ var _a; |
@@ -1,6 +0,7 @@ | ||
import { DeclarationReflection, PageEvent, ProjectReflection } from 'typedoc'; | ||
import { DeclarationReflection, ProjectReflection } from 'typedoc'; | ||
import { MarkdownThemeRenderContext } from '../..'; | ||
import { MarkdownPageEvent } from '../../../plugin/events'; | ||
/** | ||
* @category Partials | ||
*/ | ||
export declare function pageIndex(context: MarkdownThemeRenderContext, page: PageEvent<DeclarationReflection | ProjectReflection>, headingLevel: number): string; | ||
export declare function pageIndex(context: MarkdownThemeRenderContext, page: MarkdownPageEvent<DeclarationReflection | ProjectReflection>, headingLevel: number): string; |
@@ -28,2 +28,4 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
const typedoc_1 = require("typedoc"); | ||
const maps_1 = require("../../../options/maps"); | ||
const elements_1 = require("../../../support/elements"); | ||
@@ -36,7 +38,14 @@ const utils_1 = require("../../../support/utils"); | ||
function pageIndex(context, page, headingLevel) { | ||
var _a; | ||
var _a, _b; | ||
const md = []; | ||
if (!page.model.groups) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Packages')); | ||
const packagesList = (_a = page.model.children) === null || _a === void 0 ? void 0 : _a.map((projectPackage) => { | ||
if ((0, helpers_1.hasIndex)(page.model)) { | ||
md.push(context.reflectionIndex(page.model, false, headingLevel)); | ||
return md.join('\n\n'); | ||
} | ||
const isPackages = page.project.url === page.url && | ||
context.options.getValue('entryPointStrategy') === | ||
typedoc_1.EntryPointStrategy.Packages; | ||
if (isPackages && ((_a = page.model.children) === null || _a === void 0 ? void 0 : _a.length)) { | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.packages'))); | ||
const packagesList = (_b = page.model.children) === null || _b === void 0 ? void 0 : _b.map((projectPackage) => { | ||
return `- [${(0, utils_1.escapeChars)(projectPackage.name)}](${context.relativeURL(Boolean(projectPackage.readme) | ||
@@ -49,5 +58,7 @@ ? `${path.dirname(projectPackage.url || '')}/${context.options.getValue('entryFileName')}` | ||
} | ||
if ((0, helpers_1.hasIndex)(page.model)) { | ||
md.push(context.reflectionIndex(page.model, false, headingLevel)); | ||
return md.join('\n\n'); | ||
if (!context.options.getValue('hideInPageTOC') && | ||
(0, helpers_1.hasToc)(page.model, context.options.getValue('outputFileStrategy') === | ||
maps_1.OutputFileStrategy.Members)) { | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.contents'))); | ||
md.push(context.reflectionIndex(page.model, true, headingLevel + 1)); | ||
} | ||
@@ -54,0 +65,0 @@ return md.join('\n\n'); |
@@ -22,2 +22,3 @@ "use strict"; | ||
groups === null || groups === void 0 ? void 0 : groups.forEach((reflectionGroup) => { | ||
var _a; | ||
if (reflectionGroup.categories) { | ||
@@ -31,4 +32,13 @@ md.push((0, elements_1.heading)(subHeadingLevel, reflectionGroup.title) + '\n'); | ||
else { | ||
md.push((0, elements_1.heading)(subHeadingLevel, reflectionGroup.title) + '\n'); | ||
md.push(getGroup(context, reflectionGroup, inline) + '\n'); | ||
const hasChildren = reflectionGroup.children.some((child) => Boolean(child.url)); | ||
if (inline) { | ||
md.push(`- [${context.groupTitle(reflectionGroup.title)}](${context.relativeURL((_a = context.page) === null || _a === void 0 ? void 0 : _a.url)}#${(0, utils_1.slugify)(context.groupTitle(reflectionGroup.title)).toLowerCase()})`); | ||
if (hasChildren) { | ||
md.push((0, elements_1.indentBlock)(getGroup(context, reflectionGroup, inline) + '\n')); | ||
} | ||
} | ||
else { | ||
md.push((0, elements_1.heading)(subHeadingLevel, context.groupTitle(reflectionGroup.title)) + '\n'); | ||
md.push(getGroup(context, reflectionGroup, inline) + '\n'); | ||
} | ||
} | ||
@@ -50,3 +60,3 @@ }); | ||
typedoc_1.ReflectionKind.singularString(reflectionKind), | ||
'Description', | ||
context.getTextContent('label.description'), | ||
]; | ||
@@ -70,3 +80,12 @@ const rows = []; | ||
function getList(context, group) { | ||
const children = group.children.map((child) => `- [${(0, utils_1.escapeChars)(child.name)}](${context.relativeURL(child.url)})`); | ||
const children = group.children | ||
.filter((child) => Boolean(child.url)) | ||
.map((child) => { | ||
const name = child.name === 'constructor' | ||
? `${child.signatures | ||
? child.signatures[0].name | ||
: context.getTextContent('kind.constructor.singular')}` | ||
: child.name; | ||
return `- [${(0, utils_1.escapeChars)(name)}](${context.relativeURL(child.url)})`; | ||
}); | ||
return children.join('\n'); | ||
@@ -73,0 +92,0 @@ } |
@@ -29,3 +29,3 @@ "use strict"; | ||
if ((_b = (_a = declaration.setSignature) === null || _a === void 0 ? void 0 : _a.parameters) === null || _b === void 0 ? void 0 : _b.length) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Parameters')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('kind.parameter.plural'))); | ||
if (context.options.getValue('parametersFormat') === 'table') { | ||
@@ -32,0 +32,0 @@ md.push(context.parametersTable(declaration.setSignature.parameters)); |
@@ -13,7 +13,10 @@ "use strict"; | ||
md.push(context.declarationMemberIdentifier(declaration)); | ||
if (declaration.comment) { | ||
md.push(context.comment(declaration.comment, headingLevel)); | ||
const typeDeclaration = (_a = declaration.type) === null || _a === void 0 ? void 0 : _a.declaration; | ||
if (!((_b = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.signatures) === null || _b === void 0 ? void 0 : _b.every((signature) => Boolean(signature.comment)))) { | ||
if (declaration.comment) { | ||
md.push(context.comment(declaration.comment, headingLevel)); | ||
} | ||
} | ||
if (declaration.type instanceof typedoc_1.IntersectionType) { | ||
(_b = (_a = declaration.type) === null || _a === void 0 ? void 0 : _a.types) === null || _b === void 0 ? void 0 : _b.forEach((intersectionType) => { | ||
(_d = (_c = declaration.type) === null || _c === void 0 ? void 0 : _c.types) === null || _d === void 0 ? void 0 : _d.forEach((intersectionType) => { | ||
if (intersectionType instanceof typedoc_1.ReflectionType) { | ||
@@ -26,3 +29,3 @@ md.push((0, elements_1.heading)(headingLevel, 'Type declaration')); | ||
if (declaration.type instanceof typedoc_1.ReferenceType && | ||
((_c = declaration.type.typeArguments) === null || _c === void 0 ? void 0 : _c.length)) { | ||
((_e = declaration.type.typeArguments) === null || _e === void 0 ? void 0 : _e.length)) { | ||
if (declaration.type.typeArguments[0] instanceof typedoc_1.ReflectionType) { | ||
@@ -42,3 +45,2 @@ md.push((0, elements_1.heading)(headingLevel, 'Type declaration')); | ||
} | ||
const typeDeclaration = (_d = declaration.type) === null || _d === void 0 ? void 0 : _d.declaration; | ||
if (typeDeclaration) { | ||
@@ -49,11 +51,10 @@ if (typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.indexSignature) { | ||
} | ||
if (((_e = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.signatures) === null || _e === void 0 ? void 0 : _e.length) || | ||
((_f = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.children) === null || _f === void 0 ? void 0 : _f.length)) { | ||
if ((_g = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.signatures) === null || _g === void 0 ? void 0 : _g.length) { | ||
typeDeclaration.signatures.forEach((signature) => { | ||
md.push(context.signatureMember(signature, headingLevel, true)); | ||
}); | ||
} | ||
if ((_f = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.signatures) === null || _f === void 0 ? void 0 : _f.length) { | ||
typeDeclaration.signatures.forEach((signature) => { | ||
md.push(context.signatureMember(signature, headingLevel, true)); | ||
}); | ||
} | ||
if ((_g = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.children) === null || _g === void 0 ? void 0 : _g.length) { | ||
if (!nested && ((_h = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.children) === null || _h === void 0 ? void 0 : _h.length)) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Type declaration')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.typeDeclaration'))); | ||
md.push(context.typeDeclarationMember(typeDeclaration, headingLevel)); | ||
@@ -64,3 +65,5 @@ } | ||
md.push(context.inheritance(declaration, headingLevel)); | ||
if (!nested && declaration.sources) { | ||
if (!nested && | ||
declaration.sources && | ||
!context.options.getValue('disableSources')) { | ||
md.push(context.sources(declaration, headingLevel)); | ||
@@ -67,0 +70,0 @@ } |
@@ -16,7 +16,7 @@ "use strict"; | ||
if (parent) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Extends')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.extends'))); | ||
md.push(`- ${parent}`); | ||
} | ||
else { | ||
md.push((0, elements_1.heading)(headingLevel, 'Extended By')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.extendedBy'))); | ||
const lines = []; | ||
@@ -23,0 +23,0 @@ declarationHierarchy.next.types.forEach((hierarchyType) => { |
@@ -9,3 +9,3 @@ "use strict"; | ||
if (headingLevel !== -1) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Implementation of')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.implementationOf'))); | ||
} | ||
@@ -16,3 +16,3 @@ md.push(typeAndParent(context, reflection.implementationOf)); | ||
if (headingLevel !== -1) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Inherited from')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.inheritedFrom'))); | ||
} | ||
@@ -22,4 +22,5 @@ md.push(typeAndParent(context, reflection.inheritedFrom)); | ||
if (reflection.overwrites) { | ||
const overridesLabel = context.getTextContent('label.overrides'); | ||
if (headingLevel !== -1) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Overrides')); | ||
md.push((0, elements_1.heading)(headingLevel, overridesLabel)); | ||
} | ||
@@ -26,0 +27,0 @@ md.push(typeAndParent(context, reflection.overwrites)); |
@@ -10,4 +10,6 @@ "use strict"; | ||
let referenced = props.tryGetTargetReflectionDeep(); | ||
const reExportsText = context.getTextContent('label.reExports'); | ||
const renamesAndReExportsText = context.getTextContent('label.renamesAndReExports'); | ||
if (!referenced) { | ||
return `Re-exports ${props.name}`; | ||
return `${reExportsText} ${props.name}`; | ||
} | ||
@@ -18,9 +20,9 @@ if ((referenced === null || referenced === void 0 ? void 0 : referenced.kindOf(typedoc_1.ReflectionKind.TypeLiteral)) && referenced.parent) { | ||
if (!(referenced === null || referenced === void 0 ? void 0 : referenced.url)) { | ||
return `Re-exports ${referenced.name}`; | ||
return `${reExportsText} ${referenced.name}`; | ||
} | ||
if (props.name === referenced.name) { | ||
return `Re-exports [${referenced.name}](${context.urlTo(referenced)})`; | ||
return `${reExportsText} [${referenced.name}](${context.urlTo(referenced)})`; | ||
} | ||
return `Renames and re-exports [${referenced.name}](${context.urlTo(referenced)})`; | ||
return `${renamesAndReExportsText} [${referenced.name}](${context.urlTo(referenced)})`; | ||
} | ||
exports.referenceMember = referenceMember; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reflectionMember = void 0; | ||
const maps_1 = require("../../../options/maps"); | ||
const elements_1 = require("../../../support/elements"); | ||
@@ -19,3 +20,3 @@ const helpers_1 = require("../../helpers"); | ||
if (reflection.typeParameters) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Type parameters')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('kind.type-parameter.plural'))); | ||
if (context.options.getValue('parametersFormat') === 'table') { | ||
@@ -29,3 +30,3 @@ md.push(context.typeParametersTable(reflection.typeParameters)); | ||
if (reflection.implementedTypes) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Implements')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.implements'))); | ||
md.push((0, elements_1.unorderedList)(reflection.implementedTypes.map((implementedType) => context.someType(implementedType)))); | ||
@@ -39,3 +40,3 @@ } | ||
if ('indexSignature' in reflection && reflection.indexSignature) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Indexable')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.indexable'))); | ||
md.push(context.indexSignatureTitle(reflection.indexSignature)); | ||
@@ -46,6 +47,15 @@ } | ||
if (isAbsolute) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Index')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.index'))); | ||
} | ||
md.push(context.reflectionIndex(reflection, false, isAbsolute ? headingLevel + 1 : headingLevel)); | ||
} | ||
if (!context.options.getValue('hideInPageTOC') && | ||
(0, helpers_1.hasToc)(reflection, context.options.getValue('outputFileStrategy') === | ||
maps_1.OutputFileStrategy.Members)) { | ||
const tocContent = context.reflectionIndex(reflection, true, headingLevel + 1); | ||
if (tocContent.length) { | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.contents'))); | ||
md.push(context.reflectionIndex(reflection, true, headingLevel + 1)); | ||
} | ||
} | ||
md.push(context.members(reflection, headingLevel)); | ||
@@ -52,0 +62,0 @@ return md.join('\n\n'); |
@@ -22,3 +22,3 @@ "use strict"; | ||
!signature.kindOf(typedoc_1.ReflectionKind.ConstructorSignature)) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Type parameters')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('kind.type-parameter.plural'))); | ||
if (context.options.getValue('parametersFormat') === 'table') { | ||
@@ -32,3 +32,3 @@ md.push(context.typeParametersTable(signature.typeParameters)); | ||
if ((_b = signature.parameters) === null || _b === void 0 ? void 0 : _b.length) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Parameters')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('kind.parameter.plural'))); | ||
if (context.options.getValue('parametersFormat') === 'table') { | ||
@@ -48,3 +48,5 @@ md.push(context.parametersTable(signature.parameters)); | ||
} | ||
if (!nested && signature.sources) { | ||
if (!nested && | ||
signature.sources && | ||
!context.options.getValue('disableSources')) { | ||
md.push(context.sources(signature, headingLevel)); | ||
@@ -51,0 +53,0 @@ } |
@@ -13,3 +13,3 @@ "use strict"; | ||
const typeDeclaration = (_a = signature.type) === null || _a === void 0 ? void 0 : _a.declaration; | ||
md.push((0, elements_1.heading)(headingLevel, 'Returns')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.returns'))); | ||
md.push(getReturnType(context, typeDeclaration, signature.type)); | ||
@@ -16,0 +16,0 @@ if ((_b = signature.comment) === null || _b === void 0 ? void 0 : _b.blockTags.length) { |
@@ -13,3 +13,3 @@ "use strict"; | ||
if (headingLevel !== -1) { | ||
md.push((0, elements_1.heading)(headingLevel, 'Source')); | ||
md.push((0, elements_1.heading)(headingLevel, context.getTextContent('label.source'))); | ||
} | ||
@@ -16,0 +16,0 @@ (_a = reflection.sources) === null || _a === void 0 ? void 0 : _a.forEach((source, index) => { |
@@ -11,8 +11,9 @@ "use strict"; | ||
const displayHr = (reflection) => { | ||
var _a; | ||
if (context.options.getValue('outputFileStrategy') === 'modules') { | ||
return (0, helpers_1.isGroupKind)(reflection); | ||
} | ||
return !((_a = context.options | ||
.getValue('membersWithOwnFile')) === null || _a === void 0 ? void 0 : _a.includes(reflection)); | ||
//return !context.options | ||
// .getValue('membersWithOwnFile') | ||
// ?.includes(reflection); | ||
return true; | ||
}; | ||
@@ -55,3 +56,3 @@ const pushCategories = (categories, headingLevel) => { | ||
if (group.categories) { | ||
md.push((0, elements_1.heading)(headingLevel, group.title)); | ||
md.push((0, elements_1.heading)(headingLevel, context.groupTitle(group.title))); | ||
pushCategories(group.categories, headingLevel + 1); | ||
@@ -62,6 +63,7 @@ } | ||
const isEnumGroup = group.children.every((child) => child.kindOf(typedoc_1.ReflectionKind.EnumMember)); | ||
md.push((0, elements_1.heading)(headingLevel, group.title)); | ||
md.push((0, elements_1.heading)(headingLevel, context.groupTitle(group.title))); | ||
if (isPropertiesGroup && | ||
context.options.getValue('propertiesFormat') === 'table') { | ||
md.push(context.propertiesTable(group.children)); | ||
md.push(context.propertiesTable(group.children, context.groupTitle(group.title) === | ||
context.getTextContent('kind.event.plural'))); | ||
} | ||
@@ -68,0 +70,0 @@ else if (isEnumGroup && |
@@ -11,19 +11,18 @@ "use strict"; | ||
var _a; | ||
const memberPageTitle = context.options.getValue('memberPageTitle'); | ||
const name = (0, helpers_1.getMemberTitle)(page.model); | ||
if (((_a = page.model) === null || _a === void 0 ? void 0 : _a.url) === page.project.url) { | ||
const projectName = (0, helpers_1.getProjectDisplayName)(page.project, context.options.getValue('includeVersion')); | ||
return context.options | ||
.getValue('indexPageTitle') | ||
.replace('{projectName}', projectName); | ||
const titleContent = context.options.isSet('indexPageTitle') | ||
? context.options.getValue('indexPageTitle') | ||
: context.getTextContent('title.indexPage'); | ||
return context.indexTitle(titleContent, page.project.name, page.project.packageVersion); | ||
} | ||
if (page.model.kindOf(typedoc_1.ReflectionKind.Module)) { | ||
return page.model.packageVersion | ||
? `${name} - v${page.model.packageVersion}` | ||
: name; | ||
} | ||
return memberPageTitle | ||
const name = (0, helpers_1.getMemberTitle)(page.model); | ||
const textContent = page.model.kindOf(typedoc_1.ReflectionKind.Module) | ||
? context.getTextContent('title.modulePage') | ||
: context.options.isSet('memberPageTitle') | ||
? context.options.getValue('memberPageTitle') | ||
: context.getTextContent('title.memberPage'); | ||
return textContent | ||
.replace('{name}', name) | ||
.replace('{kind}', typedoc_1.ReflectionKind.singularString(page.model.kind)); | ||
.replace('{kind}', context.kindString(page.model.kind)); | ||
} | ||
exports.pageTitle = pageTitle; |
@@ -14,10 +14,9 @@ "use strict"; | ||
const hasComments = comments.some((value) => Boolean(value)); | ||
const hasSources = !context.options.getValue('disableSources'); | ||
const headers = ['Member', 'Value']; | ||
const headers = [ | ||
context.getTextContent('kind.enum-member.singular'), | ||
context.getTextContent('label.value'), | ||
]; | ||
if (hasComments) { | ||
headers.push('Description'); | ||
headers.push(context.getTextContent('label.description')); | ||
} | ||
if (hasSources) { | ||
headers.push('Source'); | ||
} | ||
const rows = props.map((property) => { | ||
@@ -46,5 +45,2 @@ var _a; | ||
} | ||
if (hasSources) { | ||
row.push(context.sources(property, -1)); | ||
} | ||
return `| ${row.join(' | ')} |\n`; | ||
@@ -51,0 +47,0 @@ }); |
@@ -32,8 +32,11 @@ "use strict"; | ||
const hasComments = parsedParams.some((param) => Boolean(param.comment)); | ||
const headers = ['Parameter', 'Type']; | ||
const headers = [ | ||
context.getTextContent('kind.parameter.singular'), | ||
context.getTextContent('label.type'), | ||
]; | ||
if (showDefaults) { | ||
headers.push('Default value'); | ||
headers.push(context.getTextContent('label.defaultValue')); | ||
} | ||
if (hasComments) { | ||
headers.push('Description'); | ||
headers.push(context.getTextContent('label.description')); | ||
} | ||
@@ -40,0 +43,0 @@ const firstOptionalParamIndex = parameters.findIndex((parameter) => parameter.flags.isOptional); |
@@ -6,2 +6,2 @@ import { DeclarationReflection } from 'typedoc'; | ||
*/ | ||
export declare function propertiesTable(context: MarkdownThemeRenderContext, props: DeclarationReflection[]): string; | ||
export declare function propertiesTable(context: MarkdownThemeRenderContext, props: DeclarationReflection[], isEventProps?: boolean): string; |
@@ -10,25 +10,29 @@ "use strict"; | ||
*/ | ||
function propertiesTable(context, props) { | ||
function propertiesTable(context, props, isEventProps = false) { | ||
const modifiers = props.map((param) => (0, helpers_1.getModifier)(param)); | ||
const hasModifiers = modifiers.some((value) => Boolean(value)); | ||
const inheritance = props.map((reflection) => Boolean(reflection.overwrites) || Boolean(reflection.inheritedFrom)); | ||
const hasInheritance = inheritance.some((value) => Boolean(value)); | ||
const hasSources = !context.options.getValue('disableSources'); | ||
const hasOverrides = props.some((prop) => Boolean(prop.overwrites)); | ||
const hasInheritance = props.some((prop) => Boolean(prop.inheritedFrom)); | ||
const hasComments = props.some((prop) => { var _a, _b, _c, _d; return ((_b = (_a = prop.comment) === null || _a === void 0 ? void 0 : _a.blockTags) === null || _b === void 0 ? void 0 : _b.length) || ((_d = (_c = prop === null || prop === void 0 ? void 0 : prop.comment) === null || _c === void 0 ? void 0 : _c.summary) === null || _d === void 0 ? void 0 : _d.length); }); | ||
const headers = []; | ||
if (hasModifiers) { | ||
headers.push('Modifier'); | ||
headers.push(context.getTextContent('label.modifier')); | ||
} | ||
headers.push('Property'); | ||
headers.push('Type'); | ||
headers.push('Description'); | ||
headers.push(isEventProps | ||
? context.getTextContent('kind.event.singular') | ||
: context.getTextContent('kind.property.singular')); | ||
headers.push(context.getTextContent('label.type')); | ||
if (hasComments) { | ||
headers.push(context.getTextContent('label.description')); | ||
} | ||
if (hasOverrides) { | ||
headers.push(context.getTextContent('label.overrides')); | ||
} | ||
if (hasInheritance) { | ||
headers.push('Inheritance'); | ||
headers.push(context.getTextContent('label.inheritedFrom')); | ||
} | ||
if (hasSources) { | ||
headers.push('Source'); | ||
} | ||
const rows = []; | ||
const declarations = (0, helpers_1.flattenDeclarations)(props); | ||
declarations.forEach((property, index) => { | ||
var _a; | ||
var _a, _b, _c, _d, _e; | ||
const propertyType = (0, helpers_1.getDeclarationType)(property); | ||
@@ -55,8 +59,15 @@ const row = []; | ||
} | ||
const comments = property.comment; | ||
if (comments) { | ||
row.push((0, utils_1.stripLineBreaks)((0, utils_1.formatTableDescriptionCol)(context.comment(comments)))); | ||
if (hasComments) { | ||
const hasComment = ((_c = (_b = property.comment) === null || _b === void 0 ? void 0 : _b.blockTags) === null || _c === void 0 ? void 0 : _c.length) || | ||
((_e = (_d = property === null || property === void 0 ? void 0 : property.comment) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.length); | ||
const comments = property === null || property === void 0 ? void 0 : property.comment; | ||
if (hasComment && comments) { | ||
row.push((0, utils_1.stripLineBreaks)((0, utils_1.formatTableDescriptionCol)(context.comment(comments)))); | ||
} | ||
else { | ||
row.push('-'); | ||
} | ||
} | ||
else { | ||
row.push('-'); | ||
if (hasOverrides) { | ||
row.push(context.inheritance(property, -1) || '-'); | ||
} | ||
@@ -66,5 +77,2 @@ if (hasInheritance) { | ||
} | ||
if (hasSources) { | ||
row.push(context.sources(property, -1)); | ||
} | ||
rows.push(row); | ||
@@ -71,0 +79,0 @@ }); |
@@ -12,5 +12,5 @@ "use strict"; | ||
const headers = []; | ||
headers.push('Member'); | ||
headers.push('Type'); | ||
headers.push('Description'); | ||
headers.push(context.getTextContent('label.member')); | ||
headers.push(context.getTextContent('label.type')); | ||
headers.push(context.getTextContent('label.description')); | ||
const declarations = (0, helpers_1.flattenDeclarations)(props, true); | ||
@@ -17,0 +17,0 @@ const rows = []; |
@@ -12,8 +12,8 @@ "use strict"; | ||
const hasComments = typeParameters.some((typeParameter) => Boolean(typeParameter.comment)); | ||
const headers = ['Parameter']; | ||
const headers = [context.getTextContent('kind.type-parameter.singular')]; | ||
if (hasDefault) { | ||
headers.push('Value'); | ||
headers.push(context.getTextContent('label.value')); | ||
} | ||
if (hasComments) { | ||
headers.push('Description'); | ||
headers.push(context.getTextContent('label.description')); | ||
} | ||
@@ -20,0 +20,0 @@ const rows = []; |
@@ -17,15 +17,14 @@ "use strict"; | ||
const includeReadme = context.options.getValue('mergeReadme') && page.model.readme; | ||
const headingLevel = includeReadme ? 2 : 1; | ||
if (includeReadme && page.model.readme) { | ||
md.push(context.commentParts(page.model.readme)); | ||
} | ||
else { | ||
if (!context.options.getValue('hidePageTitle')) { | ||
md.push((0, elements_1.heading)(1, context.pageTitle(page))); | ||
} | ||
if (!context.options.getValue('hidePageTitle')) { | ||
md.push((0, elements_1.heading)(headingLevel, context.pageTitle(page))); | ||
} | ||
if (page.model.comment) { | ||
md.push(context.comment(page.model.comment, 2)); | ||
md.push(context.comment(page.model.comment, headingLevel + 1)); | ||
} | ||
md.push(context.pageIndex(page, 2)); | ||
md.push(context.members(page.model, 2)); | ||
md.push(context.pageIndex(page, headingLevel + 1)); | ||
md.push(context.members(page.model, headingLevel + 1)); | ||
md.push(context.footer()); | ||
@@ -32,0 +31,0 @@ return md.join('\n\n'); |
@@ -12,2 +12,5 @@ "use strict"; | ||
} | ||
if (!context.options.getValue('hideBreadcrumbs')) { | ||
md.push(context.breadcrumbs(page)); | ||
} | ||
if (page.model.readme) { | ||
@@ -14,0 +17,0 @@ md.push(context.commentParts(page.model.readme)); |
@@ -1,9 +0,8 @@ | ||
import { DeclarationReflection, PageEvent, ProjectReflection, Reflection, ReflectionKind, RenderTemplate, Renderer, Theme } from 'typedoc'; | ||
import { DeclarationReflection, ProjectReflection, Reflection, ReflectionKind, RenderTemplate, Renderer, Theme } from 'typedoc'; | ||
import { OutputFileStrategy } from '../options/maps'; | ||
import { TextContentMappings } from '../options/models'; | ||
import { MarkdownPageEvent } from '../plugin/events'; | ||
import { OutputFileStrategy } from '../plugin/options/custom-maps'; | ||
import { UrlMapping } from '../plugin/url-mapping'; | ||
import { NavigationItem, TemplateMapping } from './models'; | ||
import { NavigationContext } from './navigation-context'; | ||
import { MarkdownThemeRenderContext } from './render-context'; | ||
import { UrlsContext } from './urls-context'; | ||
/** | ||
@@ -16,2 +15,3 @@ * This is in-built MarkdownTheme which extends TypeDocs Theme class. | ||
export declare class MarkdownTheme extends Theme { | ||
textMappings: TextContentMappings; | ||
/** | ||
@@ -23,4 +23,6 @@ * | ||
getRenderContext(pageEvent: MarkdownPageEvent<Reflection> | null): MarkdownThemeRenderContext; | ||
getNavigationContext(): NavigationContext; | ||
getUrlsContext(project: ProjectReflection): UrlsContext; | ||
getTextContent(key: keyof TextContentMappings): string; | ||
private getTextContentMappings; | ||
private getNavigationContext; | ||
private getUrlsContext; | ||
readmeTemplate: (pageEvent: MarkdownPageEvent<ProjectReflection>) => string; | ||
@@ -36,4 +38,2 @@ projectTemplate: (pageEvent: MarkdownPageEvent<ProjectReflection>) => string; | ||
getNavigation(project: ProjectReflection): NavigationItem[]; | ||
hasToc(page: PageEvent): boolean | undefined; | ||
insertToc(page: PageEvent, contents: string): string; | ||
/** | ||
@@ -40,0 +40,0 @@ * Returns the template mapping for a given reflection kind |
@@ -5,3 +5,3 @@ "use strict"; | ||
const typedoc_1 = require("typedoc"); | ||
const custom_maps_1 = require("../plugin/options/custom-maps"); | ||
const maps_1 = require("../options/maps"); | ||
const utils_1 = require("../support/utils"); | ||
@@ -36,6 +36,29 @@ const navigation_context_1 = require("./navigation-context"); | ||
}; | ||
// DEPRECATED PROPS WARNING (to delete) | ||
const deprecatedOptions = ['indexPageTitle', 'memberPageTitle']; | ||
deprecatedOptions.forEach((option) => { | ||
if (this.application.options.isSet(option)) { | ||
this.application.logger.warn(`[typedoc-plugin-markdown] "${option}" is deprecated. Please see https://www.typedoc-plugin-markdown.org/options#${option.toLowerCase()}`); | ||
} | ||
}); | ||
this.textMappings = this.getTextContentMappings(); | ||
} | ||
getRenderContext(pageEvent) { | ||
return new render_context_1.MarkdownThemeRenderContext(pageEvent, this.application.options); | ||
return new render_context_1.MarkdownThemeRenderContext(this, pageEvent, this.application.options); | ||
} | ||
getTextContent(key) { | ||
return this.textMappings[key]; | ||
} | ||
getTextContentMappings() { | ||
const textFromOptions = this.application.options.getValue('textContentMappings'); | ||
const knownKeys = Object.keys(maps_1.StaticText); | ||
for (const key of Object.keys(textFromOptions)) { | ||
if (!knownKeys.includes(key)) { | ||
this.application.logger.warn(`[typedoc-plugin-markdown] "${key}" is not a valid "textContentMappings" key. Valid keys are ${knownKeys | ||
.map((key) => `"${key}"`) | ||
.join(', ')}.`); | ||
} | ||
} | ||
return { ...maps_1.StaticText, ...(textFromOptions || {}) }; | ||
} | ||
getNavigationContext() { | ||
@@ -51,4 +74,3 @@ return new navigation_context_1.NavigationContext(this, this.application.options.getRawValues()); | ||
render(page, template) { | ||
const contents = template(page); | ||
return this.hasToc(page) ? this.insertToc(page, contents) : contents; | ||
return template(page); | ||
} | ||
@@ -61,47 +83,2 @@ getUrls(project) { | ||
} | ||
hasToc(page) { | ||
var _a; | ||
if (this.application.options.getValue('hideInPageTOC')) { | ||
return false; | ||
} | ||
const reflection = page.model; | ||
return (reflection.kindOf([ | ||
typedoc_1.ReflectionKind.Project, | ||
typedoc_1.ReflectionKind.Module, | ||
typedoc_1.ReflectionKind.Namespace, | ||
typedoc_1.ReflectionKind.Enum, | ||
typedoc_1.ReflectionKind.Class, | ||
typedoc_1.ReflectionKind.Interface, | ||
]) && | ||
((_a = reflection.groups) === null || _a === void 0 ? void 0 : _a.some((group) => !group.allChildrenHaveOwnDocument()))); | ||
} | ||
insertToc(page, contents) { | ||
var _a; | ||
const regXHeader = /(?<flag>#{2,6})\s+(?<content>.+)/g; | ||
const anchors = []; | ||
const toc = (_a = Array.from(contents === null || contents === void 0 ? void 0 : contents.matchAll(regXHeader))) === null || _a === void 0 ? void 0 : _a.map(({ groups: { flag, content } }) => { | ||
return { | ||
heading: flag.length, | ||
content, | ||
}; | ||
}).map((item) => { | ||
var _a; | ||
anchors.push(item.content); | ||
const count = (_a = anchors === null || anchors === void 0 ? void 0 : anchors.filter((id) => id === item.content)) === null || _a === void 0 ? void 0 : _a.length; | ||
return { ...item, count }; | ||
}).filter((item) => item.heading < 4).map((item) => { | ||
const spaces = Array.from({ length: item.heading }) | ||
.map((_, i) => (i > 1 ? ' ' : '')) | ||
.join(''); | ||
const urlParts = page === null || page === void 0 ? void 0 : page.url.split('/'); | ||
const urlBase = urlParts[urlParts.length - 1]; | ||
return `${spaces}- [${item.content}](${encodeURI(urlBase)}#${(0, utils_1.slugify)(item.content).toLowerCase()}${item.count > 1 ? `-${item.count - 1}` : ''})`; | ||
}).join('\n'); | ||
const contentToLines = contents === null || contents === void 0 ? void 0 : contents.split('\n'); | ||
const firstHeadingIndex = contentToLines === null || contentToLines === void 0 ? void 0 : contentToLines.findIndex((line) => line.startsWith('##')); | ||
if (firstHeadingIndex && firstHeadingIndex > 0) { | ||
contentToLines === null || contentToLines === void 0 ? void 0 : contentToLines.splice(firstHeadingIndex, 0, `\n\n## Contents\n\n${toc}\n\n`); | ||
} | ||
return contentToLines === null || contentToLines === void 0 ? void 0 : contentToLines.join('\n'); | ||
} | ||
/** | ||
@@ -118,3 +95,4 @@ * Returns the template mapping for a given reflection kind | ||
}; | ||
const membersWithOwnFile = this.application.options.getValue('membersWithOwnFile'); | ||
// const membersWithOwnFile = | ||
// this.application.options.getValue('membersWithOwnFile'); | ||
const mappings = { | ||
@@ -132,4 +110,5 @@ [typedoc_1.ReflectionKind.Module]: { | ||
}; | ||
if (outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
(membersWithOwnFile === null || membersWithOwnFile === void 0 ? void 0 : membersWithOwnFile.includes(typedoc_1.ReflectionKind[typedoc_1.ReflectionKind.Class]))) { | ||
if (outputFileStrategy === maps_1.OutputFileStrategy.Members //&& | ||
//membersWithOwnFile?.includes(ReflectionKind[ReflectionKind.Class]) | ||
) { | ||
mappings[typedoc_1.ReflectionKind.Class] = { | ||
@@ -141,4 +120,5 @@ template: this.reflectionTemplate, | ||
} | ||
if (outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
(membersWithOwnFile === null || membersWithOwnFile === void 0 ? void 0 : membersWithOwnFile.includes(typedoc_1.ReflectionKind[typedoc_1.ReflectionKind.Interface]))) { | ||
if (outputFileStrategy === maps_1.OutputFileStrategy.Members //&& | ||
//membersWithOwnFile?.includes(ReflectionKind[ReflectionKind.Interface]) | ||
) { | ||
mappings[typedoc_1.ReflectionKind.Interface] = { | ||
@@ -151,4 +131,5 @@ isLeaf: false, | ||
} | ||
if (outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
(membersWithOwnFile === null || membersWithOwnFile === void 0 ? void 0 : membersWithOwnFile.includes(typedoc_1.ReflectionKind[typedoc_1.ReflectionKind.Enum]))) { | ||
if (outputFileStrategy === maps_1.OutputFileStrategy.Members //&& | ||
//membersWithOwnFile?.includes(ReflectionKind[ReflectionKind.Enum]) | ||
) { | ||
mappings[typedoc_1.ReflectionKind.Enum] = { | ||
@@ -160,4 +141,5 @@ template: this.reflectionTemplate, | ||
} | ||
if (outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
(membersWithOwnFile === null || membersWithOwnFile === void 0 ? void 0 : membersWithOwnFile.includes(typedoc_1.ReflectionKind[typedoc_1.ReflectionKind.Function]))) { | ||
if (outputFileStrategy === maps_1.OutputFileStrategy.Members //&& | ||
//membersWithOwnFile?.includes(ReflectionKind[ReflectionKind.Function]) | ||
) { | ||
mappings[typedoc_1.ReflectionKind.Function] = { | ||
@@ -169,4 +151,5 @@ template: this.memberTemplate, | ||
} | ||
if (outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
(membersWithOwnFile === null || membersWithOwnFile === void 0 ? void 0 : membersWithOwnFile.includes(typedoc_1.ReflectionKind[typedoc_1.ReflectionKind.TypeAlias]))) { | ||
if (outputFileStrategy === maps_1.OutputFileStrategy.Members //&& | ||
//membersWithOwnFile?.includes(ReflectionKind[ReflectionKind.TypeAlias]) | ||
) { | ||
mappings[typedoc_1.ReflectionKind.TypeAlias] = { | ||
@@ -178,4 +161,5 @@ template: this.memberTemplate, | ||
} | ||
if (outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
(membersWithOwnFile === null || membersWithOwnFile === void 0 ? void 0 : membersWithOwnFile.includes(typedoc_1.ReflectionKind[typedoc_1.ReflectionKind.Variable]))) { | ||
if (outputFileStrategy === maps_1.OutputFileStrategy.Members //&& | ||
//membersWithOwnFile?.includes(ReflectionKind[ReflectionKind.Variable]) | ||
) { | ||
mappings[typedoc_1.ReflectionKind.Variable] = { | ||
@@ -182,0 +166,0 @@ template: this.memberTemplate, |
@@ -29,3 +29,3 @@ "use strict"; | ||
const typedoc_1 = require("typedoc"); | ||
const custom_maps_1 = require("../plugin/options/custom-maps"); | ||
const maps_1 = require("../options/maps"); | ||
const url_mapping_1 = require("../plugin/url-mapping"); | ||
@@ -151,3 +151,3 @@ const utils_1 = require("../support/utils"); | ||
if (this.options.getValue('outputFileStrategy') === | ||
custom_maps_1.OutputFileStrategy.Modules && | ||
maps_1.OutputFileStrategy.Modules && | ||
reflection.name === 'index') { | ||
@@ -180,3 +180,3 @@ return urlPath.replace('index.md', 'module.index.md'); | ||
this.options.getValue('outputFileStrategy') === | ||
custom_maps_1.OutputFileStrategy.Modules && | ||
maps_1.OutputFileStrategy.Modules && | ||
!this.childrenIncludeNamespaces(reflection)) { | ||
@@ -183,0 +183,0 @@ return null; |
{ | ||
"name": "typedoc-plugin-markdown", | ||
"version": "4.0.0-next.38", | ||
"version": "4.0.0-next.39", | ||
"description": "A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"prepublishOnly": "npm run lint && npm run build", | ||
"prebuild": "rm -rf dist && npm run task:code", | ||
"prebuild": "rm -rf dist && prebuild-options && ts-node scripts/prebuild-resources", | ||
"build": "tsc", | ||
@@ -22,5 +22,3 @@ "pretest": "ts-node ./test/__scripts__/prepare.ts", | ||
"build-and-test": "npm run build && npm run test", | ||
"api-docs": "npm run build && typedoc --options ./typedoc.api.js --out ./docs/api", | ||
"task:docs": "node scripts/docs/docs.mjs", | ||
"task:code": "ts-node scripts/code" | ||
"api-docs": "npm run build && typedoc --options ./typedoc.api.js --out ./docs/api" | ||
}, | ||
@@ -27,0 +25,0 @@ "author": "Thomas Grey", |
# typedoc-plugin-markdown | ||
![npm](https://img.shields.io/npm/v/typedoc-plugin-markdown%2Fnext?\&logo=npm) [![Build Status](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml/badge.svg?branch=next)](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml) | ||
![npm](https://img.shields.io/npm/v/typedoc-plugin-markdown%2Fnext?&logo=npm) ![Downloads](https://img.shields.io/npm/dm/typedoc-plugin-markdown) [![Build Status](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml/badge.svg?branch=next)](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml) | ||
> **Please note this pre-release version may contain breaking changes within the same semantic version.** | ||
A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown. | ||
A plugin for [TypeDoc](https://typedoc.org) that renders TypeScript API documentation as Markdown. [MDX 2+](https://mdxjs.com/) and [GFM](https://github.github.com/gfm/) compliant. | ||
## Contents | ||
* [What does it do?](#what-does-it-do) | ||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
* [Options](#options) | ||
* [Contributing](#contributing) | ||
* [License](#license) | ||
## What does it do? | ||
By default, [TypeDoc](https://typedoc.org) will render API documentation as a webpage, e.g. HTML files. | ||
The plugin replaces the default HTML theme with a built-in Markdown theme and exposes some additional options. This is useful if documentation is required to be included in project README files, Wikis and static site generators. | ||
## Installation | ||
```bash | ||
npm install typedoc typedoc-plugin-markdown@next --save-dev | ||
``` | ||
```shell | ||
npm install typedoc-plugin-markdown --save-dev | ||
``` | ||
## Usage | ||
## Documentation | ||
Plugins are loaded by using the TypeDoc `plugin` configuration option: | ||
Please visit https://typedoc-plugin-markdown.org. | ||
```bash | ||
typedoc --plugin typedoc-plugin-markdown | ||
``` | ||
For general TypeDoc configuration usage please see <https://typedoc.org/options/configuration>. | ||
## Options | ||
### TypeDoc Options | ||
All of TypeDoc's [Configuration](https://typedoc.org/options/configuration/), [Input](https://typedoc.org/options/input/) and [Organization](https://typedoc.org/options/organization/) options are respected as they are executed at the conversion phase of the project. | ||
TypeDoc's [Output](https://typedoc.org/options/output/) options are on the whole only relevant to the HTML theme and the majority are ignored by this plugin. | ||
Supported Output options are: [`--out`](https://typedoc.org/options/output/#out), [`--cleanOutputDir`](https://typedoc.org/options/output/#cleanoutputdir). | ||
### Plugin Options | ||
This plugin exposes several additional options. Please see [Plugin Options](./docs/plugin-options.md) for detailed usage. | ||
#### File output options | ||
Options that configure how files are generated. | ||
* [`--outputFileStrategy`](./docs/plugin-options.md#--outputfilestrategy) | ||
* [`--membersWithOwnFile`](./docs/plugin-options.md#--memberswithownfile) | ||
* [`--entryFileName`](./docs/plugin-options.md#--entryfilename) | ||
* [`--entryModule`](./docs/plugin-options.md#--entrymodule) | ||
* [`--mergeReadme`](./docs/plugin-options.md#--mergereadme) | ||
#### Structure and formatting options | ||
Options that alter the format and structure of pages. | ||
* [`--hidePageHeader`](./docs/plugin-options.md#--hidepageheader) | ||
* [`--hidePageTitle`](./docs/plugin-options.md#--hidepagetitle) | ||
* [`--hideBreadcrumbs`](./docs/plugin-options.md#--hidebreadcrumbs) | ||
* [`--hideInPageTOC`](./docs/plugin-options.md#--hideinpagetoc) | ||
* [`--indexPageTitle`](./docs/plugin-options.md#--indexpagetitle) | ||
* [`--memberPageTitle`](./docs/plugin-options.md#--memberpagetitle) | ||
* [`--excludeGroups`](./docs/plugin-options.md#--excludegroups) | ||
* [`--useCodeBlocks`](./docs/plugin-options.md#--usecodeblocks) | ||
* [`--expandObjects`](./docs/plugin-options.md#--expandobjects) | ||
* [`--parametersFormat`](./docs/plugin-options.md#--parametersformat) | ||
* [`--propertiesFormat`](./docs/plugin-options.md#--propertiesformat) | ||
* [`--enumMembersFormat`](./docs/plugin-options.md#--enummembersformat) | ||
* [`--typeDeclarationFormat`](./docs/plugin-options.md#--typedeclarationformat) | ||
* [`--indexFormat`](./docs/plugin-options.md#--indexformat) | ||
#### Utility options | ||
Options that configure additional functionality. | ||
* [`--preserveAnchorCasing`](./docs/plugin-options.md#--preserveanchorcasing) | ||
* [`--anchorPrefix`](./docs/plugin-options.md#--anchorprefix) | ||
* [`--namedAnchors`](./docs/plugin-options.md#--namedanchors) | ||
* [`--publicPath`](./docs/plugin-options.md#--publicpath) | ||
## Contributing | ||
Contributions and suggestions are welcome. Contributing guidelines coming soon. | ||
## License | ||
[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/LICENSE) | ||
Released under the [MIT License](./LICENSE). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220417
151
5240
19