typedoc-plugin-markdown
Advanced tools
Comparing version 4.0.0-next.27 to 4.0.0-next.28
@@ -61,37 +61,3 @@ "use strict"; | ||
}); | ||
/* app.converter.on( | ||
Converter.EVENT_RESOLVE_END, | ||
(context: Context, reflection: Reflection) => { | ||
const project = context.project; | ||
const removeGroups = (children) => { | ||
return children?.map((child) => | ||
Object.assign(child, { | ||
children: removeGroups(child.children), | ||
groups: !child.kindOf( | ||
ReflectionKind.Project, | ||
ReflectionKind.Module, | ||
), | ||
}), | ||
); | ||
}; | ||
project.children = removeGroups(project.children); | ||
}, | ||
);*/ | ||
/** | ||
* Options reader that sets the Markdown theme as the defaut and initializes other relevant options. | ||
*/ | ||
/*app.options.addReader( | ||
new (class implements OptionsReader { | ||
name = 'markdown-theme'; | ||
readonly order = 900; | ||
readonly supportsPackages = false; | ||
read(container: Options) { | ||
container.setValue('modifierTags', [ | ||
...(container.getValue('modifierTags') || []), | ||
...['@membersToFile', '@moduleToFile'], | ||
]); | ||
} | ||
})(), | ||
);*/ | ||
} | ||
exports.load = load; |
@@ -8,44 +8,12 @@ import { DeclarationOption } from 'typedoc'; | ||
* | ||
* **`--outputFileStrategy members`** | ||
* **`members`** | ||
* | ||
* Generates an individual file for each exported member. This is the standard behaviour of the HTML theme and the plugin default. | ||
* | ||
* In this example output folder structure modules `module-a` and `module-b` export two classes and variables each: | ||
* It is also possible to further refine what members are exported to individual files with the [`--membersWithOwnFile`](#membersWithOwnFile) option. | ||
* | ||
* ``` | ||
* ├── README.md | ||
* ├── API.md | ||
* ├── module-a | ||
* ├── ├── README.md | ||
* │ ├── classes | ||
* │ │ ├── ClassA.md | ||
* │ │ ├── ClassB.md | ||
* ├── ├── variables | ||
* │ │ ├── VariableA.md | ||
* │ │ ├── VariableB.md | ||
* ├── module-b | ||
* ├── ├── README.md | ||
* │ ├── classes | ||
* │ │ ├── ClassA.md | ||
* │ │ ├── ClassB.md | ||
* ├── ├── variables | ||
* │ │ ├── VariableA.md | ||
* │ │ ├── VariableB.md | ||
* ``` | ||
* **`modules`** | ||
* | ||
* When `members` is set, it is also possible to further refine what members are exported to individual files with the [`membersWithOwnFile`](#membersWithOwnFile) option. | ||
* | ||
* **`--outputFileStrategy modules`** | ||
* | ||
* Generates a single file for every Module or Namespace where all members are hoisted to a single module file. This creates a flat navigation structure and reduces the amount of files generated. | ||
* | ||
* The above example will output the following folder structure: | ||
* | ||
* ``` | ||
* ├── README.md | ||
* ├── API.md | ||
* ├── module-a.md | ||
* ├── module-b.md | ||
* ``` | ||
* | ||
* @category fileOutput | ||
@@ -67,21 +35,12 @@ */ | ||
/** | ||
* The entry page in this context is the reference to the file that acts as a root page for a project and it's folders, equivalent to `index.html` for web pages. | ||
* The entry page in this context is the reference to the file that acts as a root page for the documentation, equivalent to `index.html` for web pages. | ||
* | ||
* `README.md` is recognised when browsing folders on repos and Wikis. `index.md` might be better if published as a web site. | ||
* `index.md` is the default, however `README.md` is recognised when browsing folders on repos and Wikis. | ||
* | ||
* The content of this file at the root of the project is conditional on if a readme file is resolved for the project. | ||
* The content of this file is one of the following: | ||
* | ||
* A. If a readme file is resolved then two root files are generated: | ||
* a) The [`--entryModule`](#--entrymodule) (if set). | ||
* b) The resolved Readme file. | ||
* c) The documentation index page (if readme = none). | ||
* | ||
* ``` | ||
* ├── README.md - (the project readme file) | ||
* ├── API.md - (API index page) | ||
* ``` | ||
* | ||
* B. If a readme file is NOT resolved (when `readme` = `none`), then the index page becomes the `entryFileName` page and there is no seperate index page. | ||
* | ||
* ``` | ||
* ├── README.md - (API index page) | ||
* ``` | ||
* | ||
* @category fileOutput | ||
@@ -92,11 +51,9 @@ * | ||
/** | ||
* By default when a readme file is resolved, a seperate index page is created. This option prepends the readme file into the index page creating a single documentation entrypoint. | ||
* If set the name of the file will be determined by the value of [`--entryFileName`](#--entryfilename). | ||
* | ||
* - This option is ignored when `readme` is set to `none`. | ||
* - `--indexPageTitle` is ignored. | ||
* This is only applicable when multiple modules are resolved. | ||
* | ||
* @category fileOutput | ||
* | ||
*/ | ||
export declare const mergeReadme: DeclarationOption; | ||
export declare const entryModule: DeclarationOption; | ||
/** | ||
@@ -103,0 +60,0 @@ * @category ui |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.namedAnchors = exports.anchorPrefix = exports.preserveAnchorCasing = exports.indexFormat = exports.typeDeclarationFormat = exports.enumMembersFormat = exports.propertiesFormat = exports.parametersFormat = exports.expandObjects = exports.useCodeBlocks = exports.excludeGroups = exports.memberPageTitle = exports.indexPageTitle = exports.hideInPageTOC = exports.hideBreadcrumbs = exports.hidePageTitle = exports.hidePageHeader = exports.mergeReadme = exports.entryFileName = exports.membersWithOwnFile = exports.outputFileStrategy = void 0; | ||
exports.namedAnchors = exports.anchorPrefix = exports.preserveAnchorCasing = exports.indexFormat = exports.typeDeclarationFormat = exports.enumMembersFormat = exports.propertiesFormat = exports.parametersFormat = exports.expandObjects = exports.useCodeBlocks = exports.excludeGroups = exports.memberPageTitle = exports.indexPageTitle = exports.hideInPageTOC = exports.hideBreadcrumbs = exports.hidePageTitle = exports.hidePageHeader = exports.entryModule = exports.entryFileName = exports.membersWithOwnFile = exports.outputFileStrategy = void 0; | ||
const typedoc_1 = require("typedoc"); | ||
@@ -12,44 +12,12 @@ const custom_maps_1 = require("./custom-maps"); | ||
* | ||
* **`--outputFileStrategy members`** | ||
* **`members`** | ||
* | ||
* Generates an individual file for each exported member. This is the standard behaviour of the HTML theme and the plugin default. | ||
* | ||
* In this example output folder structure modules `module-a` and `module-b` export two classes and variables each: | ||
* It is also possible to further refine what members are exported to individual files with the [`--membersWithOwnFile`](#membersWithOwnFile) option. | ||
* | ||
* ``` | ||
* ├── README.md | ||
* ├── API.md | ||
* ├── module-a | ||
* ├── ├── README.md | ||
* │ ├── classes | ||
* │ │ ├── ClassA.md | ||
* │ │ ├── ClassB.md | ||
* ├── ├── variables | ||
* │ │ ├── VariableA.md | ||
* │ │ ├── VariableB.md | ||
* ├── module-b | ||
* ├── ├── README.md | ||
* │ ├── classes | ||
* │ │ ├── ClassA.md | ||
* │ │ ├── ClassB.md | ||
* ├── ├── variables | ||
* │ │ ├── VariableA.md | ||
* │ │ ├── VariableB.md | ||
* ``` | ||
* **`modules`** | ||
* | ||
* When `members` is set, it is also possible to further refine what members are exported to individual files with the [`membersWithOwnFile`](#membersWithOwnFile) option. | ||
* | ||
* **`--outputFileStrategy modules`** | ||
* | ||
* Generates a single file for every Module or Namespace where all members are hoisted to a single module file. This creates a flat navigation structure and reduces the amount of files generated. | ||
* | ||
* The above example will output the following folder structure: | ||
* | ||
* ``` | ||
* ├── README.md | ||
* ├── API.md | ||
* ├── module-a.md | ||
* ├── module-b.md | ||
* ``` | ||
* | ||
* @category fileOutput | ||
@@ -90,21 +58,12 @@ */ | ||
/** | ||
* The entry page in this context is the reference to the file that acts as a root page for a project and it's folders, equivalent to `index.html` for web pages. | ||
* The entry page in this context is the reference to the file that acts as a root page for the documentation, equivalent to `index.html` for web pages. | ||
* | ||
* `README.md` is recognised when browsing folders on repos and Wikis. `index.md` might be better if published as a web site. | ||
* `index.md` is the default, however `README.md` is recognised when browsing folders on repos and Wikis. | ||
* | ||
* The content of this file at the root of the project is conditional on if a readme file is resolved for the project. | ||
* The content of this file is one of the following: | ||
* | ||
* A. If a readme file is resolved then two root files are generated: | ||
* a) The [`--entryModule`](#--entrymodule) (if set). | ||
* b) The resolved Readme file. | ||
* c) The documentation index page (if readme = none). | ||
* | ||
* ``` | ||
* ├── README.md - (the project readme file) | ||
* ├── API.md - (API index page) | ||
* ``` | ||
* | ||
* B. If a readme file is NOT resolved (when `readme` = `none`), then the index page becomes the `entryFileName` page and there is no seperate index page. | ||
* | ||
* ``` | ||
* ├── README.md - (API index page) | ||
* ``` | ||
* | ||
* @category fileOutput | ||
@@ -117,18 +76,15 @@ * | ||
type: typedoc_1.ParameterType.String, | ||
defaultValue: 'README.md', | ||
defaultValue: 'index.md', | ||
}; | ||
/** | ||
* By default when a readme file is resolved, a seperate index page is created. This option prepends the readme file into the index page creating a single documentation entrypoint. | ||
* If set the name of the file will be determined by the value of [`--entryFileName`](#--entryfilename). | ||
* | ||
* - This option is ignored when `readme` is set to `none`. | ||
* - `--indexPageTitle` is ignored. | ||
* This is only applicable when multiple modules are resolved. | ||
* | ||
* @category fileOutput | ||
* | ||
*/ | ||
exports.mergeReadme = { | ||
name: 'mergeReadme', | ||
help: 'Merges the resolved readme into the project index page.', | ||
type: typedoc_1.ParameterType.Boolean, | ||
defaultValue: false, | ||
exports.entryModule = { | ||
name: 'entryModule', | ||
help: 'The name of a module that should act as the root page for documentation.', | ||
type: typedoc_1.ParameterType.String, | ||
}; | ||
@@ -135,0 +91,0 @@ /** |
@@ -6,3 +6,3 @@ declare module 'typedoc' { | ||
entryFileName: string; | ||
mergeReadme: boolean; | ||
entryModule: string; | ||
hidePageHeader: boolean; | ||
@@ -31,3 +31,3 @@ hidePageTitle: boolean; | ||
entryFileName: string; | ||
mergeReadme: boolean; | ||
entryModule: string; | ||
hidePageHeader: boolean; | ||
@@ -34,0 +34,0 @@ hidePageTitle: boolean; |
@@ -25,3 +25,2 @@ /** | ||
export declare function getSignatureParameters(parameters: ParameterReflection[], format?: boolean): string; | ||
export declare function getIndexFileName(project: ProjectReflection): "modules.md" | "exports.md"; | ||
export declare function hasReadme(project: ProjectReflection): boolean; |
@@ -9,3 +9,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasReadme = 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.hasReadme = 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; | ||
const typedoc_1 = require("typedoc"); | ||
@@ -85,3 +85,2 @@ const elements_1 = require("../support/elements"); | ||
function getMemberTitle(reflection) { | ||
var _a; | ||
const md = []; | ||
@@ -96,10 +95,7 @@ const name = []; | ||
name.push(`${(0, utils_1.escapeChars)(reflection.name)}`); | ||
if ((_a = reflection.signatures) === null || _a === void 0 ? void 0 : _a.length) { | ||
name.push('()'); | ||
} | ||
if (reflection.typeParameters) { | ||
const typeParameters = reflection.typeParameters | ||
.map((typeParameter) => typeParameter.name) | ||
.map((typeParameter) => (0, elements_1.backTicks)(typeParameter.name)) | ||
.join(', '); | ||
name.push(`${(0, elements_1.backTicks)(`<${typeParameters}>`)}`); | ||
name.push(`${`\\<${typeParameters}\\>`}`); | ||
} | ||
@@ -193,8 +189,2 @@ md.push(name.join('')); | ||
exports.getSignatureParameters = getSignatureParameters; | ||
function getIndexFileName(project) { | ||
var _a; | ||
const isModules = (_a = project.children) === null || _a === void 0 ? void 0 : _a.every((child) => child.kindOf(typedoc_1.ReflectionKind.Module)); | ||
return isModules ? 'modules.md' : 'exports.md'; | ||
} | ||
exports.getIndexFileName = getIndexFileName; | ||
function hasReadme(project) { | ||
@@ -201,0 +191,0 @@ return Boolean(project.readme); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NavigationContext = void 0; | ||
const typedoc_1 = require("typedoc"); | ||
const custom_maps_1 = require("../plugin/options/custom-maps"); | ||
class NavigationContext { | ||
@@ -12,20 +14,14 @@ constructor(theme, options) { | ||
var _a; | ||
const entryFileName = this.options.entryFileName; | ||
const hasReadme = !((_a = this.options.readme) === null || _a === void 0 ? void 0 : _a.endsWith('none')); | ||
const hasReadme = Boolean(project.readme); | ||
const containsOnlyModules = (_a = project === null || project === void 0 ? void 0 : project.children) === null || _a === void 0 ? void 0 : _a.every((child) => child.hasOwnDocument); | ||
if (hasReadme) { | ||
this.navigation.push({ | ||
title: 'Readme', | ||
url: entryFileName, | ||
}); | ||
this.navigation.push({ | ||
title: 'API', | ||
url: project.url, | ||
}); | ||
if (!containsOnlyModules && | ||
this.options.outputFileStrategy === custom_maps_1.OutputFileStrategy.Members && | ||
this.options.entryPointStrategy !== typedoc_1.EntryPointStrategy.Packages) { | ||
this.navigation.push({ | ||
title: 'Documentation', | ||
url: project.url, | ||
}); | ||
} | ||
} | ||
else { | ||
this.navigation.push({ | ||
title: 'API', | ||
url: entryFileName, | ||
}); | ||
} | ||
this.buildNavigationFromProject(project); | ||
@@ -35,19 +31,29 @@ return this.navigation; | ||
buildNavigationFromProject(project) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
if ((_a = project.groups) === null || _a === void 0 ? void 0 : _a.length) { | ||
if (project.groups.length === 1) { | ||
const entryModule = Boolean((_b = project === null || project === void 0 ? void 0 : project.groups[0]) === null || _b === void 0 ? void 0 : _b.children.find((child) => child.name === this.options.entryModule)); | ||
if ((project.groups.length === 1 && !Boolean(entryModule)) || | ||
(project.groups.length === 1 && | ||
this.options.outputFileStrategy === custom_maps_1.OutputFileStrategy.Modules)) { | ||
const children = this.getGroupChildren(project.groups[0]); | ||
if (children) { | ||
this.navigation.push(...children); | ||
this.navigation.push(...children.filter((child) => child.title !== this.options.entryModule)); | ||
} | ||
} | ||
else { | ||
(_b = project.groups) === null || _b === void 0 ? void 0 : _b.forEach((projectGroup) => { | ||
(_c = project.groups) === null || _c === void 0 ? void 0 : _c.forEach((projectGroup) => { | ||
const children = this.getGroupChildren(projectGroup); | ||
const indexModule = projectGroup.children.find((child) => child.name === this.options.entryModule); | ||
if (children.length) { | ||
this.navigation.push({ | ||
title: projectGroup.title, | ||
children, | ||
children: children.filter((child) => child.title !== this.options.entryModule), | ||
}); | ||
} | ||
if (indexModule) { | ||
const children = this.getChildrenOrGroups(indexModule); | ||
if (children) { | ||
this.navigation.push(...children); | ||
} | ||
} | ||
}); | ||
@@ -57,3 +63,3 @@ } | ||
else { | ||
(_c = project.children) === null || _c === void 0 ? void 0 : _c.forEach((child) => { | ||
(_d = project.children) === null || _d === void 0 ? void 0 : _d.forEach((child) => { | ||
this.navigation.push({ | ||
@@ -60,0 +66,0 @@ title: child.name, |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.breadcrumbs = void 0; | ||
const path = __importStar(require("path")); | ||
const elements_1 = require("../../../support/elements"); | ||
@@ -37,8 +13,2 @@ const utils_1 = require("../../../support/utils"); | ||
const md = []; | ||
if (page.url === page.project.url || | ||
(page.url === context.options.getValue('entryFileName') && | ||
page.url.split(path.sep).length === 1)) { | ||
return ''; | ||
} | ||
md.push((0, elements_1.link)((0, utils_1.escapeChars)(page.project.name), context.relativeURL(page.project.url))); | ||
const breadcrumb = (model) => { | ||
@@ -58,4 +28,4 @@ var _a; | ||
md.push(pageName); | ||
return md.length > 1 ? `${md.join(' / ')}` : ''; | ||
return md.length > 1 ? `${md.join('.')}` : ''; | ||
} | ||
exports.breadcrumbs = breadcrumbs; |
@@ -22,4 +22,4 @@ "use strict"; | ||
function projectHeader(context, page) { | ||
var _a, _b, _c; | ||
const entryFileName = context.options.getValue('entryFileName'); | ||
const indexFileName = (0, helpers_1.getIndexFileName)(page.project); | ||
const titleLink = context.options.getValue('titleLink'); | ||
@@ -29,29 +29,21 @@ const projectName = (0, helpers_1.getProjectDisplayName)(page.project, context.options.getValue('includeVersion')); | ||
if (Boolean(titleLink)) { | ||
md.push((0, elements_1.link)((0, elements_1.bold)(projectName), titleLink)); | ||
md.push((0, elements_1.link)(projectName, titleLink)); | ||
} | ||
else { | ||
md.push((0, elements_1.bold)(projectName)); | ||
md.push(projectName); | ||
} | ||
md.push('•'); | ||
if ((0, helpers_1.hasReadme)(page.project)) { | ||
if (!context.options.getValue('mergeReadme')) { | ||
const links = []; | ||
links.push('('); | ||
if (page.url === entryFileName) { | ||
links.push('Readme'); | ||
links.push('\\|'); | ||
} | ||
else { | ||
links.push((0, elements_1.link)('Readme', context.relativeURL(entryFileName))); | ||
links.push('\\|'); | ||
} | ||
if (page.url !== entryFileName) { | ||
links.push('API'); | ||
} | ||
else { | ||
links.push((0, elements_1.link)('API', context.relativeURL(indexFileName))); | ||
} | ||
links.push(')'); | ||
md.push(links.join(' ')); | ||
} | ||
const links = []; | ||
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; | ||
links.push((0, elements_1.link)('Readme', context.relativeURL(preserveModulesPage ? 'readme_.md' : entryFileName))); | ||
links.push('\\|'); | ||
links.push((0, elements_1.link)('Documentation', context.relativeURL(page.project.url))); | ||
md.push(links.join(' ')); | ||
} | ||
else { | ||
md.push((0, elements_1.link)('Documentation', context.relativeURL(page.project.url))); | ||
} | ||
return `${md.join(' ')}\n\n***\n`; | ||
@@ -68,23 +60,9 @@ } | ||
if ((0, helpers_1.hasReadme)(packageItem)) { | ||
if (!context.options.getValue('mergeReadme')) { | ||
const links = []; | ||
const readmeUrl = `${packageItem.name}/${entryFileName}`; | ||
links.push('('); | ||
if (page.url === readmeUrl) { | ||
links.push('Readme'); | ||
links.push('\\|'); | ||
} | ||
else { | ||
links.push((0, elements_1.link)('Readme', context.relativeURL(readmeUrl))); | ||
links.push('\\|'); | ||
} | ||
if (page.url !== readmeUrl) { | ||
links.push('API'); | ||
} | ||
else { | ||
links.push((0, elements_1.link)('API', context.relativeURL(packageItem.url))); | ||
} | ||
links.push(')'); | ||
md.push(links.join(' ')); | ||
} | ||
const links = []; | ||
const readmeUrl = `${packageItem.name}/${entryFileName}`; | ||
links.push('•'); | ||
links.push((0, elements_1.link)('Readme', context.relativeURL(readmeUrl))); | ||
links.push('\\|'); | ||
links.push((0, elements_1.link)('Documentation', context.relativeURL(packageItem.url))); | ||
md.push(links.join(' ')); | ||
} | ||
@@ -91,0 +69,0 @@ return `${md.join(' ')}\n\n***\n`; |
@@ -28,3 +28,2 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
const typedoc_1 = require("typedoc"); | ||
const elements_1 = require("../../../support/elements"); | ||
@@ -37,3 +36,3 @@ const utils_1 = require("../../../support/utils"); | ||
function pageIndex(context, page, headingLevel) { | ||
var _a, _b; | ||
var _a; | ||
const md = []; | ||
@@ -51,7 +50,3 @@ if (!page.model.groups) { | ||
if ((0, helpers_1.hasIndex)(page.model)) { | ||
const isModules = (_b = page.project.children) === null || _b === void 0 ? void 0 : _b.every((child) => child.kindOf(typedoc_1.ReflectionKind.Module)); | ||
if (!isModules) { | ||
md.push((0, elements_1.heading)(2, 'Exports')); | ||
} | ||
md.push(context.reflectionIndex(page.model, false, isModules ? headingLevel : headingLevel + 1)); | ||
md.push(context.reflectionIndex(page.model, false, headingLevel)); | ||
return md.join('\n\n'); | ||
@@ -58,0 +53,0 @@ } |
@@ -13,8 +13,6 @@ "use strict"; | ||
} | ||
if (!context.options.getValue('hideBreadcrumbs')) { | ||
md.push(context.breadcrumbs(page)); | ||
} | ||
if (!context.options.getValue('hidePageTitle')) { | ||
md.push((0, elements_1.heading)(1, context.pageTitle(page))); | ||
} | ||
md.push(context.breadcrumbs(page)); | ||
md.push(context.member(page.model, 1)); | ||
@@ -21,0 +19,0 @@ md.push(context.footer()); |
@@ -13,5 +13,2 @@ "use strict"; | ||
} | ||
if (!context.options.getValue('hideBreadcrumbs')) { | ||
md.push(context.breadcrumbs(page)); | ||
} | ||
if (!context.options.getValue('hidePageTitle')) { | ||
@@ -18,0 +15,0 @@ md.push((0, elements_1.heading)(1, context.pageTitle(page))); |
@@ -12,10 +12,4 @@ "use strict"; | ||
} | ||
if (!context.options.getValue('hideBreadcrumbs')) { | ||
md.push(context.breadcrumbs(page)); | ||
} | ||
if (page.model.readme) { | ||
md.push(context.commentParts(page.model.readme)); | ||
if (context.options.getValue('mergeReadme')) { | ||
md.push(getIndexReplacer(context, page)); | ||
} | ||
} | ||
@@ -26,10 +20,1 @@ md.push(context.footer()); | ||
exports.readmeTemplate = readmeTemplate; | ||
function getIndexReplacer(context, page) { | ||
const md = []; | ||
md.push(context.pageIndex(page, 2)); | ||
if (page.model.comment) { | ||
md.push(context.comment(page.model.comment, 2)); | ||
} | ||
md.push(context.members(page.model, 2)); | ||
return md.join('\n\n'); | ||
} |
@@ -13,8 +13,6 @@ "use strict"; | ||
} | ||
if (!context.options.getValue('hideBreadcrumbs')) { | ||
md.push(context.breadcrumbs(page)); | ||
} | ||
if (!context.options.getValue('hidePageTitle')) { | ||
md.push((0, elements_1.heading)(1, context.pageTitle(page))); | ||
} | ||
md.push(context.breadcrumbs(page)); | ||
md.push(context.reflectionMember(page.model, 2)); | ||
@@ -21,0 +19,0 @@ md.push(context.footer()); |
@@ -22,3 +22,3 @@ import { DeclarationReflection, PageEvent, ProjectReflection, Reflection, ReflectionKind, RenderTemplate, Renderer, Theme } from 'typedoc'; | ||
getNavigationContext(): NavigationContext; | ||
getUrlsContext(): UrlsContext; | ||
getUrlsContext(project: ProjectReflection): UrlsContext; | ||
readmeTemplate: (pageEvent: MarkdownPageEvent<ProjectReflection>) => string; | ||
@@ -25,0 +25,0 @@ projectTemplate: (pageEvent: MarkdownPageEvent<ProjectReflection>) => string; |
@@ -42,4 +42,4 @@ "use strict"; | ||
} | ||
getUrlsContext() { | ||
return new urls_context_1.UrlsContext(this, this.application.options.getRawValues()); | ||
getUrlsContext(project) { | ||
return new urls_context_1.UrlsContext(this, project, this.application.options.getRawValues()); | ||
} | ||
@@ -54,3 +54,3 @@ /** | ||
getUrls(project) { | ||
return this.getUrlsContext().getUrls(project); | ||
return this.getUrlsContext(project).getUrls(); | ||
} | ||
@@ -57,0 +57,0 @@ getNavigation(project) { |
import { DeclarationReflection, ProjectReflection, TypeDocOptions } from 'typedoc'; | ||
import { UrlMapping } from '../plugin/url-mapping'; | ||
import { NavigationItem, UrlOption } from '../theme/models'; | ||
import { UrlOption } from '../theme/models'; | ||
import { MarkdownTheme } from './theme'; | ||
export declare class UrlsContext { | ||
theme: MarkdownTheme; | ||
project: ProjectReflection; | ||
options: Partial<TypeDocOptions>; | ||
urls: UrlMapping[]; | ||
navigation: NavigationItem[]; | ||
anchors: Record<string, string[]>; | ||
constructor(theme: MarkdownTheme, options: Partial<TypeDocOptions>); | ||
hasReadme: boolean; | ||
preserveModulesPage: boolean; | ||
indexFilename: string; | ||
constructor(theme: MarkdownTheme, project: ProjectReflection, options: Partial<TypeDocOptions>); | ||
/** | ||
@@ -18,3 +21,3 @@ * Map the models of the given project to the desired output files. | ||
*/ | ||
getUrls(project: ProjectReflection): UrlMapping[]; | ||
getUrls(): UrlMapping[]; | ||
/** | ||
@@ -27,3 +30,4 @@ * | ||
private buildUrlsFromGroup; | ||
getUrl(reflection: DeclarationReflection, options: UrlOption): string; | ||
getUrl(reflection: DeclarationReflection, urlPath: string): string; | ||
getUrlPath(reflection: DeclarationReflection, options: UrlOption): string; | ||
private applyAnchorUrl; | ||
@@ -30,0 +34,0 @@ private getAnchorId; |
@@ -34,8 +34,15 @@ "use strict"; | ||
class UrlsContext { | ||
constructor(theme, options) { | ||
constructor(theme, project, options) { | ||
var _a, _b, _c; | ||
this.theme = theme; | ||
this.project = project; | ||
this.options = options; | ||
this.urls = []; | ||
this.navigation = []; | ||
this.anchors = {}; | ||
this.indexFilename = 'docs.md'; | ||
this.hasReadme = Boolean(this.project.readme); | ||
this.preserveModulesPage = | ||
(((_a = this.project) === null || _a === void 0 ? void 0 : _a.groups) && | ||
Boolean((_c = (_b = this.project) === null || _b === void 0 ? void 0 : _b.groups[0]) === null || _c === void 0 ? void 0 : _c.children.find((child) => child.name === this.options.entryModule))) || | ||
false; | ||
} | ||
@@ -48,22 +55,22 @@ /** | ||
*/ | ||
getUrls(project) { | ||
getUrls() { | ||
var _a; | ||
const isPackages = this.options.entryPointStrategy === typedoc_1.EntryPointStrategy.Packages && | ||
!Boolean(this.project.groups); | ||
const entryFileName = this.options.entryFileName; | ||
const indexFileName = (0, helpers_1.getIndexFileName)(project); | ||
const showIndex = !this.options.mergeReadme; | ||
if ((0, helpers_1.hasReadme)(project)) { | ||
project.url = showIndex ? indexFileName : entryFileName; | ||
this.urls.push(new url_mapping_1.UrlMapping(entryFileName, project, this.theme.readmeTemplate)); | ||
if (showIndex) { | ||
this.urls.push(new url_mapping_1.UrlMapping(indexFileName, project, this.theme.projectTemplate)); | ||
} | ||
this.project.url = Boolean(this.project.readme) | ||
? this.indexFilename | ||
: this.preserveModulesPage | ||
? this.indexFilename | ||
: this.options.entryFileName; | ||
if (Boolean(this.project.readme)) { | ||
this.urls.push(new url_mapping_1.UrlMapping(this.preserveModulesPage ? 'readme_.md' : entryFileName, this.project, this.theme.readmeTemplate)); | ||
this.urls.push(new url_mapping_1.UrlMapping(this.indexFilename, this.project, this.theme.projectTemplate)); | ||
} | ||
else { | ||
project.url = entryFileName; | ||
this.urls.push(new url_mapping_1.UrlMapping(entryFileName, project, this.theme.projectTemplate)); | ||
this.urls.push(new url_mapping_1.UrlMapping(this.preserveModulesPage ? this.indexFilename : entryFileName, this.project, this.theme.projectTemplate)); | ||
} | ||
if (this.options.entryPointStrategy === typedoc_1.EntryPointStrategy.Packages && | ||
!Boolean(project.groups)) { | ||
(_a = project.children) === null || _a === void 0 ? void 0 : _a.forEach((projectChild) => { | ||
const url = `${projectChild.name}/${Boolean(projectChild.readme) ? indexFileName : entryFileName}`; | ||
if (isPackages) { | ||
(_a = this.project.children) === null || _a === void 0 ? void 0 : _a.forEach((projectChild) => { | ||
const url = `${projectChild.name}/${Boolean(projectChild.readme) ? this.indexFilename : entryFileName}`; | ||
if (projectChild.readme) { | ||
@@ -78,3 +85,3 @@ this.urls.push(new url_mapping_1.UrlMapping(`${path.dirname(url)}/${entryFileName}`, projectChild, this.theme.readmeTemplate)); | ||
else { | ||
this.buildUrlsFromProject(project); | ||
this.buildUrlsFromProject(this.project); | ||
} | ||
@@ -104,6 +111,7 @@ return this.urls; | ||
const directory = options.directory || mapping.directory; | ||
const url = this.getUrl(reflection, { | ||
const urlPath = this.getUrlPath(reflection, { | ||
...options, | ||
directory, | ||
}); | ||
const url = this.getUrl(reflection, urlPath); | ||
this.urls.push(new url_mapping_1.UrlMapping(url, reflection, mapping.template)); | ||
@@ -116,3 +124,3 @@ reflection.url = url; | ||
this.buildUrlsFromGroup(groupChild, { | ||
parentUrl: url, | ||
parentUrl: urlPath, | ||
directory: (mapping === null || mapping === void 0 ? void 0 : mapping.directory) || null, | ||
@@ -127,4 +135,17 @@ }); | ||
} | ||
getUrl(reflection, options) { | ||
const alias = reflection.name.replace(/^_+/, ''); | ||
getUrl(reflection, urlPath) { | ||
if (reflection.name === this.options.entryModule) { | ||
return this.options.entryFileName; | ||
} | ||
if (this.options.outputFileStrategy === custom_maps_1.OutputFileStrategy.Modules && | ||
reflection.name === 'index') { | ||
return `module.index.md`; | ||
} | ||
return urlPath; | ||
} | ||
getUrlPath(reflection, options) { | ||
const alias = reflection.name | ||
.replace(/^_+/, '') | ||
.replace(/</, '-') | ||
.replace(/>/, '-'); | ||
const parentDir = options.parentUrl | ||
@@ -138,5 +159,2 @@ ? path.dirname(options.parentUrl) | ||
if (reflection.kind === typedoc_1.ReflectionKind.Module) { | ||
if (path.parse(this.options.entryFileName).name === alias) { | ||
return `module.${alias}`; | ||
} | ||
return alias; | ||
@@ -143,0 +161,0 @@ } |
{ | ||
"name": "typedoc-plugin-markdown", | ||
"version": "4.0.0-next.27", | ||
"version": "4.0.0-next.28", | ||
"description": "A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.", | ||
@@ -18,3 +18,4 @@ "main": "dist/index.js", | ||
"test:lint-mdx": "node test/__scripts__/lint.mdx.mjs", | ||
"test:jest": "jest", | ||
"test:jest": "jest --updateSnapshot", | ||
"build-and-run": "npm run build && npm run pretest", | ||
"build-and-test": "npm run build && npm run test", | ||
@@ -21,0 +22,0 @@ "api-docs": "npm run build && typedoc --options ./typedoc.api.js --out ./docs/api", |
# 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) [![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) | ||
@@ -11,8 +11,8 @@ > **Please note this pre-release version may contain breaking changes within the same semantic version.** | ||
- [What does it do?](#what-does-it-do) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Options](#options) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
* [What does it do?](#what-does-it-do) | ||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
* [Options](#options) | ||
* [Contributing](#contributing) | ||
* [License](#license) | ||
@@ -59,6 +59,6 @@ ## What does it do? | ||
- [`--outputFileStrategy`](./docs/plugin-options.md#--outputfilestrategy) | ||
- [`--membersWithOwnFile`](./docs/plugin-options.md#--memberswithownfile) | ||
- [`--entryFileName`](./docs/plugin-options.md#--entryfilename) | ||
- [`--mergeReadme`](./docs/plugin-options.md#--mergereadme) | ||
* [`--outputFileStrategy`](./docs/plugin-options.md#--outputfilestrategy) | ||
* [`--membersWithOwnFile`](./docs/plugin-options.md#--memberswithownfile) | ||
* [`--entryFileName`](./docs/plugin-options.md#--entryfilename) | ||
* [`--entryModule`](./docs/plugin-options.md#--entrymodule) | ||
@@ -69,16 +69,16 @@ #### Structure and formatting options | ||
- [`--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) | ||
* [`--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) | ||
@@ -89,5 +89,5 @@ #### Utility options | ||
- [`--preserveAnchorCasing`](./docs/plugin-options.md#--preserveanchorcasing) | ||
- [`--anchorPrefix`](./docs/plugin-options.md#--anchorprefix) | ||
- [`--namedAnchors`](./docs/plugin-options.md#--namedanchors) | ||
* [`--preserveAnchorCasing`](./docs/plugin-options.md#--preserveanchorcasing) | ||
* [`--anchorPrefix`](./docs/plugin-options.md#--anchorprefix) | ||
* [`--namedAnchors`](./docs/plugin-options.md#--namedanchors) | ||
@@ -94,0 +94,0 @@ ## Contributing |
197878
4631