From 68afc7c528dce6283cf69c27af259478dc4f10cc Mon Sep 17 00:00:00 2001 From: tgreyuk Date: Sat, 18 May 2024 11:46:06 +0100 Subject: [PATCH] feat(core): typedoc@0.26 documents implementation --- .../examples/docusaurus/docusaurus.config.js | 15 +- devtools/examples/docusaurus/sidebars.js | 4 +- devtools/packages/fixtures/cli.ts | 14 +- devtools/packages/helpers/constants.ts | 2 + devtools/packages/helpers/models.ts | 1 + .../prebuild-options/tasks/generate-models.ts | 96 +- docs/pages/docs/options.mdx | 85 +- package-lock.json | 261 ++-- package.json | 16 +- .../src/defs/typedoc.d.ts | 8 + .../src/options/option-types.ts | 8 - .../__snapshots__/docusaurus.spec.ts.snap | 4 +- .../src/defs/typedoc.d.ts | 8 + .../src/options/option-types.ts | 8 - .../src/defs/typedoc.d.ts | 8 + .../src/options/option-types.ts | 8 - .../src/defs/typedoc.d.ts | 15 + .../src/options/option-types.ts | 17 +- .../typedoc-plugin-frontmatter/tsdoc.json | 14 + .../.scripts/prebuild-resources.ts | 5 +- .../.scripts/prebuild.ts | 2 - .../.scripts/schema/generate-schema.ts | 2 +- packages/typedoc-plugin-markdown/package.json | 11 +- .../src/app/renderer/overrides.ts | 4 +- .../src/app/translatable.ts | 73 + .../src/defs/typedoc.d.ts | 84 ++ packages/typedoc-plugin-markdown/src/index.ts | 9 +- .../src/libs/markdown/index.ts | 2 +- .../get-file-name-with-extension.spec.ts | 22 +- .../utils/get-file-name-with-extension.ts | 5 +- .../src/libs/utils/index.ts | 5 +- .../src/libs/utils/to-pascal-case.spec.ts | 7 + .../src/libs/utils/to-pascal-case.ts | 6 + .../src/options/declarations.ts | 33 +- .../src/options/index.ts | 1 - .../src/options/option-types.ts | 127 +- .../src/options/text-mappings/index.ts | 2 - .../options/text-mappings/kind-defaults.ts | 78 -- .../text-mappings/text-mapping-defaults.ts | 37 - .../typedoc-plugin-markdown/src/public-api.ts | 2 +- .../src/theme/core/navigation-builder.ts | 225 ++-- .../src/theme/core/url-builder.ts | 441 ++++--- .../src/theme/markdown-theme.ts | 43 +- .../src/theme/markdown-themecontext.ts | 23 +- .../helpers/get-declaration-comment.ts | 8 - .../helpers/get-description-for-reflection.ts | 18 + .../resources/helpers/get-group-index-list.ts | 20 + .../helpers/get-group-index-table.ts | 38 + .../resources/helpers/get-group-index.ts | 17 + .../src/theme/resources/index.ts | 125 +- .../partials/comments.commentParts.ts | 14 +- .../resources/partials/container.body.ts | 14 +- .../partials/container.categories.ts | 4 +- .../resources/partials/container.groups.ts | 29 +- .../resources/partials/container.members.ts | 6 +- .../resources/partials/member.accessor.ts | 9 +- .../resources/partials/member.container.ts | 35 + .../resources/partials/member.declaration.ts | 44 +- .../resources/partials/member.documents.ts | 39 + .../partials/member.enumMembersTable.ts | 8 +- .../resources/partials/member.hierarchy.ts | 6 +- .../resources/partials/member.inheritance.ts | 8 +- .../resources/partials/member.memberTitle.ts | 5 +- .../partials/member.memberWithGroups.ts | 48 +- .../partials/member.parametersTable.ts | 8 +- .../partials/member.propertiesTable.ts | 22 +- .../resources/partials/member.reference.ts | 4 +- .../partials/member.reflectionIndex.ts | 127 +- .../resources/partials/member.signature.ts | 35 +- .../partials/member.signatureReturns.ts | 2 +- .../resources/partials/member.signatures.ts | 62 + .../resources/partials/member.sources.ts | 2 +- .../src/theme/resources/partials/member.ts | 103 +- .../partials/member.typeDeclarationList.ts | 2 +- .../partials/member.typeDeclarationTable.ts | 8 +- .../partials/member.typeParametersTable.ts | 11 +- .../resources/partials/page.breadcrumbs.ts | 5 +- .../theme/resources/partials/page.footer.ts | 2 +- .../theme/resources/partials/page.header.ts | 9 +- .../resources/partials/page.packagesIndex.ts | 8 +- .../resources/partials/page.pageTitle.ts | 34 +- .../partials/type.reflection.declaration.ts | 32 +- .../src/theme/resources/templates/document.ts | 27 + .../src/theme/resources/templates/project.ts | 35 +- .../src/theme/resources/templates/read-me.ts | 14 +- .../theme/resources/templates/reflection.ts | 14 +- .../test/fixtures/PROJECT_DOC_1.md | 8 + .../test/fixtures/config.ts | 56 +- .../custom-plugins/stub-documents-theme.mjs | 42 + .../fixtures/custom-plugins/urls-plugin.mjs | 19 + .../fixtures/docs/project/PROJECT_DOC_2.md | 3 + .../fixtures/docs/project/PROJECT_DOC_3.md | 3 + .../fixtures/docs/reflection/CLASS_DOC.md | 3 + .../test/fixtures/docs/reflection/ENUM_DOC.md | 3 + .../docs/reflection/FUNCTION_DOC_1.md | 3 + .../docs/reflection/FUNCTION_DOC_2.md | 3 + .../docs/reflection/FUNCTION_DOC_3.md | 3 + .../fixtures/docs/reflection/INTERFACE_DOC.md | 3 + .../fixtures/docs/reflection/MODULE_DOC.md | 3 + .../fixtures/docs/reflection/NAMESPACE_DOC.md | 3 + .../test/fixtures/docs/reflection/TYPE_DOC.md | 3 + .../fixtures/docs/reflection/VARIABLE_DOC.md | 3 + .../test/fixtures/src/comments/index.ts | 19 +- .../test/fixtures/src/documents/module-1.ts | 77 ++ .../test/fixtures/src/documents/module-2.ts | 66 + .../test/fixtures/src/reflections/classes.ts | 4 - .../fixtures/src/reflections/functions.ts | 3 +- .../fixtures/src/reflections/interfaces.ts | 2 +- .../test/fixtures/typedoc-documents.json | 775 +++++++++++ .../specs/__snapshots__/comments.spec.ts.snap | 46 +- .../__snapshots__/documents.spec.ts.snap | 336 +++++ .../specs/__snapshots__/groups.spec.ts.snap | 16 + .../__snapshots__/navigation.spec.ts.snap | 1172 ++++++++++++++++- .../objects-and-params.spec.ts.snap | 20 +- .../reflection.class.spec.ts.snap | 36 +- .../reflection.function.spec.ts.snap | 22 +- .../reflection.interface.spec.ts.snap | 24 +- .../reflection.type-alias.spec.ts.snap | 92 +- .../specs/__snapshots__/text.spec.ts.snap | 16 +- .../specs/__snapshots__/urls.spec.ts.snap | 251 +++- .../test/specs/comments.spec.ts | 2 +- .../test/specs/documents.spec.ts | 118 ++ .../test/specs/navigation.spec.ts | 12 + .../test/specs/urls.spec.ts | 8 + .../src/defs/typedoc.d.ts | 10 + .../src/options/option-types.ts | 9 - .../specs/__snapshots__/remark.spec.ts.snap | 26 +- .../src/defs/typedoc.d.ts | 9 + .../src/options/option-types.ts | 9 - 129 files changed, 4727 insertions(+), 1516 deletions(-) create mode 100644 packages/docusaurus-plugin-typedoc/src/defs/typedoc.d.ts create mode 100644 packages/typedoc-github-wiki-theme/src/defs/typedoc.d.ts create mode 100644 packages/typedoc-gitlab-wiki-theme/src/defs/typedoc.d.ts create mode 100644 packages/typedoc-plugin-frontmatter/src/defs/typedoc.d.ts create mode 100644 packages/typedoc-plugin-frontmatter/tsdoc.json create mode 100644 packages/typedoc-plugin-markdown/src/app/translatable.ts create mode 100644 packages/typedoc-plugin-markdown/src/defs/typedoc.d.ts create mode 100644 packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.spec.ts create mode 100644 packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.ts delete mode 100644 packages/typedoc-plugin-markdown/src/options/text-mappings/index.ts delete mode 100644 packages/typedoc-plugin-markdown/src/options/text-mappings/kind-defaults.ts delete mode 100644 packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts delete mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-declaration-comment.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-description-for-reflection.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-list.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-table.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/partials/member.container.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/partials/member.documents.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatures.ts create mode 100644 packages/typedoc-plugin-markdown/src/theme/resources/templates/document.ts create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/PROJECT_DOC_1.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/stub-documents-theme.mjs create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/urls-plugin.mjs create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_2.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_3.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/CLASS_DOC.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/ENUM_DOC.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_1.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_2.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_3.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/INTERFACE_DOC.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/MODULE_DOC.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/NAMESPACE_DOC.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/TYPE_DOC.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/VARIABLE_DOC.md create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-1.ts create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-2.ts create mode 100644 packages/typedoc-plugin-markdown/test/fixtures/typedoc-documents.json create mode 100644 packages/typedoc-plugin-markdown/test/specs/__snapshots__/documents.spec.ts.snap create mode 100644 packages/typedoc-plugin-markdown/test/specs/documents.spec.ts create mode 100644 packages/typedoc-plugin-remark/src/defs/typedoc.d.ts create mode 100644 packages/typedoc-vitepress-theme/src/defs/typedoc.d.ts diff --git a/devtools/examples/docusaurus/docusaurus.config.js b/devtools/examples/docusaurus/docusaurus.config.js index 50bdd6998..c9fabc0ef 100644 --- a/devtools/examples/docusaurus/docusaurus.config.js +++ b/devtools/examples/docusaurus/docusaurus.config.js @@ -58,17 +58,24 @@ const config = { __dirname, '../../../packages/typedoc-plugin-markdown/test/fixtures/tsconfig.json', ), - entryPoints: - '../../../packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts', + entryPoints: [ + '../../../packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-1.ts', + '../../../packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-2.ts', + ], expandObjects: true, readme: 'none', sidebar: { pretty: true }, outputFileStrategy: 'members', propertiesFormat: 'htmlTable', cleanOutputDir: true, + projectDocuments: [ + '../../../packages/typedoc-plugin-markdown/test/fixtures/PROJECT_DOC_1.md', + '../../../packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_2.md', + '../../../packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_3.md', + ], }, ], - [ + /*[ docusaurusPlugin, { id: 'api-2', @@ -100,7 +107,7 @@ const config = { }, }, ], - /*[ + [ docusaurusPlugin, { id: 'api-3', diff --git a/devtools/examples/docusaurus/sidebars.js b/devtools/examples/docusaurus/sidebars.js index 5a204fc5b..ffefa930e 100644 --- a/devtools/examples/docusaurus/sidebars.js +++ b/devtools/examples/docusaurus/sidebars.js @@ -24,7 +24,7 @@ const sidebars = { }, items: require('./docs/api/typedoc-sidebar.cjs'), }, - { + /*{ type: 'category', label: 'DOCS 2', link: { @@ -33,7 +33,7 @@ const sidebars = { }, items: require('./docs/api-2/typedoc-sidebar.cjs'), }, - /*{ + { type: 'category', label: 'DOCS 3', link: { diff --git a/devtools/packages/fixtures/cli.ts b/devtools/packages/fixtures/cli.ts index 0df47c2de..4498a1704 100755 --- a/devtools/packages/fixtures/cli.ts +++ b/devtools/packages/fixtures/cli.ts @@ -41,7 +41,7 @@ async function main() { const outputFileStrategies: ('members' | 'modules')[] = config.outputFileStrategies || ['members', 'modules']; - //writeHtml(key, config.entryPoints); + writeHtml(key, config.entryPoints); outputFileStrategies.forEach((outputFileStrategy) => { config.options.forEach((optionGroup, index: number) => { const options = { @@ -99,6 +99,10 @@ function writeMarkdown( } export function writeHtml(key: string, entryPoints: string[]) { + const fixturesRoot = path.join( + __dirname, + '../../../packages/typedoc-plugin-markdown/test/fixtures', + ); const fullPath = path.join( process.cwd(), 'test', @@ -117,6 +121,14 @@ export function writeHtml(key: string, entryPoints: string[]) { 'Warn', '-out', fullPath, + '-readme', + 'none', + '-projectDocuments', + path.join(fixturesRoot, 'PROJECT_DOC_1.md'), + '-projectDocuments', + path.join(fixturesRoot, 'docs/project/PROJECT_DOC_2.md'), + '-projectDocuments', + path.join(fixturesRoot, 'docs/project/PROJECT_DOC_3.md'), ], ...toEntryPoints(entryPoints), ], diff --git a/devtools/packages/helpers/constants.ts b/devtools/packages/helpers/constants.ts index afc70cc96..253b0ea78 100644 --- a/devtools/packages/helpers/constants.ts +++ b/devtools/packages/helpers/constants.ts @@ -1,10 +1,12 @@ import { DocsConfig } from './models'; +export const SRC_PATH = `${process.cwd()}/src`; export const PRESETS_PATH = `${process.cwd()}/src/options/presets.ts`; export const DOCS_CONFIG: Record = { ['typedoc-plugin-markdown']: { declarationsPath: `${process.cwd()}/src/options/declarations.ts`, + translatablePath: `${process.cwd()}/src/app/translatable.ts`, optionsPath: '/docs', docsPath: '/docs', declarations: true, diff --git a/devtools/packages/helpers/models.ts b/devtools/packages/helpers/models.ts index 40446e082..5657b833b 100644 --- a/devtools/packages/helpers/models.ts +++ b/devtools/packages/helpers/models.ts @@ -1,5 +1,6 @@ export interface DocsConfig { declarationsPath?: string; + translatablePath?: string; presetsPath?: string; optionsPath: string; docsPath: string; diff --git a/devtools/packages/prebuild-options/tasks/generate-models.ts b/devtools/packages/prebuild-options/tasks/generate-models.ts index ec8a7a93f..7d006ec85 100644 --- a/devtools/packages/prebuild-options/tasks/generate-models.ts +++ b/devtools/packages/prebuild-options/tasks/generate-models.ts @@ -1,4 +1,4 @@ -import { DocsConfig } from '@devtools/helpers'; +import { DocsConfig, SRC_PATH } from '@devtools/helpers'; import * as fs from 'fs'; import * as path from 'path'; import * as prettier from 'prettier'; @@ -11,36 +11,75 @@ import { DeclarationOption, ParameterType } from 'typedoc'; export async function generateOptionsModels(docsConfig: DocsConfig) { const optionsConfig = await import(docsConfig.declarationsPath as string); - const mixedTypes = (Object.entries(optionsConfig) as any).filter( - ([name, option]) => - option.type === ParameterType.Mixed && option.defaultValue, - ); - - const containsManuallyValidatedOptions = Object.values(optionsConfig).some( - (option) => - (option as any).type === ParameterType.Mixed && - (option as any).defaultValue, - ); - const sortedOptionsConfig = Object.fromEntries( Object.entries(optionsConfig).sort((a, b) => a[0].localeCompare(b[0])), ); - const optionsOutput = ` - // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. + await writeTypeDocDeclarations(docsConfig, sortedOptionsConfig); + await writeOptionsTypes(docsConfig, sortedOptionsConfig); +} - ${ - containsManuallyValidatedOptions && - `import { ManuallyValidatedOption } from 'typedoc'` - }; +async function writeTypeDocDeclarations( + docsConfig: DocsConfig, + sortedOptionsConfig: any, +) { + const typedocDeclarationsFile = path.join(SRC_PATH, 'defs', 'typedoc.d.ts'); + + const manuallyValidatedOptions = Object.entries(sortedOptionsConfig) + .filter( + ([name, option]) => + (option as any).type === ParameterType.Mixed && + (option as any).defaultValue, + ) + .map(([name, option]) => capitalize(name)); + + const out: string[] = []; + + out.push(`// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'`); - declare module 'typedoc' { - export interface TypeDocOptionMap { - ${(Object.entries(sortedOptionsConfig) as any) - .map(([name, option]) => `${name}: ${getType(name, option)};`) - .join('\n')} - } + if (manuallyValidatedOptions.length) { + manuallyValidatedOptions.forEach((option: any) => { + out.push(`import { ${option} } from '../options/option-types';`); + }); + } + + out.push(`declare module 'typedoc' {`); + out.push(`export interface TypeDocOptionMap { + ${(Object.entries(sortedOptionsConfig) as any) + .map(([name, option]) => `${name}: ${getType(name, option)};`) + .join('\n')} + }`); + + if (docsConfig.translatablePath) { + const { translatable } = await import(docsConfig.translatablePath); + out.push(` + // eslint-disable-next-line @typescript-eslint/no-namespace + export namespace Internationalization { + export interface TranslatableStrings ${getTranslations(translatable)} + }`); } + out.push(`}`); + const formatted = await prettier.format(out.join('\n'), { + parser: 'typescript', + singleQuote: true, + trailingComma: 'all', + }); + + fs.writeFileSync(typedocDeclarationsFile, formatted); +} + +async function writeOptionsTypes( + docsConfig: DocsConfig, + sortedOptionsConfig: any, +) { + const mixedTypes = (Object.entries(sortedOptionsConfig) as any).filter( + ([name, option]) => + option.type === ParameterType.Mixed && option.defaultValue, + ); + + const optionsOutput = ` + // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. /** * Describes the options declared by the plugin. @@ -94,6 +133,15 @@ ${name}: ${getType(name, option, true)};`, fs.writeFileSync(optionsModelFile, formatted); } +function getTranslations(inputObject: { [key: string]: string }) { + const output: { [key: string]: string[] } = {}; + for (const [key, value] of Object.entries(inputObject)) { + const matches = value.match(/{\d+}/g) || []; + output[key] = matches.map(() => 'string'); + } + return JSON.stringify(output).replace(/"/g, ''); +} + function getComments(name: string) { if (name === 'textContentMappings') { return 'Describes the keys available to replace static text.'; diff --git a/docs/pages/docs/options.mdx b/docs/pages/docs/options.mdx index b4111226d..635d21a51 100644 --- a/docs/pages/docs/options.mdx +++ b/docs/pages/docs/options.mdx @@ -294,6 +294,22 @@ Ignored if `flattenOutputFiles` is set to `true`. --- +### inlineDocuments + +Inline documents in pages. + +> Accepts a boolean value. Defaults to `false`. + +By default a documents index and separate documents pages are generated when using the `@document` tag. + +```json filename="typedoc.json" +{ + "inlineDocuments": false +} +``` + +--- + ### excludeGroups @@ -540,74 +556,7 @@ Only keys that require translation need to be added to the object. ```json filename="typedoc.json" { - "textContentMappings": { - "header.title": "{projectName} {version}", - "header.docs": "Docs", - "breadcrumbs.home": "{projectName} {version}", - "footer.text": "", - "title.indexPage": "{projectName} {version}", - "title.modulePage": "{name}", - "title.memberPage": "{kind}: {name}", - "label.apiIndex": "API Index", - "label.defaultValue": "Default value", - "label.description": "Description", - "label.extendedBy": "Extended by", - "label.extends": "Extends", - "label.flags": "Flags", - "label.globals": "Globals", - "label.implements": "Implements", - "label.implementationOf": "Implementation of", - "label.inheritedFrom": "Inherited from", - "label.index": "Index", - "label.indexable": "Indexable", - "label.indexSignature": "Index signature", - "label.member": "Member", - "label.modifier": "Modifier", - "label.name": "Name", - "label.overrides": "Overrides", - "label.packages": "Packages", - "label.reExports": "Re-exports", - "label.renamesAndReExports": "Renames and re-exports", - "label.returns": "Returns", - "label.source": "Source", - "label.type": "Type", - "label.typeDeclaration": "Type declaration", - "label.value": "Value", - "kind.accessor.singular": "Accessor", - "kind.accessor.plural": "Accessors", - "kind.class.singular": "Class", - "kind.class.plural": "Classes", - "kind.constructor.singular": "Constructor", - "kind.constructor.plural": "Constructors", - "kind.enum.singular": "Enumeration", - "kind.enum.plural": "Enumerations", - "kind.enumMember.singular": "Enumeration Member", - "kind.enumMember.plural": "Enumeration Members", - "kind.event.singular": "Event", - "kind.event.plural": "Events", - "kind.function.singular": "Function", - "kind.function.plural": "Functions", - "kind.interface.singular": "Interface", - "kind.interface.plural": "Interfaces", - "kind.method.singular": "Method", - "kind.method.plural": "Methods", - "kind.module.singular": "Module", - "kind.module.plural": "Modules", - "kind.namespace.singular": "Namespace", - "kind.namespace.plural": "Namespaces", - "kind.variable.singular": "Variable", - "kind.variable.plural": "Variables", - "kind.parameter.singular": "Parameter", - "kind.parameter.plural": "Parameters", - "kind.property.singular": "Property", - "kind.property.plural": "Properties", - "kind.reference.singular": "Reference", - "kind.reference.plural": "References", - "kind.typeAlias.singular": "Type alias", - "kind.typeAlias.plural": "Type Aliases", - "kind.typeParameter.singular": "Type parameter", - "kind.typeParameter.plural": "Type parameters" - } + "textContentMappings": {} } ``` diff --git a/package-lock.json b/package-lock.json index 560e4bd92..f318b2cbb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,19 +15,19 @@ "devtools/packages/*" ], "devDependencies": { - "@changesets/cli": "^2.27.1", + "@changesets/cli": "^2.27.2", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.12", - "@types/node": "^20.12.7", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", + "@types/node": "^20.12.12", + "@typescript-eslint/eslint-plugin": "^7.9.0", + "@typescript-eslint/parser": "^7.9.0", "consola": "^3.2.3", "copyfiles": "^2.4.1", - "eslint": "^8.57.0", + "eslint": "8.57.0", "fs-extra": "^11.2.0", - "glob": "^10.3.12", + "glob": "^10.3.15", "husky": "^9.0.11", "jest": "^29.7.0", "markdownlint": "^0.34.0", @@ -43,8 +43,8 @@ "ts-json-schema-generator": "^2.1.1", "ts-morph": "^22.0.0", "ts-node": "^10.9.2", - "tsc-alias": "^1.8.8", - "typedoc": "0.25.13", + "tsc-alias": "^1.8.10", + "typedoc": "^0.26.0-beta.1", "typescript": "^5.4.5", "unified-prettier": "^2.0.1" } @@ -2055,9 +2055,9 @@ "dev": true }, "node_modules/@changesets/apply-release-plan": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.0.0.tgz", - "integrity": "sha512-vfi69JR416qC9hWmFGSxj7N6wA5J222XNBmezSVATPWDVPIF7gkd4d8CpbEbXmRWbVrkoli3oerGS6dcL/BGsQ==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.0.1.tgz", + "integrity": "sha512-aPdSq/R++HOyfEeBGjEe6LNG8gs0KMSyRETD/J2092OkNq8mOioAxyKjMbvVUdzgr/HTawzMOz7lfw339KnsCA==", "dev": true, "dependencies": { "@babel/runtime": "^7.20.1", @@ -2128,13 +2128,13 @@ } }, "node_modules/@changesets/cli": { - "version": "2.27.1", - "resolved": "https://registry.npmjs.org/@changesets/cli/-/cli-2.27.1.tgz", - "integrity": "sha512-iJ91xlvRnnrJnELTp4eJJEOPjgpF3NOh4qeQehM6Ugiz9gJPRZ2t+TsXun6E3AMN4hScZKjqVXl0TX+C7AB3ZQ==", + "version": "2.27.2", + "resolved": "https://registry.npmjs.org/@changesets/cli/-/cli-2.27.2.tgz", + "integrity": "sha512-6/kADjKMOrlLwNr/Y5HAq7T9oGOA2Lq5A59AGtwQCCiXuSGp4EgszzdJFeBiF8pdz7Wn1HaLzSUBhAaNToEJqg==", "dev": true, "dependencies": { "@babel/runtime": "^7.20.1", - "@changesets/apply-release-plan": "^7.0.0", + "@changesets/apply-release-plan": "^7.0.1", "@changesets/assemble-release-plan": "^6.0.0", "@changesets/changelog-git": "^0.2.0", "@changesets/config": "^3.0.0", @@ -2146,7 +2146,7 @@ "@changesets/pre": "^2.0.0", "@changesets/read": "^0.6.0", "@changesets/types": "^6.0.0", - "@changesets/write": "^0.3.0", + "@changesets/write": "^0.3.1", "@manypkg/get-packages": "^1.1.3", "@types/semver": "^7.5.0", "ansi-colors": "^4.1.3", @@ -2368,9 +2368,9 @@ "dev": true }, "node_modules/@changesets/write": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@changesets/write/-/write-0.3.0.tgz", - "integrity": "sha512-slGLb21fxZVUYbyea+94uFiD6ntQW0M2hIKNznFizDhZPDgn2c/fv1UzzlW43RVzh1BEDuIqW6hzlJ1OflNmcw==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@changesets/write/-/write-0.3.1.tgz", + "integrity": "sha512-SyGtMXzH3qFqlHKcvFY2eX+6b0NGiFcNav8AFsYwy5l8hejOeoeTDemu5Yjmke2V5jpzY+pBvM0vCCQ3gdZpfw==", "dev": true, "dependencies": { "@babel/runtime": "^7.20.1", @@ -5048,6 +5048,11 @@ "integrity": "sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==", "dev": true }, + "node_modules/@shikijs/core": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.5.2.tgz", + "integrity": "sha512-wSAOgaz48GmhILFElMCeQypSZmj6Ru6DttOOtl3KNkdJ17ApQuGNCfzpk4cClasVrnIu45++2DBwG4LNMQAfaA==" + }, "node_modules/@sideway/address": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz", @@ -5835,9 +5840,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "20.12.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", - "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -5985,21 +5990,19 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.6.0.tgz", - "integrity": "sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.9.0.tgz", + "integrity": "sha512-6e+X0X3sFe/G/54aC3jt0txuMTURqLyekmEHViqyA2VnxhLMpvA6nqmcjIy+Cr9tLDHPssA74BP5Mx9HQIxBEA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/type-utils": "7.6.0", - "@typescript-eslint/utils": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", - "debug": "^4.3.4", + "@typescript-eslint/scope-manager": "7.9.0", + "@typescript-eslint/type-utils": "7.9.0", + "@typescript-eslint/utils": "7.9.0", + "@typescript-eslint/visitor-keys": "7.9.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", - "semver": "^7.6.0", "ts-api-utils": "^1.3.0" }, "engines": { @@ -6020,15 +6023,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.6.0.tgz", - "integrity": "sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.9.0.tgz", + "integrity": "sha512-qHMJfkL5qvgQB2aLvhUSXxbK7OLnDkwPzFalg458pxQgfxKDfT1ZDbHQM/I6mDIf/svlMkj21kzKuQ2ixJlatQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/typescript-estree": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/scope-manager": "7.9.0", + "@typescript-eslint/types": "7.9.0", + "@typescript-eslint/typescript-estree": "7.9.0", + "@typescript-eslint/visitor-keys": "7.9.0", "debug": "^4.3.4" }, "engines": { @@ -6048,13 +6051,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.6.0.tgz", - "integrity": "sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.9.0.tgz", + "integrity": "sha512-ZwPK4DeCDxr3GJltRz5iZejPFAAr4Wk3+2WIBaj1L5PYK5RgxExu/Y68FFVclN0y6GGwH8q+KgKRCvaTmFBbgQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0" + "@typescript-eslint/types": "7.9.0", + "@typescript-eslint/visitor-keys": "7.9.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -6065,13 +6068,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.6.0.tgz", - "integrity": "sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.9.0.tgz", + "integrity": "sha512-6Qy8dfut0PFrFRAZsGzuLoM4hre4gjzWJB6sUvdunCYZsYemTkzZNwF1rnGea326PHPT3zn5Lmg32M/xfJfByA==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.6.0", - "@typescript-eslint/utils": "7.6.0", + "@typescript-eslint/typescript-estree": "7.9.0", + "@typescript-eslint/utils": "7.9.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -6092,9 +6095,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.6.0.tgz", - "integrity": "sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.9.0.tgz", + "integrity": "sha512-oZQD9HEWQanl9UfsbGVcZ2cGaR0YT5476xfWE0oE5kQa2sNK2frxOlkeacLOTh9po4AlUT5rtkGyYM5kew0z5w==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -6105,13 +6108,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.6.0.tgz", - "integrity": "sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.9.0.tgz", + "integrity": "sha512-zBCMCkrb2YjpKV3LA0ZJubtKCDxLttxfdGmwZvTqqWevUPN0FZvSI26FalGFFUZU/9YQK/A4xcQF9o/VVaCKAg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/visitor-keys": "7.6.0", + "@typescript-eslint/types": "7.9.0", + "@typescript-eslint/visitor-keys": "7.9.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -6133,18 +6136,15 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.6.0.tgz", - "integrity": "sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.9.0.tgz", + "integrity": "sha512-5KVRQCzZajmT4Ep+NEgjXCvjuypVvYHUW7RHlXzNPuak2oWpVoD1jf5xCP0dPAuNIchjC7uQyvbdaSTFaLqSdA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@types/json-schema": "^7.0.15", - "@types/semver": "^7.5.8", - "@typescript-eslint/scope-manager": "7.6.0", - "@typescript-eslint/types": "7.6.0", - "@typescript-eslint/typescript-estree": "7.6.0", - "semver": "^7.6.0" + "@typescript-eslint/scope-manager": "7.9.0", + "@typescript-eslint/types": "7.9.0", + "@typescript-eslint/typescript-estree": "7.9.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -6158,12 +6158,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.6.0.tgz", - "integrity": "sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.9.0.tgz", + "integrity": "sha512-iESPx2TNLDNGQLyjKhUvIKprlP49XNEK+MvIf9nIO7ZZaZdbnfWKHnXAgufpxqfA0YryH8XToi4+CjBgVnFTSQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.6.0", + "@typescript-eslint/types": "7.9.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -6583,11 +6583,6 @@ "node": ">=8" } }, - "node_modules/ansi-sequence-parser": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz", - "integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==" - }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -9487,7 +9482,6 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, "engines": { "node": ">=0.12" }, @@ -11299,22 +11293,22 @@ "dev": true }, "node_modules/glob": { - "version": "10.3.12", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", - "integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==", + "version": "10.3.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.15.tgz", + "integrity": "sha512-0c6RlJt1TICLyvJYIApxb8GsXoai0KUP7AxKKAtsYXdgJR1mGEUa7DgwShbdk1nly0PYoZj01xd4hzbq3fsjpw==", "dev": true, "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^2.3.6", "minimatch": "^9.0.1", "minipass": "^7.0.4", - "path-scurry": "^1.10.2" + "path-scurry": "^1.11.0" }, "bin": { "glob": "dist/esm/bin.mjs" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -14950,11 +14944,6 @@ "node": ">=6" } }, - "node_modules/jsonc-parser": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", - "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==" - }, "node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -15082,7 +15071,6 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", - "dev": true, "dependencies": { "uc.micro": "^2.0.0" } @@ -15332,7 +15320,6 @@ "version": "14.1.0", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", - "dev": true, "dependencies": { "argparse": "^2.0.1", "entities": "^4.4.0", @@ -15348,8 +15335,7 @@ "node_modules/markdown-it/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/markdown-table": { "version": "3.0.3", @@ -15388,17 +15374,6 @@ "url": "https://github.com/sponsors/DavidAnson" } }, - "node_modules/marked": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", - "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", - "bin": { - "marked": "bin/marked.js" - }, - "engines": { - "node": ">= 12" - } - }, "node_modules/mdast-util-directive": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mdast-util-directive/-/mdast-util-directive-3.0.0.tgz", @@ -15762,8 +15737,7 @@ "node_modules/mdurl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", - "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", - "dev": true + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==" }, "node_modules/media-typer": { "version": "0.3.0", @@ -16716,9 +16690,9 @@ } }, "node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz", + "integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==", "dev": true, "engines": { "node": ">=16 || 14 >=14.17" @@ -17349,25 +17323,25 @@ "dev": true }, "node_modules/path-scurry": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.2.tgz", - "integrity": "sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", "dev": true, "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", - "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", + "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "dev": true, "engines": { "node": "14 || >=16.14" @@ -18437,7 +18411,6 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", - "dev": true, "engines": { "node": ">=6" } @@ -20193,14 +20166,11 @@ } }, "node_modules/shiki": { - "version": "0.14.7", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.7.tgz", - "integrity": "sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.5.2.tgz", + "integrity": "sha512-fpPbuSaatinmdGijE7VYUD3hxLozR3ZZ+iAx8Iy2X6REmJGyF5hQl94SgmiUNTospq346nXUVZx0035dyGvIVw==", "dependencies": { - "ansi-sequence-parser": "^1.1.0", - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" + "@shikijs/core": "1.5.2" } }, "node_modules/side-channel": { @@ -21556,9 +21526,9 @@ } }, "node_modules/tsc-alias": { - "version": "1.8.8", - "resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.8.tgz", - "integrity": "sha512-OYUOd2wl0H858NvABWr/BoSKNERw3N9GTi3rHPK8Iv4O1UyUXIrTTOAZNHsjlVpXFOhpJBVARI1s+rzwLivN3Q==", + "version": "1.8.10", + "resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.10.tgz", + "integrity": "sha512-Ibv4KAWfFkFdKJxnWfVtdOmB0Zi1RJVxcbPGiCDsFpCQSsmpWyuzHG3rQyI5YkobWwxFPEyQfu1hdo4qLG2zPw==", "dev": true, "dependencies": { "chokidar": "^3.5.3", @@ -21906,23 +21876,24 @@ } }, "node_modules/typedoc": { - "version": "0.25.13", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.13.tgz", - "integrity": "sha512-pQqiwiJ+Z4pigfOnnysObszLiU3mVLWAExSPf+Mu06G/qsc3wzbuM56SZQvONhHLncLUhYzOVkjFFpFfL5AzhQ==", + "version": "0.26.0-beta.1", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.0-beta.1.tgz", + "integrity": "sha512-bnTZHxgvGQusWGEZyyzzaxD6Q1+8UQcEksT3PmN8jtgpWu1b1/Kb2Ib4jbpErHUabMR0+9088EH5eFolMN0RQA==", "dependencies": { "lunr": "^2.3.9", - "marked": "^4.3.0", - "minimatch": "^9.0.3", - "shiki": "^0.14.7" + "markdown-it": "^14.1.0", + "minimatch": "^9.0.4", + "shiki": "^1.4.0", + "yaml": "^2.4.2" }, "bin": { "typedoc": "bin/typedoc" }, "engines": { - "node": ">= 16" + "node": ">= 18" }, "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x" + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" } }, "node_modules/typedoc-github-wiki-theme": { @@ -21964,8 +21935,7 @@ "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", - "dev": true + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==" }, "node_modules/unbox-primitive": { "version": "1.0.2", @@ -22542,16 +22512,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/vscode-oniguruma": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", - "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==" - }, - "node_modules/vscode-textmate": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", - "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==" - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -23331,9 +23291,9 @@ "dev": true }, "node_modules/yaml": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.1.tgz", - "integrity": "sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", + "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", "bin": { "yaml": "bin.mjs" }, @@ -23432,7 +23392,7 @@ } }, "packages/docusaurus-plugin-typedoc": { - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "devDependencies": { "@docusaurus/core": "^3.2.1", @@ -23467,10 +23427,13 @@ } }, "packages/typedoc-plugin-markdown": { - "version": "4.0.0", + "version": "4.0.2", "license": "MIT", + "engines": { + "node": ">= 18" + }, "peerDependencies": { - "typedoc": "0.25.x" + "typedoc": "beta.x" } }, "packages/typedoc-plugin-remark": { diff --git a/package.json b/package.json index 96a6a5dac..08cbe377b 100644 --- a/package.json +++ b/package.json @@ -19,19 +19,19 @@ "prepare": "husky" }, "devDependencies": { - "@changesets/cli": "^2.27.1", + "@changesets/cli": "^2.27.2", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.12", - "@types/node": "^20.12.7", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", + "@types/node": "^20.12.12", + "@typescript-eslint/eslint-plugin": "^7.9.0", + "@typescript-eslint/parser": "^7.9.0", "consola": "^3.2.3", "copyfiles": "^2.4.1", - "eslint": "^8.57.0", + "eslint": "8.57.0", "fs-extra": "^11.2.0", - "glob": "^10.3.12", + "glob": "^10.3.15", "husky": "^9.0.11", "jest": "^29.7.0", "markdownlint": "^0.34.0", @@ -47,8 +47,8 @@ "ts-json-schema-generator": "^2.1.1", "ts-morph": "^22.0.0", "ts-node": "^10.9.2", - "tsc-alias": "^1.8.8", - "typedoc": "0.25.13", + "tsc-alias": "^1.8.10", + "typedoc": "^0.26.0-beta.1", "typescript": "^5.4.5", "unified-prettier": "^2.0.1" } diff --git a/packages/docusaurus-plugin-typedoc/src/defs/typedoc.d.ts b/packages/docusaurus-plugin-typedoc/src/defs/typedoc.d.ts new file mode 100644 index 000000000..a5e85594b --- /dev/null +++ b/packages/docusaurus-plugin-typedoc/src/defs/typedoc.d.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'; +import { Sidebar } from '../options/option-types'; +declare module 'typedoc' { + export interface TypeDocOptionMap { + sidebar: ManuallyValidatedOption; + } +} diff --git a/packages/docusaurus-plugin-typedoc/src/options/option-types.ts b/packages/docusaurus-plugin-typedoc/src/options/option-types.ts index dc5f9d457..10869650b 100644 --- a/packages/docusaurus-plugin-typedoc/src/options/option-types.ts +++ b/packages/docusaurus-plugin-typedoc/src/options/option-types.ts @@ -1,13 +1,5 @@ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. -import { ManuallyValidatedOption } from 'typedoc'; - -declare module 'typedoc' { - export interface TypeDocOptionMap { - sidebar: ManuallyValidatedOption; - } -} - /** * Describes the options declared by the plugin. * diff --git a/packages/docusaurus-plugin-typedoc/test/specs/__snapshots__/docusaurus.spec.ts.snap b/packages/docusaurus-plugin-typedoc/test/specs/__snapshots__/docusaurus.spec.ts.snap index 6564d7c49..a30259b8c 100644 --- a/packages/docusaurus-plugin-typedoc/test/specs/__snapshots__/docusaurus.spec.ts.snap +++ b/packages/docusaurus-plugin-typedoc/test/specs/__snapshots__/docusaurus.spec.ts.snap @@ -64,11 +64,11 @@ Links using \`{@link}\` inline tags. - [Links to CommentInterface.prop](index.md#prop) - [Links to CommentInterface.propb](index.md#propb) -#### Extended by +#### Extended By - [\`CommentInterfaceExtended\`](index.md#commentinterfaceextended) -#### Type parameters +#### Type Parameters • **T** diff --git a/packages/typedoc-github-wiki-theme/src/defs/typedoc.d.ts b/packages/typedoc-github-wiki-theme/src/defs/typedoc.d.ts new file mode 100644 index 000000000..a5e85594b --- /dev/null +++ b/packages/typedoc-github-wiki-theme/src/defs/typedoc.d.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'; +import { Sidebar } from '../options/option-types'; +declare module 'typedoc' { + export interface TypeDocOptionMap { + sidebar: ManuallyValidatedOption; + } +} diff --git a/packages/typedoc-github-wiki-theme/src/options/option-types.ts b/packages/typedoc-github-wiki-theme/src/options/option-types.ts index 0ebce1c86..1a571451c 100644 --- a/packages/typedoc-github-wiki-theme/src/options/option-types.ts +++ b/packages/typedoc-github-wiki-theme/src/options/option-types.ts @@ -1,13 +1,5 @@ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. -import { ManuallyValidatedOption } from 'typedoc'; - -declare module 'typedoc' { - export interface TypeDocOptionMap { - sidebar: ManuallyValidatedOption; - } -} - /** * Describes the options declared by the plugin. * diff --git a/packages/typedoc-gitlab-wiki-theme/src/defs/typedoc.d.ts b/packages/typedoc-gitlab-wiki-theme/src/defs/typedoc.d.ts new file mode 100644 index 000000000..a5e85594b --- /dev/null +++ b/packages/typedoc-gitlab-wiki-theme/src/defs/typedoc.d.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'; +import { Sidebar } from '../options/option-types'; +declare module 'typedoc' { + export interface TypeDocOptionMap { + sidebar: ManuallyValidatedOption; + } +} diff --git a/packages/typedoc-gitlab-wiki-theme/src/options/option-types.ts b/packages/typedoc-gitlab-wiki-theme/src/options/option-types.ts index 6589b356e..7a8217f0c 100644 --- a/packages/typedoc-gitlab-wiki-theme/src/options/option-types.ts +++ b/packages/typedoc-gitlab-wiki-theme/src/options/option-types.ts @@ -1,13 +1,5 @@ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. -import { ManuallyValidatedOption } from 'typedoc'; - -declare module 'typedoc' { - export interface TypeDocOptionMap { - sidebar: ManuallyValidatedOption; - } -} - /** * Describes the options declared by the plugin. * diff --git a/packages/typedoc-plugin-frontmatter/src/defs/typedoc.d.ts b/packages/typedoc-plugin-frontmatter/src/defs/typedoc.d.ts new file mode 100644 index 000000000..655c5b1a4 --- /dev/null +++ b/packages/typedoc-plugin-frontmatter/src/defs/typedoc.d.ts @@ -0,0 +1,15 @@ +// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'; +import { FrontmatterGlobals } from '../options/option-types'; +import { IndexFrontmatter } from '../options/option-types'; +import { ReadmeFrontmatter } from '../options/option-types'; +declare module 'typedoc' { + export interface TypeDocOptionMap { + frontmatterCommentTags: any[]; + frontmatterGlobals: ManuallyValidatedOption; + frontmatterNamingConvention: 'camelCase' | 'snakeCase'; + indexFrontmatter: ManuallyValidatedOption; + preserveFrontmatterCommentTags: boolean; + readmeFrontmatter: ManuallyValidatedOption; + } +} diff --git a/packages/typedoc-plugin-frontmatter/src/options/option-types.ts b/packages/typedoc-plugin-frontmatter/src/options/option-types.ts index dc8cfba07..4b181a2a3 100644 --- a/packages/typedoc-plugin-frontmatter/src/options/option-types.ts +++ b/packages/typedoc-plugin-frontmatter/src/options/option-types.ts @@ -1,18 +1,5 @@ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. -import { ManuallyValidatedOption } from 'typedoc'; - -declare module 'typedoc' { - export interface TypeDocOptionMap { - frontmatterCommentTags: any[]; - frontmatterGlobals: ManuallyValidatedOption; - frontmatterNamingConvention: 'camelCase' | 'snakeCase'; - indexFrontmatter: ManuallyValidatedOption; - preserveFrontmatterCommentTags: boolean; - readmeFrontmatter: ManuallyValidatedOption; - } -} - /** * Describes the options declared by the plugin. * @@ -62,11 +49,11 @@ export interface FrontmatterGlobals {} * * @category Options */ -export interface ReadmeFrontmatter {} +export interface IndexFrontmatter {} /** * * * @category Options */ -export interface IndexFrontmatter {} +export interface ReadmeFrontmatter {} diff --git a/packages/typedoc-plugin-frontmatter/tsdoc.json b/packages/typedoc-plugin-frontmatter/tsdoc.json new file mode 100644 index 000000000..4fc0cfcf0 --- /dev/null +++ b/packages/typedoc-plugin-frontmatter/tsdoc.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://developer.microsoft.com/en-us/json-schemas/tsdoc/v0/tsdoc.schema.json", + "noStandardTags": false, + "tagDefinitions": [ + { + "tagName": "@tagOne", + "syntaxKind": "block" + }, + { + "tagName": "@tagTwo", + "syntaxKind": "block" + } + ] +} diff --git a/packages/typedoc-plugin-markdown/.scripts/prebuild-resources.ts b/packages/typedoc-plugin-markdown/.scripts/prebuild-resources.ts index 1f5402b0b..2c7bd7816 100644 --- a/packages/typedoc-plugin-markdown/.scripts/prebuild-resources.ts +++ b/packages/typedoc-plugin-markdown/.scripts/prebuild-resources.ts @@ -75,7 +75,6 @@ function getSymbols(files: string[], type: string, thePath = resourcesPath) { return ` /** * ${jsDoc.getComment() ? jsDoc.getComment() : ''} - * ${jsDoc .getTags() .map((tag) => `* ${tag.getText()}`) @@ -139,7 +138,7 @@ function writeLibsBarrelsFile(resourceType: string) { out.push(`export { ${symbols[index].symbolName} } from './${file}';`); }); - fs.outputFileSync(barrelsFile, out.join('\n')); + fs.outputFileSync(barrelsFile, out.join('\n').trim() + '\n'); } async function writeResourcesFile() { @@ -162,6 +161,7 @@ async function writeResourcesFile() { 'ContainerReflection', 'DeclarationHierarchy', 'DeclarationReflection', + 'DocumentReflection', 'IndexedAccessType', 'InferredType', 'IntersectionType', @@ -188,6 +188,7 @@ async function writeResourcesFile() { ]; const out = `// THIS FILE IS AUTO GENERATED. DO NOT EDIT DIRECTLY. +import { MarkdownPageEvent } from '@plugin/app/events'; import { MarkdownThemeContext } from '@plugin/theme'; import {${typedocTypes.join(',')}} from 'typedoc'; diff --git a/packages/typedoc-plugin-markdown/.scripts/prebuild.ts b/packages/typedoc-plugin-markdown/.scripts/prebuild.ts index 6da765879..719a45217 100644 --- a/packages/typedoc-plugin-markdown/.scripts/prebuild.ts +++ b/packages/typedoc-plugin-markdown/.scripts/prebuild.ts @@ -1,11 +1,9 @@ import { consola } from 'consola'; -import { prebuildKinds } from './prebuild-kinds'; import { prebuildResources } from './prebuild-resources'; main(); async function main() { - await prebuildKinds(); await prebuildResources(); consola.success('[typedoc-plugin-markdown] Prebuild code complete'); } diff --git a/packages/typedoc-plugin-markdown/.scripts/schema/generate-schema.ts b/packages/typedoc-plugin-markdown/.scripts/schema/generate-schema.ts index 9ff08645d..5a4e18362 100644 --- a/packages/typedoc-plugin-markdown/.scripts/schema/generate-schema.ts +++ b/packages/typedoc-plugin-markdown/.scripts/schema/generate-schema.ts @@ -41,7 +41,7 @@ async function main() { __dirname, '../../../../docs/public/schema.json', ); - console.log(schemaFile); + const schemaString = JSON.stringify(schemaWrapper, null, 2); fs.writeFileSync(schemaFile, schemaString); } diff --git a/packages/typedoc-plugin-markdown/package.json b/packages/typedoc-plugin-markdown/package.json index 46b5f296e..caf8c147f 100644 --- a/packages/typedoc-plugin-markdown/package.json +++ b/packages/typedoc-plugin-markdown/package.json @@ -32,6 +32,12 @@ "directory": "packages/typedoc-plugin-markdown" }, "homepage": "https://typedoc-plugin-markdown.org", + "peerDependencies": { + "typedoc": "beta.x" + }, + "engines": { + "node": ">= 18" + }, "keywords": [ "api", "documentation", @@ -39,8 +45,5 @@ "typedoc", "typescript", "typedoc-plugin" - ], - "peerDependencies": { - "typedoc": "0.25.x" - } + ] } diff --git a/packages/typedoc-plugin-markdown/src/app/renderer/overrides.ts b/packages/typedoc-plugin-markdown/src/app/renderer/overrides.ts index da079f1a8..56528f0e8 100644 --- a/packages/typedoc-plugin-markdown/src/app/renderer/overrides.ts +++ b/packages/typedoc-plugin-markdown/src/app/renderer/overrides.ts @@ -5,6 +5,7 @@ import * as path from 'path'; import { Application, DeclarationReflection, + DocumentReflection, ProjectReflection, Reflection, Renderer, @@ -94,7 +95,8 @@ export async function render( ?.filter( (urlMapping) => urlMapping.model instanceof ProjectReflection || - urlMapping.model instanceof DeclarationReflection, + urlMapping.model instanceof DeclarationReflection || + urlMapping.model instanceof DocumentReflection, ) .forEach(async (urlMapping) => { const [template, page] = output.createPageEvent(urlMapping); diff --git a/packages/typedoc-plugin-markdown/src/app/translatable.ts b/packages/typedoc-plugin-markdown/src/app/translatable.ts new file mode 100644 index 000000000..86f481f02 --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/app/translatable.ts @@ -0,0 +1,73 @@ +import { Application } from 'typedoc'; + +export function getTranslatable(app: Application) { + // read text content mappings for backward compatibility + const textContentMappings = app.options.getValue('textContentMappings'); + return { ...translatable, ...serializeTextContent(textContentMappings) }; +} + +export const translatable = { + // header + theme_header_title: '{0} {1}', // {projectName} {version}, + theme_header_docs: 'Docs', // displayed in the header when readme is resolved + + // breadcrumbs + theme_breadcrumbs_home: '{0} {1}', // {projectName} {version}, + + // titles + theme_title_index_page: '{0} {1}', // {projectName} {version}, + theme_title_member_page: '{0}: {1}', // {kind}: {name} + theme_title_module_page: '{0}', // {name}, + + // footer + theme_footer_text: '', + + // generic labels + theme_api_index: 'API Index', + theme_default_value: 'Default Value', + theme_description: 'Description', + theme_event: 'Event', + theme_extends: 'Extends', + theme_extended_by: 'Extended By', + theme_flags: 'Flags', + theme_globals: 'Globals', + theme_member: 'Member', + theme_member_plural: 'Members', + theme_modifier: 'Modifier', + theme_name: 'Name', + theme_packages: 'Packages', + theme_source: 'Source', + theme_type: 'Type', + theme_value: 'Value', + theme_version: 'Version', +}; + +/** + * textContentMappings is now deprecated. + * + * This method maps textContentMappings to translatable object to avoid a breaking options change. + * + * This method will be removed once textContentMappings is removed from options declaration. + * + */ +function serializeTextContent(textContentMappings: any) { + const output: { [key: string]: string } = {}; + for (const [key, value] of Object.entries(textContentMappings)) { + const newKey = 'theme_' + camelToSnakeCase(key.replace(/\./g, '_')); + let newValue = (value as any) + .replace(/{version}/g, '{1}') + .replace(/{kind}/g, '{0}') + .replace(/{projectName}/g, '{0}'); + if (newKey === 'theme_title_member_page') { + newValue = newValue.replace(/{name}/g, '{1}'); + } else { + newValue = newValue.replace(/{name}/g, '{0}'); + } + output[newKey] = newValue; + } + return output; +} + +function camelToSnakeCase(str: string) { + return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`); +} diff --git a/packages/typedoc-plugin-markdown/src/defs/typedoc.d.ts b/packages/typedoc-plugin-markdown/src/defs/typedoc.d.ts new file mode 100644 index 000000000..5e9f47262 --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/defs/typedoc.d.ts @@ -0,0 +1,84 @@ +// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'; +import { TextContentMappings } from '../options/option-types'; +declare module 'typedoc' { + export interface TypeDocOptionMap { + anchorPrefix: string; + entryFileName: string; + entryModule: string; + enumMembersFormat: 'list' | 'table' | 'htmlTable'; + excludeGroups: boolean; + excludeScopesInPaths: boolean; + expandObjects: boolean; + expandParameters: boolean; + fileExtension: string; + flattenOutputFiles: boolean; + hideBreadcrumbs: boolean; + hidePageHeader: boolean; + hidePageTitle: boolean; + indexFormat: 'list' | 'table' | 'htmlTable'; + inlineDocuments: boolean; + membersWithOwnFile: ( + | 'Enum' + | 'Variable' + | 'Function' + | 'Class' + | 'Interface' + | 'TypeAlias' + )[]; + mergeReadme: boolean; + navigationModel: { + excludeGroups: boolean; + excludeCategories: boolean; + excludeFolders: boolean; + }; + outputFileStrategy: 'members' | 'modules'; + parametersFormat: 'list' | 'table' | 'htmlTable'; + preserveAnchorCasing: boolean; + propertiesFormat: 'list' | 'table' | 'htmlTable'; + publicPath: string; + sanitizeComments: boolean; + tableColumns: { + excludeDefaultsCol: boolean; + excludeInheritedFromCol: boolean; + excludeModifiersCol: boolean; + excludeOverridesCol: boolean; + excludeSourcesCol: boolean; + leftAlignHeadings: boolean; + }; + textContentMappings: ManuallyValidatedOption>; + typeDeclarationFormat: 'list' | 'table' | 'htmlTable'; + useCodeBlocks: boolean; + useHTMLAnchors: boolean; + } + + // eslint-disable-next-line @typescript-eslint/no-namespace + export namespace Internationalization { + export interface TranslatableStrings { + theme_header_title: [string, string]; + theme_header_docs: []; + theme_breadcrumbs_home: [string, string]; + theme_title_index_page: [string, string]; + theme_title_member_page: [string, string]; + theme_title_module_page: [string]; + theme_footer_text: []; + theme_api_index: []; + theme_default_value: []; + theme_description: []; + theme_event: []; + theme_extends: []; + theme_extended_by: []; + theme_flags: []; + theme_globals: []; + theme_member: []; + theme_member_plural: []; + theme_modifier: []; + theme_name: []; + theme_packages: []; + theme_source: []; + theme_type: []; + theme_value: []; + theme_version: []; + } + } +} diff --git a/packages/typedoc-plugin-markdown/src/index.ts b/packages/typedoc-plugin-markdown/src/index.ts index c2c7154ed..c156e4cf9 100644 --- a/packages/typedoc-plugin-markdown/src/index.ts +++ b/packages/typedoc-plugin-markdown/src/index.ts @@ -42,9 +42,16 @@ export function load(app: Application) { } as DeclarationOption); }); + /** + * ========================================= + * 2. Extend locale with plugin translations + * ========================================= + */ + //app.internationalization.addTranslations('en', getTranslatable(app)); + /** * ================================================= - * 2. Intercept and modify some TypeDoc core methods + * 3. Intercept and modify some TypeDoc core methods * ================================================= * * Currently the TypeDoc {@link Renderer} class is quite coupled to the HTML theme so we override a couple of core methods. diff --git a/packages/typedoc-plugin-markdown/src/libs/markdown/index.ts b/packages/typedoc-plugin-markdown/src/libs/markdown/index.ts index bbc5647fd..1ef7f70b4 100644 --- a/packages/typedoc-plugin-markdown/src/libs/markdown/index.ts +++ b/packages/typedoc-plugin-markdown/src/libs/markdown/index.ts @@ -16,4 +16,4 @@ export { italic } from './italic'; export { link } from './link'; export { strikeThrough } from './strike-through'; export { table } from './table'; -export { unorderedList } from './unordered-list'; \ No newline at end of file +export { unorderedList } from './unordered-list'; diff --git a/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.spec.ts b/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.spec.ts index 453e66dcc..15102b5cd 100644 --- a/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.spec.ts +++ b/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.spec.ts @@ -1,31 +1,31 @@ -import path from 'path'; +import * as path from 'path'; import { getFileNameWithExtension } from './get-file-name-with-extension'; describe('getFileNameWithExtension', () => { it('should return filename with extension', () => { - const fileName = 'testFile'; + const fileName = 'example'; const fileExtension = '.txt'; - const expectedOutput = 'testFile.txt'; + const expectedOutput = 'example.txt'; const result = getFileNameWithExtension(fileName, fileExtension); expect(result).toEqual(expectedOutput); }); - it('should handle fileExtension without dot', () => { - const fileName = 'testFile'; - const fileExtension = 'txt'; - const expectedOutput = 'testFile.txt'; + it('should handle filename with directory', () => { + const fileName = path.join('dir1', 'dir2', 'example'); + const fileExtension = '.txt'; + const expectedOutput = path.join('dir1', 'dir2', 'example.txt'); const result = getFileNameWithExtension(fileName, fileExtension); expect(result).toEqual(expectedOutput); }); - it('should handle fileName with directories', () => { - const fileName = path.join('dir1', 'dir2', 'testFile'); - const fileExtension = 'txt'; - const expectedOutput = path.join('dir1', 'dir2', 'testFile.txt'); + it('should handle filename with existing extension', () => { + const fileName = 'example.old'; + const fileExtension = '.txt'; + const expectedOutput = 'example.txt'; const result = getFileNameWithExtension(fileName, fileExtension); diff --git a/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.ts b/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.ts index 605f59ed1..80097d089 100644 --- a/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.ts +++ b/packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.ts @@ -8,8 +8,5 @@ export function getFileNameWithExtension( fileExtension: string, ) { const parsedPath = path.parse(fileName); - const extension = fileExtension.startsWith('.') - ? fileExtension.slice(1) - : fileExtension; - return path.join(parsedPath.dir, `${parsedPath.name}.${extension}`); + return path.join(parsedPath.dir, `${parsedPath.name}${fileExtension}`); } diff --git a/packages/typedoc-plugin-markdown/src/libs/utils/index.ts b/packages/typedoc-plugin-markdown/src/libs/utils/index.ts index b263c8310..ea46f3804 100644 --- a/packages/typedoc-plugin-markdown/src/libs/utils/index.ts +++ b/packages/typedoc-plugin-markdown/src/libs/utils/index.ts @@ -1,5 +1,3 @@ - - // PLEASE NOTE: THE CONTENTS OF THE FILE BELOW THIS POINT IS AUTO GENERATED! export { camelToTitleCase } from './camel-to-title-case'; @@ -13,4 +11,5 @@ export { removeFirstScopedDirectory } from './remove-first-scoped-directory'; export { removeLineBreaks } from './remove-line-breaks'; export { sanitizeComments } from './sanitize-comments'; export { slugify } from './slugify'; -export { unEscapeChars } from './un-escape-chars'; \ No newline at end of file +export { toPascalCase } from './to-pascal-case'; +export { unEscapeChars } from './un-escape-chars'; diff --git a/packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.spec.ts b/packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.spec.ts new file mode 100644 index 000000000..ba5f2492d --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.spec.ts @@ -0,0 +1,7 @@ +import { toPascalCase } from './to-pascal-case'; + +describe('toPascalCase', () => { + it('should convert a string to start case', () => { + expect(toPascalCase('Type Alias')).toBe('TypeAlias'); + }); +}); diff --git a/packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.ts b/packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.ts new file mode 100644 index 000000000..43d00e22e --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/libs/utils/to-pascal-case.ts @@ -0,0 +1,6 @@ +export function toPascalCase(text: string): string { + return text + .split(' ') + .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) + .join(''); +} diff --git a/packages/typedoc-plugin-markdown/src/options/declarations.ts b/packages/typedoc-plugin-markdown/src/options/declarations.ts index 1c4b05b52..19d001f22 100644 --- a/packages/typedoc-plugin-markdown/src/options/declarations.ts +++ b/packages/typedoc-plugin-markdown/src/options/declarations.ts @@ -4,7 +4,6 @@ import { MembersWithOwnFile, OutputFileStrategy, } from './option-maps'; -import { TEXT_MAPPING_DEFAULTS } from './text-mappings/text-mapping-defaults'; /** * @@ -137,6 +136,13 @@ export const fileExtension: Partial = { help: 'Specify the file extension for generated output files.', type: ParameterType.String, defaultValue: '.md', + validate(value) { + if (!value.startsWith('.')) { + throw new Error( + '[typedoc-plugin-markdown] "fileExtension" must start with a period.', + ); + } + }, }; /** @@ -251,6 +257,17 @@ export const hideBreadcrumbs: Partial = { defaultValue: false, }; +/** + * By default a documents index and separate documents pages are generated when using the `@document` tag. + * + * @category UX + */ +export const inlineDocuments: Partial = { + help: 'Inline documents in pages.', + type: ParameterType.Boolean, + defaultValue: false, +}; + /** * By default members are grouped by kind (eg Classes, Functions etc). * @@ -434,7 +451,7 @@ export const tableColumns: Partial = { export const textContentMappings: Partial = { help: 'Provides a mechanism to change the content of text used in documentation.', type: ParameterType.Mixed, - defaultValue: TEXT_MAPPING_DEFAULTS, + defaultValue: {}, validate(value) { if (!value || typeof value !== 'object') { throw new Error( @@ -449,18 +466,6 @@ export const textContentMappings: Partial = { ); } } - - for (const key of Object.keys(value)) { - if (!Object.keys(TEXT_MAPPING_DEFAULTS).includes(key)) { - throw new Error( - `[typedoc-plugin-markdown] "${key}" is not a valid "textContentMappings" key. Valid keys are ${Object.keys( - TEXT_MAPPING_DEFAULTS, - ) - .map((key) => `"${key}"`) - .join(', ')}.`, - ); - } - } }, }; diff --git a/packages/typedoc-plugin-markdown/src/options/index.ts b/packages/typedoc-plugin-markdown/src/options/index.ts index daa1c9a68..53c5cf137 100644 --- a/packages/typedoc-plugin-markdown/src/options/index.ts +++ b/packages/typedoc-plugin-markdown/src/options/index.ts @@ -1,3 +1,2 @@ export * from './option-maps'; export * from './option-types'; -export * from './text-mappings'; diff --git a/packages/typedoc-plugin-markdown/src/options/option-types.ts b/packages/typedoc-plugin-markdown/src/options/option-types.ts index 90a10054f..adb3f1571 100644 --- a/packages/typedoc-plugin-markdown/src/options/option-types.ts +++ b/packages/typedoc-plugin-markdown/src/options/option-types.ts @@ -1,58 +1,5 @@ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. -import { ManuallyValidatedOption } from 'typedoc'; - -declare module 'typedoc' { - export interface TypeDocOptionMap { - anchorPrefix: string; - entryFileName: string; - entryModule: string; - enumMembersFormat: 'list' | 'table' | 'htmlTable'; - excludeGroups: boolean; - excludeScopesInPaths: boolean; - expandObjects: boolean; - expandParameters: boolean; - fileExtension: string; - flattenOutputFiles: boolean; - hideBreadcrumbs: boolean; - hidePageHeader: boolean; - hidePageTitle: boolean; - indexFormat: 'list' | 'table' | 'htmlTable'; - membersWithOwnFile: ( - | 'Enum' - | 'Variable' - | 'Function' - | 'Class' - | 'Interface' - | 'TypeAlias' - )[]; - mergeReadme: boolean; - navigationModel: { - excludeGroups: boolean; - excludeCategories: boolean; - excludeFolders: boolean; - }; - outputFileStrategy: 'members' | 'modules'; - parametersFormat: 'list' | 'table' | 'htmlTable'; - preserveAnchorCasing: boolean; - propertiesFormat: 'list' | 'table' | 'htmlTable'; - publicPath: string; - sanitizeComments: boolean; - tableColumns: { - excludeDefaultsCol: boolean; - excludeInheritedFromCol: boolean; - excludeModifiersCol: boolean; - excludeOverridesCol: boolean; - excludeSourcesCol: boolean; - leftAlignHeadings: boolean; - }; - textContentMappings: ManuallyValidatedOption>; - typeDeclarationFormat: 'list' | 'table' | 'htmlTable'; - useCodeBlocks: boolean; - useHTMLAnchors: boolean; - } -} - /** * Describes the options declared by the plugin. * @@ -129,6 +76,11 @@ export interface PluginOptions { */ indexFormat: 'list' | 'table' | 'htmlTable'; + /** + * Inline documents in pages. + */ + inlineDocuments: boolean; + /** * Determines which members are exported to their own file when `outputFileStrategy` equals `members`. */ @@ -223,71 +175,4 @@ export interface PluginOptions { * * @category Options */ -export interface TextContentMappings { - 'header.title': string; - 'header.docs': string; - 'breadcrumbs.home': string; - 'footer.text': string; - 'title.indexPage': string; - 'title.modulePage': string; - 'title.memberPage': string; - 'label.apiIndex': string; - 'label.defaultValue': string; - 'label.description': string; - 'label.extendedBy': string; - 'label.extends': string; - 'label.flags': string; - 'label.globals': string; - 'label.implements': string; - 'label.implementationOf': string; - 'label.inheritedFrom': string; - 'label.index': string; - 'label.indexable': string; - 'label.indexSignature': string; - 'label.member': string; - 'label.modifier': string; - 'label.name': string; - 'label.overrides': string; - 'label.packages': string; - 'label.reExports': string; - 'label.renamesAndReExports': string; - 'label.returns': string; - 'label.source': string; - 'label.type': string; - 'label.typeDeclaration': string; - 'label.value': string; - 'kind.accessor.singular': string; - 'kind.accessor.plural': string; - 'kind.class.singular': string; - 'kind.class.plural': string; - 'kind.constructor.singular': string; - 'kind.constructor.plural': string; - 'kind.enum.singular': string; - 'kind.enum.plural': string; - 'kind.enumMember.singular': string; - 'kind.enumMember.plural': string; - 'kind.event.singular': string; - 'kind.event.plural': string; - 'kind.function.singular': string; - 'kind.function.plural': string; - 'kind.interface.singular': string; - 'kind.interface.plural': string; - 'kind.method.singular': string; - 'kind.method.plural': string; - 'kind.module.singular': string; - 'kind.module.plural': string; - 'kind.namespace.singular': string; - 'kind.namespace.plural': string; - 'kind.variable.singular': string; - 'kind.variable.plural': string; - 'kind.parameter.singular': string; - 'kind.parameter.plural': string; - 'kind.property.singular': string; - 'kind.property.plural': string; - 'kind.reference.singular': string; - 'kind.reference.plural': string; - 'kind.typeAlias.singular': string; - 'kind.typeAlias.plural': string; - 'kind.typeParameter.singular': string; - 'kind.typeParameter.plural': string; -} +export interface TextContentMappings {} diff --git a/packages/typedoc-plugin-markdown/src/options/text-mappings/index.ts b/packages/typedoc-plugin-markdown/src/options/text-mappings/index.ts deleted file mode 100644 index 1341a68ae..000000000 --- a/packages/typedoc-plugin-markdown/src/options/text-mappings/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './kind-defaults'; -export * from './text-mapping-defaults'; diff --git a/packages/typedoc-plugin-markdown/src/options/text-mappings/kind-defaults.ts b/packages/typedoc-plugin-markdown/src/options/text-mappings/kind-defaults.ts deleted file mode 100644 index bb9c88a6d..000000000 --- a/packages/typedoc-plugin-markdown/src/options/text-mappings/kind-defaults.ts +++ /dev/null @@ -1,78 +0,0 @@ -// THIS FILE IS AUTOGENERATED - DO NOT EDIT DIRECTLY - -export const KIND_DEFAULTS: Record = { - 'kind.accessor.singular': 'Accessor', - 'kind.accessor.plural': 'Accessors', - 'kind.class.singular': 'Class', - 'kind.class.plural': 'Classes', - 'kind.constructor.singular': 'Constructor', - 'kind.constructor.plural': 'Constructors', - 'kind.enum.singular': 'Enumeration', - 'kind.enum.plural': 'Enumerations', - 'kind.enumMember.singular': 'Enumeration Member', - 'kind.enumMember.plural': 'Enumeration Members', - 'kind.event.singular': 'Event', - 'kind.event.plural': 'Events', - 'kind.function.singular': 'Function', - 'kind.function.plural': 'Functions', - 'kind.interface.singular': 'Interface', - 'kind.interface.plural': 'Interfaces', - 'kind.method.singular': 'Method', - 'kind.method.plural': 'Methods', - 'kind.module.singular': 'Module', - 'kind.module.plural': 'Modules', - 'kind.namespace.singular': 'Namespace', - 'kind.namespace.plural': 'Namespaces', - 'kind.variable.singular': 'Variable', - 'kind.variable.plural': 'Variables', - 'kind.parameter.singular': 'Parameter', - 'kind.parameter.plural': 'Parameters', - 'kind.property.singular': 'Property', - 'kind.property.plural': 'Properties', - 'kind.reference.singular': 'Reference', - 'kind.reference.plural': 'References', - 'kind.typeAlias.singular': 'Type alias', - 'kind.typeAlias.plural': 'Type Aliases', - 'kind.typeParameter.singular': 'Type parameter', - 'kind.typeParameter.plural': 'Type parameters', -}; - -export const SINGULAR_KIND_KEY_MAP: Record = { - ['Accessor']: 'kind.accessor.singular', - ['Class']: 'kind.class.singular', - ['Constructor']: 'kind.constructor.singular', - ['Enumeration']: 'kind.enum.singular', - ['Enumeration Member']: 'kind.enumMember.singular', - ['Event']: 'kind.event.singular', - ['Function']: 'kind.function.singular', - ['Interface']: 'kind.interface.singular', - ['Method']: 'kind.method.singular', - ['Module']: 'kind.module.singular', - ['Namespace']: 'kind.namespace.singular', - ['Variable']: 'kind.variable.singular', - ['Parameter']: 'kind.parameter.singular', - ['Property']: 'kind.property.singular', - ['Reference']: 'kind.reference.singular', - ['Type alias']: 'kind.typeAlias.singular', - ['Type parameter']: 'kind.typeParameter.singular', -}; - -export const PLURAL_KIND_KEY_MAP: Record = { - ['Accessors']: 'kind.accessor.plural', - ['Classes']: 'kind.class.plural', - ['Constructors']: 'kind.constructor.plural', - ['Enumerations']: 'kind.enum.plural', - ['Enumeration Members']: 'kind.enumMember.plural', - ['Events']: 'kind.event.plural', - ['Functions']: 'kind.function.plural', - ['Interfaces']: 'kind.interface.plural', - ['Methods']: 'kind.method.plural', - ['Modules']: 'kind.module.plural', - ['Namespaces']: 'kind.namespace.plural', - ['Variables']: 'kind.variable.plural', - ['Parameters']: 'kind.parameter.plural', - ['Properties']: 'kind.property.plural', - ['References']: 'kind.reference.plural', - ['Type Aliases']: 'kind.typeAlias.plural', - ['Type parameters']: 'kind.typeParameter.plural', -}; diff --git a/packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts b/packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts deleted file mode 100644 index 837467577..000000000 --- a/packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { KIND_DEFAULTS } from './kind-defaults'; - -export const TEXT_MAPPING_DEFAULTS = { - 'header.title': '{projectName} {version}', - 'header.docs': 'Docs', - 'breadcrumbs.home': '{projectName} {version}', - 'footer.text': '', - 'title.indexPage': '{projectName} {version}', - 'title.modulePage': '{name}', - 'title.memberPage': '{kind}: {name}', - 'label.apiIndex': 'API Index', - 'label.defaultValue': 'Default value', - 'label.description': 'Description', - 'label.extendedBy': 'Extended by', - 'label.extends': 'Extends', - 'label.flags': 'Flags', - 'label.globals': 'Globals', - 'label.implements': 'Implements', - 'label.implementationOf': 'Implementation of', - 'label.inheritedFrom': 'Inherited from', - 'label.index': 'Index', - 'label.indexable': 'Indexable', - 'label.indexSignature': 'Index signature', - 'label.member': 'Member', - 'label.modifier': 'Modifier', - 'label.name': 'Name', - 'label.overrides': 'Overrides', - 'label.packages': 'Packages', - 'label.reExports': 'Re-exports', - 'label.renamesAndReExports': 'Renames and re-exports', - 'label.returns': 'Returns', - 'label.source': 'Source', - 'label.type': 'Type', - 'label.typeDeclaration': 'Type declaration', - 'label.value': 'Value', - ...KIND_DEFAULTS, -}; diff --git a/packages/typedoc-plugin-markdown/src/public-api.ts b/packages/typedoc-plugin-markdown/src/public-api.ts index 632c22a01..34f0acf9b 100644 --- a/packages/typedoc-plugin-markdown/src/public-api.ts +++ b/packages/typedoc-plugin-markdown/src/public-api.ts @@ -20,7 +20,7 @@ export { MarkdownApplication, MarkdownRenderer } from '@plugin/app/application'; export { MarkdownPageEvent, MarkdownRendererEvent } from '@plugin/app/events'; export { MarkdownRendererHooks } from '@plugin/app/renderer'; -export { PluginOptions, TextContentMappings } from '@plugin/options'; +export { PluginOptions } from '@plugin/options'; export { MarkdownTheme, MarkdownThemeContext, diff --git a/packages/typedoc-plugin-markdown/src/theme/core/navigation-builder.ts b/packages/typedoc-plugin-markdown/src/theme/core/navigation-builder.ts index 747c7a7a2..acb60b235 100644 --- a/packages/typedoc-plugin-markdown/src/theme/core/navigation-builder.ts +++ b/packages/typedoc-plugin-markdown/src/theme/core/navigation-builder.ts @@ -1,63 +1,74 @@ import { MarkdownRenderer } from '@plugin/app/application'; import { isQuoted } from '@plugin/libs/utils'; -import { OutputFileStrategy, PLURAL_KIND_KEY_MAP } from '@plugin/options'; +import { OutputFileStrategy } from '@plugin/options'; import { MarkdownTheme, NavigationItem } from '@plugin/theme'; import * as path from 'path'; import { DeclarationReflection, + DocumentReflection, EntryPointStrategy, + Options, ProjectReflection, ReflectionCategory, ReflectionGroup, ReflectionKind, } from 'typedoc'; -export function buildNavigation( - theme: MarkdownTheme, - project: ProjectReflection, -) { - const options = theme.application.options; - const navigationOptions = options.getValue('navigationModel'); +export class NavigationBuilder { + private options: Options; + private packagesMeta: any; + private navigationOptions: any; + private navigation: NavigationItem[] = []; + private isPackages: boolean; - const navigation: NavigationItem[] = []; - - const packagesMeta = (theme.application.renderer as MarkdownRenderer) - .packagesMeta; - - const isPackages = - options.getValue('entryPointStrategy') === EntryPointStrategy.Packages; + constructor( + public theme: MarkdownTheme, + public project: ProjectReflection, + ) { + this.options = theme.application.options; + this.navigationOptions = this.options.getValue('navigationModel'); + this.packagesMeta = ( + theme.application.renderer as MarkdownRenderer + ).packagesMeta; + this.navigation = []; + this.isPackages = + this.options.getValue('entryPointStrategy') === + EntryPointStrategy.Packages; + } - if (isPackages) { - if (Object.keys(packagesMeta)?.length === 1) { - buildNavigationFromProject(project); + getNavigation() { + if (this.isPackages) { + if (Object.keys(this.packagesMeta)?.length === 1) { + this.buildNavigationFromProject(this.project); + } else { + this.project.children?.forEach((projectChild) => { + this.buildNavigationFromPackage(projectChild); + }); + } } else { - project.children?.forEach((projectChild) => { - buildNavigationFromPackage(projectChild); - }); + this.buildNavigationFromProject(this.project); } - } else { - buildNavigationFromProject(project); - } - return navigation; + return this.navigation; + } - function buildNavigationFromPackage(projectChild: DeclarationReflection) { - const fileExtension = options.getValue('fileExtension'); + private buildNavigationFromPackage(projectChild: DeclarationReflection) { + const fileExtension = this.options.getValue('fileExtension'); - const entryFileName = `${path.parse(options.getValue('entryFileName')).name}${fileExtension}`; + const entryFileName = `${path.parse(this.options.getValue('entryFileName')).name}${fileExtension}`; const preservePackageReadme = - Boolean(projectChild.readme) && !options.getValue('mergeReadme'); + Boolean(projectChild.readme) && !this.options.getValue('mergeReadme'); - const packageOptions = packagesMeta[projectChild.name]?.options; + const packageOptions = this.packagesMeta[projectChild.name]?.options; const outputFileStrategy = packageOptions?.isSet('outputFileStrategy') ? packageOptions.getValue('outputFileStrategy') - : options.getValue('outputFileStrategy'); + : this.options.getValue('outputFileStrategy'); const entryModule = packageOptions?.isSet('entryModule') ? packageOptions.getValue('entryModule') - : options.getValue('entryModule'); + : this.options.getValue('entryModule'); const projectChildUrl = preservePackageReadme ? `${path.dirname(projectChild.url as string)}/${entryFileName}` @@ -77,12 +88,16 @@ export function buildNavigation( outputFileStrategy === OutputFileStrategy.Modules ) { children.push({ - title: theme.textContentMappings['label.globals'] as string, + title: + this.theme.application.internationalization.proxy.theme_globals(), path: projectChild.url, kind: projectChild.kind, }); } - const childGroups = getChildrenOrGroups(projectChild, outputFileStrategy); + const childGroups = this.getReflectionGroups( + projectChild, + outputFileStrategy, + ); if (childGroups) { children.push( @@ -90,7 +105,7 @@ export function buildNavigation( ); } - navigation.push({ + this.navigation.push({ title: projectChild.name, kind: projectChild.kind, children, @@ -98,61 +113,71 @@ export function buildNavigation( }); } - function buildNavigationFromProject( + private buildNavigationFromProject( project: ProjectReflection | DeclarationReflection, ) { - const entryModule = options.getValue('entryModule'); + const entryModule = this.options.getValue('entryModule'); - if (!navigationOptions.excludeCategories && project.categories?.length) { - navigation.push( + if ( + !this.navigationOptions.excludeCategories && + project.categories?.length + ) { + this.navigation.push( ...project.categories.map((category) => { return { title: category.title, - children: getCategoryGroupChildren(category), + children: this.getCategoryGroupChildren(category), }; }), ); } else { if (project.groups?.length) { - const isEntryModule = Boolean( - project?.groups[0]?.children.find( - (child) => child.name === entryModule, - ), - ); const isOnlyModules = project.children?.every( (child) => child.kind === ReflectionKind.Module, ); - if ( - (project.groups.length === 1 && !Boolean(isEntryModule)) || - isOnlyModules - ) { - const children = getGroupChildren(project.groups[0]); - if (children?.length) { - navigation.push( - ...children.filter((child) => child.title !== entryModule), - ); - } + if (isOnlyModules) { + project.groups?.forEach((projectGroup) => { + if (projectGroup.owningReflection.kind === ReflectionKind.Module) { + const children = this.getGroupChildren(projectGroup); + if (children?.length) { + this.navigation.push( + ...children.filter((child) => child.title !== entryModule), + ); + } + } else { + this.navigation.push({ + title: projectGroup.title, + children: projectGroup.children.map((child) => { + return { + title: child.name, + kind: child.kind, + path: child.url, + }; + }), + }); + } + }); } else { project.groups?.forEach((projectGroup) => { - const children = getGroupChildren(projectGroup); + const children = this.getGroupChildren(projectGroup); const indexModule = projectGroup.children.find( (child) => child.name === entryModule, ); if (children?.length) { - navigation.push({ - title: - theme.textContentMappings[ - PLURAL_KIND_KEY_MAP[projectGroup.title] - ] || projectGroup.title, + this.navigation.push({ + title: projectGroup.title, children: children.filter( (child) => child.title !== entryModule, ), }); } if (indexModule) { - const children = getChildrenOrGroups(indexModule); + const children = + indexModule instanceof DeclarationReflection + ? this.getReflectionGroups(indexModule) + : []; if (children) { - navigation.push(...children); + this.navigation.push(...children); } } }); @@ -161,11 +186,14 @@ export function buildNavigation( } } - function getCategoryGroupChildren(group: ReflectionCategory) { + private getCategoryGroupChildren(group: ReflectionCategory) { return group.children ?.filter((child) => child.hasOwnDocument) .map((child) => { - const children = getChildrenOrGroups(child); + const children = + child instanceof DeclarationReflection + ? this.getReflectionGroups(child) + : []; return { title: child.name, kind: child.kind, @@ -175,15 +203,18 @@ export function buildNavigation( }); } - function getGroupChildren( + private getGroupChildren( group: ReflectionGroup, outputFileStrategy?: OutputFileStrategy, ) { - if (!navigationOptions.excludeCategories && group?.categories?.length) { + if ( + !this.navigationOptions.excludeCategories && + group?.categories?.length + ) { return group.categories?.map((category) => { return { title: category.title, - children: getCategoryGroupChildren(category), + children: this.getCategoryGroupChildren(category), }; }); } @@ -191,16 +222,18 @@ export function buildNavigation( return group.children ?.filter((child) => child.hasOwnDocument) .reduce((acc: NavigationItem[], child) => { - const mapping = theme.getTemplateMapping( + const mapping = this.theme.getTemplateMapping( child.kind, outputFileStrategy, ); if (Boolean(mapping)) { const children = - !navigationOptions.excludeCategories && child.categories?.length + child instanceof DeclarationReflection && + !this.navigationOptions.excludeCategories && + child.categories?.length ? child.categories ?.map((category) => { - const catChildren = getCategoryGroupChildren(category); + const catChildren = this.getCategoryGroupChildren(category); return catChildren.length ? { title: category.title, @@ -209,25 +242,29 @@ export function buildNavigation( : null; }) .filter((cat) => Boolean(cat)) - : getChildrenOrGroups(child, outputFileStrategy); - return processChildren(acc, child, children as NavigationItem[]); + : this.getReflectionGroups(child, outputFileStrategy); + return this.processChildren(acc, child, children as NavigationItem[]); } }, []); } - function getChildrenOrGroups( - reflection: DeclarationReflection, + private getReflectionGroups( + reflection: DeclarationReflection | DocumentReflection, outputFileStrategy?: OutputFileStrategy, ): NavigationItem[] | null { if ( + reflection instanceof DeclarationReflection && reflection.groups?.some((group) => group.allChildrenHaveOwnDocument()) ) { - if (navigationOptions.excludeGroups) { - return reflection.children + if (this.navigationOptions.excludeGroups) { + return reflection.childrenIncludingDocuments ?.filter((child) => child.hasOwnDocument) .reduce((acc, child) => { - const children = getChildrenOrGroups(child, outputFileStrategy); - return processChildren(acc, child, children); + const children = this.getReflectionGroups( + child, + outputFileStrategy, + ); + return this.processChildren(acc, child, children); }, []) as NavigationItem[]; } @@ -237,33 +274,39 @@ export function buildNavigation( if (isModulesGroup) { return ( - getGroupChildren(reflection.groups[0], outputFileStrategy) || null + this.getGroupChildren(reflection.groups[0], outputFileStrategy) || + null ); } return reflection.groups ?.map((group) => { - const groupChildren = getGroupChildren(group, outputFileStrategy); - return groupChildren?.length - ? { - title: - theme.textContentMappings[PLURAL_KIND_KEY_MAP[group.title]] || - group.title, - children: groupChildren || null, - } - : null; + const groupChildren = this.getGroupChildren( + group, + outputFileStrategy, + ); + if (groupChildren?.length) { + if (group.owningReflection.kind === ReflectionKind.Document) { + return groupChildren[0]; + } + return { + title: group.title, + children: groupChildren, + }; + } + return null; }) .filter((group) => Boolean(group)) as NavigationItem[]; } return null; } - function processChildren( + private processChildren( acc: NavigationItem[], - child: DeclarationReflection, + child: DeclarationReflection | DocumentReflection, children: NavigationItem[] | null, ) { - if (!isQuoted(child.name) && !navigationOptions.excludeFolders) { + if (!isQuoted(child.name) && !this.navigationOptions.excludeFolders) { const titleParts = child.name.split('/'); if (!child.name.startsWith('@') && titleParts.length > 1) { let currentLevel = acc; diff --git a/packages/typedoc-plugin-markdown/src/theme/core/url-builder.ts b/packages/typedoc-plugin-markdown/src/theme/core/url-builder.ts index 1eb1e9d4d..e3ca5ab47 100644 --- a/packages/typedoc-plugin-markdown/src/theme/core/url-builder.ts +++ b/packages/typedoc-plugin-markdown/src/theme/core/url-builder.ts @@ -4,6 +4,7 @@ import { isQuoted, removeFirstScopedDirectory, slugify, + toPascalCase, } from '@plugin/libs/utils'; import { OutputFileStrategy } from '@plugin/options/option-maps'; import { MarkdownTheme } from '@plugin/theme/markdown-theme'; @@ -15,7 +16,9 @@ import { import * as path from 'path'; import { DeclarationReflection, + DocumentReflection, EntryPointStrategy, + Options, ProjectReflection, Reflection, ReflectionKind, @@ -27,90 +30,113 @@ import { * * @param project The project whose urls should be generated. */ -export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { - const options = theme.application.options; - const packagesMeta = (theme.application.renderer as MarkdownRenderer) - .packagesMeta; - const urls: UrlMapping[] = []; - const anchors: Record = {}; - const flattenOutputFiles = options.getValue('flattenOutputFiles'); - const fileExtension = options.getValue('fileExtension'); - const ignoreScopes = options.getValue('excludeScopesInPaths'); - const entryFileName = getFileNameWithExtension( - options.getValue('entryFileName'), - fileExtension, - ); - - const isPackages = - options.getValue('entryPointStrategy') === EntryPointStrategy.Packages; - - buildEntryUrls(); - - if (isPackages) { - if (Object.keys(packagesMeta)?.length === 1) { - buildUrlsFromProject(project); +export class UrlBuilder { + private options: Options; + private packagesMeta: any; + private fileExtension: string; + private ignoreScopes: boolean; + private entryFileName: string; + private writeDocuments: boolean; + private isPackages: boolean; + private flattenOutputFiles: boolean; + private urls: UrlMapping[] = []; + private anchors: Record = {}; + + constructor( + public theme: MarkdownTheme, + public project: ProjectReflection, + ) { + this.options = theme.application.options; + + this.packagesMeta = ( + theme.application.renderer as MarkdownRenderer + ).packagesMeta; + + this.fileExtension = this.options.getValue('fileExtension'); + this.ignoreScopes = this.options.getValue('excludeScopesInPaths'); + this.writeDocuments = !this.options.getValue('inlineDocuments'); + + this.entryFileName = getFileNameWithExtension( + this.options.getValue('entryFileName'), + this.fileExtension, + ); + + this.isPackages = + this.options.getValue('entryPointStrategy') === + EntryPointStrategy.Packages; + + this.flattenOutputFiles = this.options.getValue('flattenOutputFiles'); + } + + getUrls() { + this.buildEntryUrls(); + + if (this.isPackages) { + if (Object.keys(this.packagesMeta)?.length === 1) { + this.buildUrlsFromProject(this.project); + } else { + this.project.children?.forEach((projectChild) => { + this.buildUrlsFromPackage(projectChild); + }); + } } else { - project.children?.forEach((projectChild) => { - buildUrlsFromPackage(projectChild); - }); + this.buildUrlsFromProject(this.project); } - } else { - buildUrlsFromProject(project); - } - return urls; + return this.urls; + } - function buildEntryUrls() { + private buildEntryUrls() { const preserveReadme = - Boolean(project.readme) && !options.getValue('mergeReadme'); + Boolean(this.project.readme) && !this.options.getValue('mergeReadme'); - const isModulesOnly = project.children?.every( + const isModulesOnly = this.project.children?.every( (child) => child.kind === ReflectionKind.Module, ); const useEntryModule = - project?.groups && + this.project?.groups && Boolean( - project?.groups[0]?.children.find( - (child) => child.name === options.getValue('entryModule'), + this.project?.groups[0]?.children.find( + (child) => child.name === this.options.getValue('entryModule'), ), ) && isModulesOnly; - const indexFilename = getIndexFileName(project, isPackages); + const indexFilename = this.getIndexFileName(this.project, this.isPackages); - project.url = preserveReadme + this.project.url = preserveReadme ? indexFilename : useEntryModule ? indexFilename - : entryFileName; + : this.entryFileName; if (preserveReadme) { - urls.push({ + this.urls.push({ url: useEntryModule - ? getFileNameWithExtension('readme_', fileExtension) - : entryFileName, - model: project, - template: theme.readmeTemplate, + ? getFileNameWithExtension('readme_', this.fileExtension) + : this.entryFileName, + model: this.project, + template: this.theme.readmeTemplate, }); if (!useEntryModule) { - urls.push({ + this.urls.push({ url: indexFilename, - model: project, - template: theme.projectTemplate, + model: this.project, + template: this.theme.projectTemplate, }); } } else { if (!useEntryModule) { - urls.push({ - url: entryFileName, - model: project, - template: theme.projectTemplate, + this.urls.push({ + url: this.entryFileName, + model: this.project, + template: this.theme.projectTemplate, }); } } } - function buildUrlsFromProject( + private buildUrlsFromProject( project: ProjectReflection | DeclarationReflection, parentUrl?: string, outputFileStrategy?: OutputFileStrategy, @@ -119,47 +145,55 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { ) { project.groups?.forEach((projectGroup) => { projectGroup.children?.forEach((projectGroupChild) => { - buildUrlsFromGroup(projectGroupChild, { - ...(parentUrl && { parentUrl }), - ...(outputFileStrategy && { outputFileStrategy }), - ...(entryModule && { entryModule }), - ...(entryFileName && { entryFileName }), - }); + if ( + this.writeDocuments && + projectGroupChild instanceof DocumentReflection + ) { + this.buildUrlsForDocuments(projectGroupChild); + } + if (projectGroupChild instanceof DeclarationReflection) { + this.buildUrlsFromGroup(projectGroupChild, { + ...(parentUrl && { parentUrl }), + ...(outputFileStrategy && { outputFileStrategy }), + ...(entryModule && { entryModule }), + ...(entryFileName && { entryFileName }), + }); + } }); }); } - function buildUrlsFromPackage(projectChild: DeclarationReflection) { + private buildUrlsFromPackage(projectChild: DeclarationReflection) { const preservePackageReadme = - Boolean(projectChild.readme) && !options.getValue('mergeReadme'); + Boolean(projectChild.readme) && !this.options.getValue('mergeReadme'); - const packagesIndex = getIndexFileName(projectChild); + const packagesIndex = this.getIndexFileName(projectChild); - const packageOptions = packagesMeta[projectChild.name]?.options; + const packageOptions = this.packagesMeta[projectChild.name]?.options; const outputFileStrategy = packageOptions.isSet('outputFileStrategy') ? packageOptions.getValue('outputFileStrategy') - : options.getValue('outputFileStrategy'); + : this.options.getValue('outputFileStrategy'); const entryModule = packageOptions.isSet('entryModule') ? packageOptions.getValue('entryModule') - : options.getValue('entryModule'); + : this.options.getValue('entryModule'); const packageEntryFileName = packageOptions.isSet('entryFileName') ? packageOptions.getValue('entryFileName') - : options.getValue('entryFileName'); + : this.options.getValue('entryFileName'); let fullEntryFileName = getFileNameWithExtension( path.join(projectChild.name, packageEntryFileName), - fileExtension, + this.fileExtension, ); let fullIndexFileName = getFileNameWithExtension( path.join(projectChild.name, packagesIndex), - fileExtension, + this.fileExtension, ); - if (ignoreScopes) { + if (this.ignoreScopes) { fullEntryFileName = removeFirstScopedDirectory(fullEntryFileName); fullIndexFileName = removeFirstScopedDirectory(fullIndexFileName); } @@ -182,30 +216,33 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { isModulesOnly; if (preservePackageReadme) { - urls.push({ + this.urls.push({ url: useEntryModule - ? `${path.dirname(indexFileName)}/${getFileNameWithExtension('readme_', fileExtension)}` + ? `${path.dirname(indexFileName)}/${getFileNameWithExtension('readme_', this.fileExtension)}` : path.join( path.dirname(indexFileName), - getFileNameWithExtension(packageEntryFileName, fileExtension), + getFileNameWithExtension( + packageEntryFileName, + this.fileExtension, + ), ), model: projectChild, - template: theme.readmeTemplate, + template: this.theme.readmeTemplate, }); if (!useEntryModule) { - urls.push({ + this.urls.push({ url: indexFileName, model: projectChild, - template: theme.projectTemplate, + template: this.theme.projectTemplate, }); } } else { if (!useEntryModule) { - urls.push({ + this.urls.push({ url: indexFileName, model: projectChild, - template: theme.projectTemplate, + template: this.theme.projectTemplate, }); } } @@ -216,7 +253,7 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { indexFileName.split(path.sep)?.length > 1 ? indexFileName : `${projectChild.name}/${indexFileName}`; - buildUrlsFromProject( + this.buildUrlsFromProject( projectChild, parentUrl, outputFileStrategy, @@ -225,11 +262,58 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { ); } - function buildUrlsFromGroup( + private buildUrlsForDocuments(reflection: DocumentReflection) { + const mapping: TemplateMapping = this.theme.getTemplateMapping( + reflection.kind, + ); + + if (mapping) { + const baseUrl = path.dirname(reflection.parent?.url || ''); + + const directory = this.flattenOutputFiles + ? ReflectionKind.singularString(reflection.kind) + : (mapping.directory as string); + const filename = [ + getFileNameWithExtension( + reflection.name.replace(/ /g, '-'), + this.fileExtension, + ), + ]; + if ( + reflection?.parent?.kind && + ![ReflectionKind.Module, ReflectionKind.Project].includes( + reflection?.parent?.kind, + ) + ) { + filename.unshift( + toPascalCase(ReflectionKind.singularString(reflection.parent?.kind)), + ); + } + + const urlBase = path.join(baseUrl, directory, filename.join('.')); + const url = this.flattenOutputFiles + ? urlBase.replace(/\//g, '.') + : urlBase; + + this.urls.push({ + url, + model: reflection, + template: mapping.template, + }); + reflection.url = url; + reflection.hasOwnDocument = true; + } + } + + private buildUrlsFromGroup( reflection: DeclarationReflection, urlOptions: UrlOption, ) { - const mapping: TemplateMapping = theme.getTemplateMapping( + if (reflection.kind === ReflectionKind.Document && !this.writeDocuments) { + return; + } + + const mapping: TemplateMapping = this.theme.getTemplateMapping( reflection.kind, urlOptions.outputFileStrategy, ); @@ -238,35 +322,38 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { let url: string; let urlPath = ''; - if (flattenOutputFiles) { - url = getFlattenedUrl(reflection); + if (this.flattenOutputFiles) { + url = this.getFlattenedUrl(reflection); } else { const directory = urlOptions.directory || mapping.directory; - urlPath = getUrlPath(reflection, { + urlPath = this.getUrlPath(reflection, { ...urlOptions, directory, }); - url = getUrl(reflection, urlPath, urlOptions); + url = this.getUrl(reflection, urlPath, urlOptions); - if (ignoreScopes) { + if (this.ignoreScopes) { url = removeFirstScopedDirectory(url); } - const duplicateUrls = urls.filter( + const duplicateUrls = this.urls.filter( (urlMapping) => urlMapping.url.toLowerCase().replace(/-\d+$/, '') === url.toLowerCase(), ); - if (duplicateUrls.length > 0) { + if ( + duplicateUrls.length > 0 && + reflection.kind !== ReflectionKind.Document + ) { const urlParts = url.split('.'); urlParts[urlParts.length - 2] += `-${duplicateUrls.length}`; url = urlParts.join('.'); } } - urls.push({ + this.urls.push({ url: url, model: reflection, template: mapping.template, @@ -277,11 +364,11 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { reflection.groups?.forEach((group) => { group.children.forEach((groupChild) => { - const mapping = theme.getTemplateMapping( + const mapping = this.theme.getTemplateMapping( groupChild.kind, urlOptions.outputFileStrategy, ); - buildUrlsFromGroup(groupChild, { + this.buildUrlsFromGroup(groupChild as DeclarationReflection, { parentUrl: urlPath, directory: mapping?.directory || null, outputFileStrategy: urlOptions.outputFileStrategy, @@ -289,39 +376,67 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { }); }); } else if (reflection.parent) { - applyAnchorUrl(reflection, reflection.parent); + this.traverseChildren(reflection, reflection.parent); } } - function getUrl( + private getUrl( reflection: DeclarationReflection, urlPath: string, urlOptions: UrlOption, ) { const entryModule = - urlOptions.entryModule || options.getValue('entryModule'); + urlOptions.entryModule || this.options.getValue('entryModule'); - const entryName = urlOptions.entryFileName || entryFileName; + const entryName = urlOptions.entryFileName || this.entryFileName; if (reflection.name === entryModule) { return entryName; } if ( - options.getValue('outputFileStrategy') === OutputFileStrategy.Modules && + this.options.getValue('outputFileStrategy') === + OutputFileStrategy.Modules && reflection.name === 'index' && path.parse(entryName).name === 'index' ) { return urlPath.replace( - getFileNameWithExtension('index', fileExtension), - getFileNameWithExtension('module_index', fileExtension), + getFileNameWithExtension('index', this.fileExtension), + getFileNameWithExtension('module_index', this.fileExtension), ); } return urlPath; } - function getUrlPath(reflection: DeclarationReflection, urlOption: UrlOption) { - const alias = getAlias(reflection.name); + getFlattenedUrl(reflection: DeclarationReflection) { + const fullName = reflection.getFullName(); + const fullNameParts = fullName.replace(/\//g, '.').split('.'); + if (reflection.kind !== ReflectionKind.Module) { + fullNameParts.splice( + fullNameParts.length - 1, + 0, + toPascalCase(ReflectionKind.singularString(reflection.kind)), + ); + } + const url = `${fullNameParts.join('.')}${this.fileExtension}` + .replace(/"/g, '') + .replace(/^\./g, ''); + reflection.url = url; + return url; + } + + private getAlias(name: string) { + if (isQuoted(name)) { + name = name.replace(/\//g, '_'); + } + return name + .replace(/"/g, '') + .replace(/^_+|_+$/g, '') + .replace(/[<>]/g, '-'); + } + + private getUrlPath(reflection: DeclarationReflection, urlOption: UrlOption) { + const alias = this.getAlias(reflection.name); const parentDir = urlOption.parentUrl ? path.dirname(urlOption.parentUrl) @@ -346,8 +461,9 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { [ReflectionKind.Module, ReflectionKind.Namespace].includes( reflection.kind, ) && - options.getValue('outputFileStrategy') === OutputFileStrategy.Modules && - !childrenIncludeNamespaces(reflection) + this.options.getValue('outputFileStrategy') === + OutputFileStrategy.Modules && + !this.moduleHasSubfolders(reflection) ) { return null; } @@ -356,76 +472,76 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { reflection.kind, ) ) { - return path.parse(entryFileName).name; + return path.parse(this.entryFileName).name; } return alias; }; return getFileNameWithExtension( [parentDir, dir(), filename()].filter((part) => Boolean(part)).join('/'), - fileExtension, + this.fileExtension, ); } - function getAlias(name: string) { - if (isQuoted(name)) { - name = name.replace(/\//g, '_'); - } - return name - .replace(/"/g, '') - .replace(/^_+|_+$/g, '') - .replace(/[<>]/g, '-'); - } - - function applyAnchorUrl( + private traverseChildren( reflection: DeclarationReflection, container: Reflection, ) { if (container.url) { - if (reflection.kind !== ReflectionKind.TypeLiteral) { - const anchorPrefix = options.getValue('anchorPrefix'); - const anchorId = getAnchorId(reflection); + this.applyAnchorUrl(reflection, container.url); + } + if (reflection.parent) { + reflection.traverse((child) => { + if (this.writeDocuments && child instanceof DocumentReflection) { + this.buildUrlsForDocuments(child); + } + if (child instanceof DeclarationReflection) { + this.traverseChildren(child, container); + } + }); + } + } - if (anchorId) { - if (!anchors[container.url]) { - anchors[container.url] = []; - } + private applyAnchorUrl( + reflection: DeclarationReflection, + containerUrl: string, + ) { + if (reflection.kind !== ReflectionKind.TypeLiteral) { + const anchorPrefix = this.options.getValue('anchorPrefix'); + const anchorId = this.getAnchorId(reflection); - anchors[container.url].push(anchorId); + if (anchorId) { + if (!this.anchors[containerUrl]) { + this.anchors[containerUrl] = []; + } - const count = anchors[container.url]?.filter( - (id) => id === anchorId, - )?.length; + this.anchors[containerUrl].push(anchorId); - const anchorParts = [anchorId]; + const count = this.anchors[containerUrl]?.filter( + (id) => id === anchorId, + )?.length; - if (count > 1) { - anchorParts.push(`-${count - 1}`); - } + const anchorParts = [anchorId]; - if (anchorPrefix) { - anchorParts.unshift(`${anchorPrefix}`); - } + if (count > 1) { + anchorParts.push(`-${count - 1}`); + } - reflection.url = container.url + '#' + anchorParts.join(''); - reflection.anchor = anchorParts.join(''); - reflection.hasOwnDocument = false; + if (anchorPrefix) { + anchorParts.unshift(`${anchorPrefix}`); } + + reflection.url = containerUrl + '#' + anchorParts.join(''); + reflection.anchor = anchorParts.join(''); + reflection.hasOwnDocument = false; } } - if (reflection.parent) { - reflection.traverse((child) => { - if (child instanceof DeclarationReflection) { - applyAnchorUrl(child, container); - } - }); - } } - function getAnchorId(reflection: DeclarationReflection) { - const preserveAnchorCasing = options.getValue('preserveAnchorCasing'); + private getAnchorId(reflection: DeclarationReflection) { + const preserveAnchorCasing = this.options.getValue('preserveAnchorCasing'); - const anchorName = getAnchorName(reflection); + const anchorName = this.getAnchorName(reflection); if (anchorName) { return preserveAnchorCasing ? anchorName : anchorName.toLowerCase(); @@ -434,15 +550,15 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { return null; } - function getAnchorName(reflection: DeclarationReflection) { - const htmlTableAnchors = options.getValue('useHTMLAnchors'); + private getAnchorName(reflection: DeclarationReflection) { + const htmlTableAnchors = this.options.getValue('useHTMLAnchors'); if (!htmlTableAnchors) { if ( (reflection.kind === ReflectionKind.Property && - options.getValue('propertiesFormat') === 'table') || + this.options.getValue('propertiesFormat') === 'table') || (reflection.kind === ReflectionKind.EnumMember && - options.getValue('enumMembersFormat') === 'table') + this.options.getValue('enumMembersFormat') === 'table') ) { return null; } @@ -461,41 +577,24 @@ export function buildUrls(theme: MarkdownTheme, project: ProjectReflection) { return anchorParts.join(''); } - function childrenIncludeNamespaces(reflection: DeclarationReflection) { - return reflection.children?.some( - (child) => child.kind === ReflectionKind.Namespace, + private moduleHasSubfolders(reflection: DeclarationReflection) { + return reflection.childrenIncludingDocuments?.some((child) => + [ReflectionKind.Namespace, ReflectionKind.Document].includes(child.kind), ); } - function getIndexFileName( + private getIndexFileName( reflection: ProjectReflection | DeclarationReflection, isPackages = false, ) { if (isPackages) { - return getFileNameWithExtension('packages', fileExtension); + return getFileNameWithExtension('packages', this.fileExtension); } const isModules = reflection.children?.every( (child) => child.kind === ReflectionKind.Module, ); return isModules - ? getFileNameWithExtension('modules', fileExtension) - : getFileNameWithExtension('globals', fileExtension); - } - - function getFlattenedUrl(reflection: DeclarationReflection) { - const fullName = reflection.getFullName(); - const fullNameParts = fullName.replace(/\//g, '.').split('.'); - if (reflection.kind !== ReflectionKind.Module) { - fullNameParts.splice( - fullNameParts.length - 1, - 0, - ReflectionKind.singularString(reflection.kind).split(' ')[0], - ); - } - const url = `${fullNameParts.join('.')}${fileExtension}` - .replace(/"/g, '') - .replace(/^\./g, ''); - reflection.url = url; - return url; + ? getFileNameWithExtension('modules', this.fileExtension) + : getFileNameWithExtension('globals', this.fileExtension); } } diff --git a/packages/typedoc-plugin-markdown/src/theme/markdown-theme.ts b/packages/typedoc-plugin-markdown/src/theme/markdown-theme.ts index 2af5e9120..96da79b68 100644 --- a/packages/typedoc-plugin-markdown/src/theme/markdown-theme.ts +++ b/packages/typedoc-plugin-markdown/src/theme/markdown-theme.ts @@ -1,21 +1,19 @@ import { MarkdownRenderer } from '@plugin/app/application'; import { MarkdownPageEvent } from '@plugin/app/events'; +import { getTranslatable } from '@plugin/app/translatable'; import { formatMarkdown } from '@plugin/libs/utils'; -import { - OutputFileStrategy, - TEXT_MAPPING_DEFAULTS, - TextContentMappings, -} from '@plugin/options'; +import { OutputFileStrategy } from '@plugin/options'; import { RenderTemplate } from '@plugin/theme'; import { DeclarationReflection, + DocumentReflection, ProjectReflection, Reflection, ReflectionKind, Theme, } from 'typedoc'; -import { buildNavigation } from './core/navigation-builder'; -import { buildUrls } from './core/url-builder'; +import { NavigationBuilder } from './core/navigation-builder'; +import { UrlBuilder } from './core/url-builder'; import { MarkdownThemeContext } from './markdown-themecontext'; /** @@ -47,17 +45,16 @@ export class MarkdownTheme extends Theme { * * @internal */ - readonly textContentMappings: Partial; /** * @ignore */ constructor(renderer: MarkdownRenderer) { super(renderer); - this.textContentMappings = { - ...TEXT_MAPPING_DEFAULTS, - ...(this.application.options.getValue('textContentMappings') || {}), - }; + this.application.internationalization.addTranslations( + 'en', + getTranslatable(this.application), + ); } /** @@ -93,7 +90,7 @@ export class MarkdownTheme extends Theme { * This method can be overriden to provide an alternative url structure. */ getUrls(project: ProjectReflection) { - return buildUrls(this, project); + return new UrlBuilder(this, project).getUrls(); } /** @@ -102,7 +99,7 @@ export class MarkdownTheme extends Theme { * This method can be overriden to provide an alternative navigation structure. */ getNavigation(project: ProjectReflection) { - return buildNavigation(this, project); + return new NavigationBuilder(this, project).getNavigation(); } /** @@ -145,6 +142,11 @@ export class MarkdownTheme extends Theme { directory: directoryName(ReflectionKind.Namespace), kind: ReflectionKind.Namespace, }, + [ReflectionKind.Document]: { + template: this.documentTemplate, + directory: directoryName(ReflectionKind.Document), + kind: ReflectionKind.Document, + }, }; if ( @@ -222,24 +224,31 @@ export class MarkdownTheme extends Theme { return mappings[kind]; } + /** + * @internal + */ + documentTemplate = (page: MarkdownPageEvent) => { + return this.getRenderContext(page).templates.document(page); + }; + /** * @internal */ readmeTemplate = (page: MarkdownPageEvent) => { - return this.getRenderContext(page).templates.readme(); + return this.getRenderContext(page).templates.readme(page); }; /** * @internal */ projectTemplate = (page: MarkdownPageEvent) => { - return this.getRenderContext(page).templates.project(); + return this.getRenderContext(page).templates.project(page); }; /** * @internal */ reflectionTemplate = (page: MarkdownPageEvent) => { - return this.getRenderContext(page).templates.reflection(); + return this.getRenderContext(page).templates.reflection(page); }; } diff --git a/packages/typedoc-plugin-markdown/src/theme/markdown-themecontext.ts b/packages/typedoc-plugin-markdown/src/theme/markdown-themecontext.ts index f69fbe007..550228026 100644 --- a/packages/typedoc-plugin-markdown/src/theme/markdown-themecontext.ts +++ b/packages/typedoc-plugin-markdown/src/theme/markdown-themecontext.ts @@ -1,11 +1,10 @@ import { MarkdownRenderer } from '@plugin/app/application'; import { MarkdownPageEvent } from '@plugin/app/events'; import { MarkdownRendererHooks } from '@plugin/app/renderer'; -import { TextContentMappings } from '@plugin/options'; import { MarkdownTheme, PackageMetaData } from '@plugin/theme'; import { helpers, partials, templates } from '@plugin/theme/resources'; import * as path from 'path'; -import { Options, Reflection } from 'typedoc'; +import { Internationalization, Options, Reflection } from 'typedoc'; /** * The theme context class that is provided as context on the rendering of every page. @@ -43,6 +42,9 @@ import { Options, Reflection } from 'typedoc'; * @category Theme */ export class MarkdownThemeContext { + internationalization: Internationalization.Internationalization; + i18n: Internationalization.TranslationProxy; + /** * */ @@ -60,15 +62,11 @@ export class MarkdownThemeContext { */ readonly options: Options, ) { - this.textContentMappings = this.theme.textContentMappings; this.packagesMetaData = (this.theme.owner as MarkdownRenderer).packagesMeta; + this.internationalization = theme.application.internationalization; + this.i18n = this.internationalization.proxy; } - /** - * Holds the textmappings object of the theme. - */ - private textContentMappings: Partial; - /** * Holds meta data for individual packages (if entryPointStrategy equals `packages`). * @@ -119,15 +117,6 @@ export class MarkdownThemeContext { */ helpers = helpers(this); - /** - * Get text mappings from the theme. - * - * @param key - The key of the text mappings - */ - getText(key: keyof TextContentMappings): string { - return this.textContentMappings[key] as string; - } - /** * Returns the package meta data for a given package name when entrypointStrategy is set to `packages`. * diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-declaration-comment.ts b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-declaration-comment.ts deleted file mode 100644 index 04ed234cc..000000000 --- a/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-declaration-comment.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DeclarationReflection } from 'typedoc'; - -export function getDeclarationComment(model: DeclarationReflection) { - if (model.signatures?.length) { - return model.signatures[0].comment; - } - return model.comment; -} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-description-for-reflection.ts b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-description-for-reflection.ts new file mode 100644 index 000000000..6b4e34c7d --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-description-for-reflection.ts @@ -0,0 +1,18 @@ +import { MarkdownThemeContext } from 'public-api'; +import { DeclarationReflection } from 'typedoc'; + +export function getDescriptionForReflection( + this: MarkdownThemeContext, + model: DeclarationReflection, +) { + const comment = model.signatures?.length + ? model.signatures[0].comment + : model.comment; + if (comment?.summary?.length) { + return this.partials + .commentParts(comment.summary) + ?.split('\n\n')[0] + .replace(/\n/g, ' '); + } + return null; +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-list.ts b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-list.ts new file mode 100644 index 000000000..cebd7bc11 --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-list.ts @@ -0,0 +1,20 @@ +import { link } from '@plugin/libs/markdown'; +import { escapeChars } from '@plugin/libs/utils'; +import { MarkdownThemeContext } from 'public-api'; +import { DeclarationReflection, DocumentReflection } from 'typedoc'; + +export function getGroupIndexList( + this: MarkdownThemeContext, + children: DeclarationReflection[] | DocumentReflection[], +) { + const filteredChildren = + children + .filter((child) => Boolean(child.url)) + .map((child) => { + return child.url + ? `- ${link(escapeChars(child.name), this.getRelativeUrl(child.url))}` + : ''; + }) || []; + + return filteredChildren.join('\n'); +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-table.ts b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-table.ts new file mode 100644 index 000000000..dc3a9e01e --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index-table.ts @@ -0,0 +1,38 @@ +import { link, table } from '@plugin/libs/markdown'; +import { escapeChars } from '@plugin/libs/utils'; +import { MarkdownThemeContext } from 'public-api'; +import { + DeclarationReflection, + DocumentReflection, + ReflectionKind, +} from 'typedoc'; + +export function getGroupIndexTable( + this: MarkdownThemeContext, + children: DeclarationReflection[] | DocumentReflection[], +) { + const tableColumnsOptions = this.options.getValue('tableColumns'); + const headers = [ + this.options.getValue('excludeGroups') + ? this.i18n.theme_member() + : ReflectionKind.singularString(children[0].kind), + this.i18n.theme_description(), + ]; + const rows: string[][] = []; + children.forEach((child) => { + const row: string[] = []; + + if (child.url) { + row.push(link(escapeChars(child.name), this.getRelativeUrl(child.url))); + } + const description = + child instanceof DeclarationReflection + ? this.helpers.getDescriptionForReflection(child) + : ((child as DocumentReflection).frontmatter.description as string); + + row.push(description || '-'); + + rows.push(row); + }); + return table(headers, rows, tableColumnsOptions.leftAlignHeadings); +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index.ts b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index.ts new file mode 100644 index 000000000..ca0d37efc --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/helpers/get-group-index.ts @@ -0,0 +1,17 @@ +import { + DeclarationReflection, + DocumentReflection, + ReflectionCategory, + ReflectionGroup, +} from 'typedoc'; + +export function getGroupIndex(group: ReflectionGroup | ReflectionCategory) { + if (this.options.getValue('indexFormat') === 'table') { + return this.helpers.getGroupIndexTable( + group.children as DeclarationReflection[] | DocumentReflection[], + ); + } + return this.helpers.getGroupIndexList( + group.children as DeclarationReflection[] | DocumentReflection[], + ); +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/index.ts b/packages/typedoc-plugin-markdown/src/theme/resources/index.ts index b0392ce43..6b22c7732 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/index.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/index.ts @@ -1,4 +1,5 @@ // THIS FILE IS AUTO GENERATED. DO NOT EDIT DIRECTLY. +import { MarkdownPageEvent } from '@plugin/app/events'; import { MarkdownThemeContext } from '@plugin/theme'; import { ArrayType, @@ -8,6 +9,7 @@ import { ContainerReflection, DeclarationHierarchy, DeclarationReflection, + DocumentReflection, IndexedAccessType, InferredType, IntersectionType, @@ -33,6 +35,7 @@ import { UnknownType, } from 'typedoc'; +import { document } from './templates/document'; import { project } from './templates/project'; import { readme } from './templates/read-me'; import { reflection } from './templates/reflection'; @@ -45,8 +48,10 @@ import { groups } from './partials/container.groups'; import { members } from './partials/container.members'; import { accessor } from './partials/member.accessor'; import { constructor } from './partials/member.constructors'; +import { memberContainer } from './partials/member.container'; import { declaration } from './partials/member.declaration'; import { declarationTitle } from './partials/member.declarationTitle'; +import { documents } from './partials/member.documents'; import { enumMembersTable } from './partials/member.enumMembersTable'; import { hierarchy } from './partials/member.hierarchy'; import { indexSignature } from './partials/member.indexSignature'; @@ -63,6 +68,7 @@ import { signature } from './partials/member.signature'; import { signatureParameters } from './partials/member.signatureParameters'; import { signatureReturns } from './partials/member.signatureReturns'; import { signatureTitle } from './partials/member.signatureTitle'; +import { signatures } from './partials/member.signatures'; import { sources } from './partials/member.sources'; import { member } from './partials/member'; import { typeAndParent } from './partials/member.typeAndParent'; @@ -96,9 +102,12 @@ import { typeOperatorType } from './partials/type.type-operator'; import { unionType } from './partials/type.union'; import { unknownType } from './partials/type.unknown'; -import { getDeclarationComment } from './helpers/get-declaration-comment'; import { getDeclarationType } from './helpers/get-declaration-type'; +import { getDescriptionForReflection } from './helpers/get-description-for-reflection'; import { getFlattenedDeclarations } from './helpers/get-flattened-declarations'; +import { getGroupIndexList } from './helpers/get-group-index-list'; +import { getGroupIndexTable } from './helpers/get-group-index-table'; +import { getGroupIndex } from './helpers/get-group-index'; import { getHierarchyType } from './helpers/get-hierarchy-type'; import { getKeyword } from './helpers/get-keyword'; import { getModifier } from './helpers/get-modifier'; @@ -109,28 +118,32 @@ import { isGroupKind } from './helpers/is-group-kind'; export const templates = (context: MarkdownThemeContext) => { return { + /** + * Template that maps to a project document. + */ + document: (page: MarkdownPageEvent) => + document.apply(context, [page]) as string, /** * Template that maps to the root project reflection. This will be the index page / documentation root page. - * */ - project: () => project.apply(context, []) as string, + project: (page: MarkdownPageEvent) => + project.apply(context, [page]) as string, /** * Template that specifically maps to the resolved readme file. This template is not used when 'readme' is set to 'none'. - * */ - readme: () => readme.apply(context, []) as string, + readme: (page: MarkdownPageEvent) => + readme.apply(context, [page]) as string, /** * Template that maps to individual reflection models. - * */ - reflection: () => reflection.apply(context, []) as string, + reflection: (page: MarkdownPageEvent) => + reflection.apply(context, [page]) as string, }; }; export const partials = (context: MarkdownThemeContext) => { return { /** - * * * @category Comment Partials */ @@ -144,14 +157,12 @@ export const partials = (context: MarkdownThemeContext) => { } = {}, ) => comment.apply(context, [model, options]) as string, /** - * * * @category Comment Partials */ commentParts: (model: CommentDisplayPart[]) => commentParts.apply(context, [model]) as string, /** - * * * @category Container Partials */ @@ -159,7 +170,6 @@ export const partials = (context: MarkdownThemeContext) => { body.apply(context, [model, options]) as string, /** * Renders a collection of reflection categories. - * * @category Container Partials */ categories: ( @@ -168,14 +178,12 @@ export const partials = (context: MarkdownThemeContext) => { ) => categories.apply(context, [model, options]) as string, /** * Renders a collection of reflection groups. - * * @category Container Partials */ groups: (model: ReflectionGroup[], options: { headingLevel: number }) => groups.apply(context, [model, options]) as string, /** * Renders a collection of members. - * * @category Container Partials */ members: ( @@ -184,7 +192,6 @@ export const partials = (context: MarkdownThemeContext) => { ) => members.apply(context, [model, options]) as string, /** * Renders an accessor member. - * * @category Member Partials */ accessor: ( @@ -193,7 +200,6 @@ export const partials = (context: MarkdownThemeContext) => { ) => accessor.apply(context, [model, options]) as string, /** * Renders an constructor member. - * * @category Member Partials */ constructor: ( @@ -201,10 +207,17 @@ export const partials = (context: MarkdownThemeContext) => { options: { headingLevel: number }, ) => constructor.apply(context, [model, options]) as string, /** - * Renders a standard declaration member. * * @category Member Partials */ + memberContainer: ( + model: DeclarationReflection, + options: { headingLevel: number; nested?: boolean | undefined }, + ) => memberContainer.apply(context, [model, options]) as string, + /** + * Renders a standard declaration member. + * @category Member Partials + */ declaration: ( model: DeclarationReflection, options: { headingLevel: number; nested?: boolean | undefined } = { @@ -213,21 +226,26 @@ export const partials = (context: MarkdownThemeContext) => { }, ) => declaration.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ declarationTitle: (model: DeclarationReflection) => declarationTitle.apply(context, [model]) as string, /** - * Renders enum members as a table. * * @category Member Partials */ + documents: ( + model: ProjectReflection | DeclarationReflection | ContainerReflection, + options: { headingLevel: number }, + ) => documents.apply(context, [model, options]) as string, + /** + * Renders enum members as a table. + * @category Member Partials + */ enumMembersTable: (model: DeclarationReflection[]) => enumMembersTable.apply(context, [model]) as string, /** - * * * @category Member Partials */ @@ -237,14 +255,12 @@ export const partials = (context: MarkdownThemeContext) => { ) => hierarchy.apply(context, [model, options]) as string, /** * Renders an index signature block - * * @category Member Partials */ indexSignature: (model: SignatureReflection) => indexSignature.apply(context, [model]) as string, /** * Renders an inheritance section. - * * @category Member Partials */ inheritance: ( @@ -253,14 +269,12 @@ export const partials = (context: MarkdownThemeContext) => { ) => inheritance.apply(context, [model, options]) as string, /** * Renders the main member title. - * * @category Member Partials */ memberTitle: (model: DeclarationReflection) => memberTitle.apply(context, [model]) as string, /** * Renders a top-level member that contains group and child members such as Classes, Interfaces and Enums. - * * @category Member Partials */ memberWithGroups: ( @@ -268,14 +282,12 @@ export const partials = (context: MarkdownThemeContext) => { options: { headingLevel: number }, ) => memberWithGroups.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ parametersList: (model: ParameterReflection[]) => parametersList.apply(context, [model]) as string, /** - * * * @category Member Partials */ @@ -285,7 +297,6 @@ export const partials = (context: MarkdownThemeContext) => { * Renders a collection of properties in a table. There is no association list partial for properties as these are handled as a standard list of members. - * * @category Member Partials * */ @@ -295,30 +306,26 @@ There is no association list partial for properties as these are handled as a st ) => declarationsTable.apply(context, [model, options]) as string, /** * Renders an reference member. - * * @category Member Partials */ referenceMember: (model: ReferenceReflection) => referenceMember.apply(context, [model]) as string, /** * Renders the flags of a reflection. - * * @category Member Partials */ reflectionFlags: (model: Reflection) => reflectionFlags.apply(context, [model]) as string, /** - * Renders the index section of a reflection. * * @category Member Partials */ reflectionIndex: ( - model: DeclarationReflection | ProjectReflection, + model: ProjectReflection | DeclarationReflection, options: { headingLevel: number }, ) => reflectionIndex.apply(context, [model, options]) as string, /** * Renders a signature member. - * * @category Member Partials */ signature: ( @@ -327,17 +334,16 @@ There is no association list partial for properties as these are handled as a st headingLevel: number; nested?: boolean | undefined; accessor?: string | undefined; + multipleSignatures?: boolean | undefined; }, ) => signature.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ signatureParameters: (model: ParameterReflection[]) => signatureParameters.apply(context, [model]) as string, /** - * * * @category Member Partials */ @@ -346,7 +352,6 @@ There is no association list partial for properties as these are handled as a st options: { headingLevel: number }, ) => signatureReturns.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ @@ -357,7 +362,14 @@ There is no association list partial for properties as these are handled as a st | undefined, ) => signatureTitle.apply(context, [model, options]) as string, /** - * + * Renders a signature collection. + * @category Member Partials + */ + signatures: ( + model: DeclarationReflection, + options: { headingLevel: number; nested?: boolean | undefined }, + ) => signatures.apply(context, [model, options]) as string, + /** * * @category Member Partials */ @@ -366,7 +378,6 @@ There is no association list partial for properties as these are handled as a st options: { headingLevel: number }, ) => sources.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ @@ -375,14 +386,12 @@ There is no association list partial for properties as these are handled as a st options: { headingLevel: number; nested?: boolean | undefined }, ) => member.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ typeAndParent: (model: ArrayType | ReferenceType) => typeAndParent.apply(context, [model]) as string, /** - * * * @category Member Partials */ @@ -391,7 +400,6 @@ There is no association list partial for properties as these are handled as a st options?: { foreCollpase?: boolean | undefined } | undefined, ) => typeArguments.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ @@ -400,7 +408,6 @@ There is no association list partial for properties as these are handled as a st options: { headingLevel: number }, ) => typeDeclaration.apply(context, [model, options]) as string, /** - * * * @category Member Partials */ @@ -409,136 +416,116 @@ There is no association list partial for properties as these are handled as a st headingLevel: number, ) => typeDeclarationList.apply(context, [model, headingLevel]) as string, /** - * * * @category Member Partials */ typeDeclarationTable: (model: DeclarationReflection[]) => typeDeclarationTable.apply(context, [model]) as string, /** - * * * @category Member Partials */ typeParametersList: (model: TypeParameterReflection[]) => typeParametersList.apply(context, [model]) as string, /** - * * * @category Member Partials */ typeParametersTable: (model: TypeParameterReflection[]) => typeParametersTable.apply(context, [model]) as string, /** - * * * @category Page Partials */ breadcrumbs: () => breadcrumbs.apply(context, []) as string, /** - * * * @category Page Partials */ footer: () => footer.apply(context, []) as string, /** - * * * @category Page Partials */ header: () => header.apply(context, []) as string, /** - * * * @category Page Partials */ packagesIndex: (model: ProjectReflection) => packagesIndex.apply(context, [model]) as string, /** - * * * @category Page Partials */ pageTitle: () => pageTitle.apply(context, []) as string, /** - * * * @category Type Partials */ arrayType: (model: ArrayType) => arrayType.apply(context, [model]) as string, /** - * * * @category Type Partials */ conditionalType: (model: ConditionalType) => conditionalType.apply(context, [model]) as string, /** - * * * @category Type Partials */ indexAccessType: (model: IndexedAccessType) => indexAccessType.apply(context, [model]) as string, /** - * * * @category Type Partials */ inferredType: (model: InferredType) => inferredType.apply(context, [model]) as string, /** - * * * @category Type Partials */ intersectionType: (model: IntersectionType) => intersectionType.apply(context, [model]) as string, /** - * * * @category Type Partials */ intrinsicType: (model: IntrinsicType) => intrinsicType.apply(context, [model]) as string, /** - * * * @category Type Partials */ literalType: (model: LiteralType) => literalType.apply(context, [model]) as string, /** - * * * @category Type Partials */ namedTupleType: (model: NamedTupleMember) => namedTupleType.apply(context, [model]) as string, /** - * * * @category Type Partials */ queryType: (model: QueryType) => queryType.apply(context, [model]) as string, /** - * * * @category Type Partials */ referenceType: (model: ReferenceType) => referenceType.apply(context, [model]) as string, /** - * * * @category Type Partials */ declarationType: (model: DeclarationReflection) => declarationType.apply(context, [model]) as string, /** - * * * @category Type Partials */ @@ -547,7 +534,6 @@ There is no association list partial for properties as these are handled as a st options?: { forceParameterType: boolean } | undefined, ) => functionType.apply(context, [model, options]) as string, /** - * * * @category Type Partials */ @@ -557,34 +543,29 @@ There is no association list partial for properties as these are handled as a st ) => reflectionType.apply(context, [model, options]) as string, /** * Takes a generic Type and returns the appropriate partial for it. - * * @category Type Partials */ someType: (model?: SomeType | undefined) => someType.apply(context, [model]) as string, /** - * * * @category Type Partials */ tupleType: (model: TupleType) => tupleType.apply(context, [model]) as string, /** - * * * @category Type Partials */ typeOperatorType: (model: TypeOperatorType) => typeOperatorType.apply(context, [model]) as string, /** - * * * @category Type Partials */ unionType: (model: UnionType) => unionType.apply(context, [model]) as string, /** - * * * @category Type Partials */ @@ -595,10 +576,10 @@ There is no association list partial for properties as these are handled as a st export const helpers = (context: MarkdownThemeContext) => { return { - getDeclarationComment: (model: DeclarationReflection) => - getDeclarationComment.apply(context, [model]) as Comment | undefined, getDeclarationType: (model: DeclarationReflection) => getDeclarationType.apply(context, [model]) as SomeType | undefined, + getDescriptionForReflection: (model: DeclarationReflection) => + getDescriptionForReflection.apply(context, [model]) as string | null, getFlattenedDeclarations: ( model: DeclarationReflection[], options?: { includeSignatures: boolean } | undefined, @@ -607,6 +588,14 @@ export const helpers = (context: MarkdownThemeContext) => { model, options, ]) as DeclarationReflection[], + getGroupIndexList: ( + children: DeclarationReflection[] | DocumentReflection[], + ) => getGroupIndexList.apply(context, [children]) as string, + getGroupIndexTable: ( + children: DeclarationReflection[] | DocumentReflection[], + ) => getGroupIndexTable.apply(context, [children]) as string, + getGroupIndex: (group: ReflectionCategory | ReflectionGroup) => + getGroupIndex.apply(context, [group]) as any, getHierarchyType: ( model: SomeType, options?: { isTarget: boolean } | undefined, diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/comments.commentParts.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/comments.commentParts.ts index 786433cce..fe3c23ffb 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/comments.commentParts.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/comments.commentParts.ts @@ -12,14 +12,14 @@ export function commentParts( ): string { const md: string[] = []; const parsedText = (text: string) => { - const mediaPattern = /media:\/\/([^ ")\]}]+)/g; - const includePattern = /\[\[include:([^\]]+?)\]\]/g; - const includeDirectory = this.options.getValue('includes'); - const mediaDirectory = this.options.getValue('media'); + // const mediaPattern = /media:\/\/([^ ")\]}]+)/g; + // const includePattern = /\[\[include:([^\]]+?)\]\]/g; + //const includeDirectory = this.options.getValue('includes'); + //const mediaDirectory = this.options.getValue('media'); - let parsedText = text; + const parsedText = text; - if (Boolean(includeDirectory)) { + /*if (Boolean(includeDirectory)) { parsedText = parsedText.replace( includePattern, (match: string, includeFile: string) => { @@ -45,7 +45,7 @@ export function commentParts( return this.getRelativeUrl(`media/${mediaFile}`, true); }, ); - } + }*/ return parsedText; }; diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.body.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.body.ts index 5d6ff7116..9381b48ae 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.body.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.body.ts @@ -1,5 +1,9 @@ import { MarkdownThemeContext } from '@plugin/theme'; -import { ContainerReflection, ReflectionKind } from 'typedoc'; +import { + ContainerReflection, + DocumentReflection, + ReflectionKind, +} from 'typedoc'; /** * @category Container Partials @@ -43,9 +47,13 @@ export function body( } } } else { - if (model.groups) { + const groups = model.groups?.filter( + (group) => !(group.owningReflection instanceof DocumentReflection), + ); + + if (groups?.length) { md.push( - this.partials.groups(model.groups, { + this.partials.groups(groups, { headingLevel: options.headingLevel, }), ); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.categories.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.categories.ts index b1690a7d3..d8fa6ca13 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.categories.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.categories.ts @@ -1,5 +1,5 @@ import { heading } from '@plugin/libs/markdown'; -import { ReflectionCategory } from 'typedoc'; +import { DeclarationReflection, ReflectionCategory } from 'typedoc'; import { MarkdownThemeContext } from '../../markdown-themecontext'; /** @@ -22,7 +22,7 @@ export function categories( } if (category.children) { md.push( - this.partials.members(category.children, { + this.partials.members(category.children as DeclarationReflection[], { headingLevel: options.headingLevel + 1, }), ); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.groups.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.groups.ts index 186086cc0..24c2a2076 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.groups.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.groups.ts @@ -1,7 +1,9 @@ import { heading } from '@plugin/libs/markdown'; -import { PLURAL_KIND_KEY_MAP } from '@plugin/options/text-mappings'; -import { TextContentMappings } from 'public-api'; -import { ReflectionGroup, ReflectionKind } from 'typedoc'; +import { + DeclarationReflection, + ReflectionGroup, + ReflectionKind, +} from 'typedoc'; import { MarkdownThemeContext } from '../../markdown-themecontext'; /** @@ -21,8 +23,7 @@ export function groups( const md: string[] = []; const getGroupTitle = (groupTitle: string) => { - const key = PLURAL_KIND_KEY_MAP[groupTitle] as keyof TextContentMappings; - return this.getText(key) || groupTitle; + return groupTitle; }; groupsWithChildren?.forEach((group, index: number) => { @@ -57,10 +58,12 @@ export function groups( .includes('table') ) { md.push( - this.partials.declarationsTable(group.children, { - isEventProps: - getGroupTitle(group.title) === this.getText('kind.event.plural'), - }), + this.partials.declarationsTable( + group.children as DeclarationReflection[], + { + isEventProps: getGroupTitle(group.title) === 'Events', + }, + ), ); } else if ( isEnumGroup && @@ -69,11 +72,15 @@ export function groups( .toLowerCase() .includes('table') ) { - md.push(this.partials.enumMembersTable(group.children)); + md.push( + this.partials.enumMembersTable( + group.children as DeclarationReflection[], + ), + ); } else { if (group.children) { md.push( - this.partials.members(group.children, { + this.partials.members(group.children as DeclarationReflection[], { headingLevel: options.headingLevel + 1, }), ); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.members.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.members.ts index 3924727ae..0328ae6b7 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.members.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/container.members.ts @@ -21,7 +21,11 @@ export function members( }; const items = model?.filter((item) => !item.hasOwnDocument); items?.forEach((item, index) => { - md.push(this.partials.member(item, { headingLevel: options.headingLevel })); + md.push( + this.partials.memberContainer(item, { + headingLevel: options.headingLevel, + }), + ); if (index < items.length - 1 && displayHr(item)) { md.push(horizontalRule()); } diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.accessor.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.accessor.ts index b62bbe229..429fe38d4 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.accessor.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.accessor.ts @@ -45,11 +45,12 @@ export function accessor( if (model.setSignature?.parameters?.length) { md.push( - heading(options.headingLevel, this.getText('kind.parameter.plural')), + heading( + options.headingLevel, + this.internationalization.kindPluralString(ReflectionKind.Parameter), + ), ); - if ( - this.options.getValue('parametersFormat').toLowerCase().includes('table') - ) { + if (this.options.getValue('parametersFormat') === 'table') { md.push(this.partials.parametersTable(model.setSignature.parameters)); } else { md.push(this.partials.parametersList(model.setSignature.parameters)); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.container.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.container.ts new file mode 100644 index 000000000..4eafb0674 --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.container.ts @@ -0,0 +1,35 @@ +import { heading } from '@plugin/libs/markdown'; +import { MarkdownThemeContext } from '@plugin/theme'; +import { DeclarationReflection, ReflectionKind } from 'typedoc'; + +/** + * @category Member Partials + */ +export function memberContainer( + this: MarkdownThemeContext, + model: DeclarationReflection, + options: { headingLevel: number; nested?: boolean }, +): string { + const md: string[] = []; + + if ( + !model.hasOwnDocument && + model.url && + this.options.getValue('useHTMLAnchors') + ) { + md.push(``); + } + + if (!model.hasOwnDocument && !(model.kind === ReflectionKind.Constructor)) { + md.push(heading(options.headingLevel, this.partials.memberTitle(model))); + } + + md.push( + this.partials.member(model, { + headingLevel: options.headingLevel, + nested: options.nested, + }), + ); + + return md.join('\n\n'); +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.declaration.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.declaration.ts index f49d51961..f85f29b7f 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.declaration.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.declaration.ts @@ -35,6 +35,14 @@ export function declaration( md.push(this.partials.declarationTitle(model)); + if (model?.documents) { + md.push( + this.partials.documents(model, { + headingLevel: options.headingLevel, + }), + ); + } + const typeDeclaration = (model.type as any) ?.declaration as DeclarationReflection; @@ -60,7 +68,7 @@ export function declaration( ) { if (intersectionType.declaration.children) { md.push( - heading(opts.headingLevel, this.getText('label.typeDeclaration')), + heading(opts.headingLevel, this.i18n.theme_type_declaration()), ); md.push( @@ -77,9 +85,7 @@ export function declaration( if (model.type instanceof ReferenceType && model.type.typeArguments?.length) { if (model.type.typeArguments[0] instanceof ReflectionType) { if (model.type.typeArguments[0].declaration?.children) { - md.push( - heading(opts.headingLevel, this.getText('label.typeDeclaration')), - ); + md.push(heading(opts.headingLevel, this.i18n.theme_type_declaration())); md.push( this.partials.typeDeclaration( model.type.typeArguments[0].declaration?.children, @@ -92,7 +98,12 @@ export function declaration( if (model.typeParameters) { md.push( - heading(opts.headingLevel, this.getText('kind.typeParameter.plural')), + heading( + opts.headingLevel, + this.internationalization.kindPluralString( + ReflectionKind.TypeParameter, + ), + ), ); if ( this.options.getValue('parametersFormat').toLowerCase().includes('table') @@ -104,9 +115,11 @@ export function declaration( } if (typeDeclaration) { - if (typeDeclaration?.indexSignature) { - md.push(heading(opts.headingLevel, this.getText('label.indexSignature'))); - md.push(this.partials.indexSignature(typeDeclaration.indexSignature)); + if (typeDeclaration?.indexSignatures?.length) { + md.push(heading(opts.headingLevel, this.i18n.kind_index_signature())); + typeDeclaration?.indexSignatures?.forEach((indexSignature) => { + md.push(this.partials.indexSignature(indexSignature)); + }); } if (typeDeclaration?.signatures?.length) { @@ -127,7 +140,7 @@ export function declaration( if (!opts.nested && typeDeclaration?.children?.length) { if (useHeading) { md.push( - heading(opts.headingLevel, this.getText('label.typeDeclaration')), + heading(opts.headingLevel, this.i18n.theme_type_declaration()), ); } @@ -135,11 +148,14 @@ export function declaration( typeDeclaration.categories.forEach((category) => { md.push(heading(opts.headingLevel, category.title)); md.push( - this.partials.typeDeclaration(category.children, { - headingLevel: useHeading - ? opts.headingLevel + 1 - : opts.headingLevel, - }), + this.partials.typeDeclaration( + category.children as DeclarationReflection[], + { + headingLevel: useHeading + ? opts.headingLevel + 1 + : opts.headingLevel, + }, + ), ); }); } else { diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.documents.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.documents.ts new file mode 100644 index 000000000..5cd47f615 --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.documents.ts @@ -0,0 +1,39 @@ +import { heading } from '@plugin/libs/markdown'; +import { MarkdownThemeContext } from '@plugin/theme'; +import { + ContainerReflection, + DeclarationReflection, + DocumentReflection, + ProjectReflection, +} from 'typedoc'; + +/** + * @category Member Partials + */ +export function documents( + this: MarkdownThemeContext, + model: ProjectReflection | DeclarationReflection | ContainerReflection, + options: { headingLevel: number }, +): string { + const md: string[] = []; + const docGroups = model.groups?.filter( + (group) => group.owningReflection instanceof DocumentReflection, + ); + if (docGroups?.length) { + docGroups.forEach((reflectionGroup) => { + md.push(heading(options.headingLevel, reflectionGroup.title)); + if (this.options.getValue('inlineDocuments')) { + reflectionGroup.children.forEach((child) => { + md.push( + this.partials.commentParts((child as DocumentReflection).content), + ); + }); + } else { + docGroups.forEach((reflectionGroup) => { + md.push(this.helpers.getGroupIndex(reflectionGroup)); + }); + } + }); + } + return md.join('\n\n'); +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.enumMembersTable.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.enumMembersTable.ts index debd2ddb7..d3ebccacc 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.enumMembersTable.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.enumMembersTable.ts @@ -1,7 +1,7 @@ import { backTicks, htmlTable, table } from '@plugin/libs/markdown'; import { removeLineBreaks } from '@plugin/libs/utils'; import { MarkdownThemeContext } from '@plugin/theme'; -import { DeclarationReflection, ReflectionType } from 'typedoc'; +import { DeclarationReflection, ReflectionKind, ReflectionType } from 'typedoc'; /** * Renders enum members as a table. @@ -18,12 +18,12 @@ export function enumMembersTable( const hasComments = comments.some((value) => Boolean(value)); const headers = [ - this.getText('kind.enumMember.singular'), - this.getText('label.value'), + this.internationalization.kindSingularString(ReflectionKind.EnumMember), + this.i18n.theme_value(), ]; if (hasComments) { - headers.push(this.getText('label.description')); + headers.push(this.i18n.theme_description()); } const rows: string[][] = []; diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.hierarchy.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.hierarchy.ts index e1434b620..06bbd3e32 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.hierarchy.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.hierarchy.ts @@ -24,12 +24,10 @@ export function hierarchy( : null; if (hModel.next) { if (parent) { - md.push(heading(options.headingLevel, this.getText('label.extends'))); + md.push(heading(options.headingLevel, this.i18n.theme_extends())); md.push(`- ${parent}`); } else { - md.push( - heading(options.headingLevel, this.getText('label.extendedBy')), - ); + md.push(heading(options.headingLevel, this.i18n.theme_extended_by())); const lines: string[] = []; hModel.next.types.forEach((hierarchyType) => { lines.push( diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.inheritance.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.inheritance.ts index ae31230a7..fd1f3234d 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.inheritance.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.inheritance.ts @@ -17,7 +17,7 @@ export function inheritance( if (model.implementationOf) { if (options.headingLevel !== -1) { md.push( - heading(options.headingLevel, this.getText('label.implementationOf')), + heading(options.headingLevel, this.i18n.theme_implementation_of()), ); } md.push(this.partials.typeAndParent(model.implementationOf)); @@ -25,15 +25,13 @@ export function inheritance( if (model.inheritedFrom) { if (options.headingLevel !== -1) { - md.push( - heading(options.headingLevel, this.getText('label.inheritedFrom')), - ); + md.push(heading(options.headingLevel, this.i18n.theme_inherited_from())); } md.push(this.partials.typeAndParent(model.inheritedFrom)); } if (model.overwrites) { - const overridesLabel = this.getText('label.overrides'); + const overridesLabel = this.i18n.theme_overrides(); if (options.headingLevel !== -1) { md.push(heading(options.headingLevel, overridesLabel)); } diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberTitle.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberTitle.ts index 001c32969..4b9d7225f 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberTitle.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberTitle.ts @@ -24,10 +24,7 @@ export function memberTitle( name.push( `${ - /\\/.test(model.name) || - (model.name.startsWith('[') && model.signatures?.length) - ? backTicks(model.name) - : escapeChars(model.name) + /\\/.test(model.name) ? backTicks(model.name) : escapeChars(model.name) }`, ); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberWithGroups.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberWithGroups.ts index ccfa3a350..5955252f5 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberWithGroups.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.memberWithGroups.ts @@ -1,6 +1,6 @@ import { heading, unorderedList } from '@plugin/libs/markdown'; import { MarkdownThemeContext } from '@plugin/theme'; -import { DeclarationReflection } from 'typedoc'; +import { DeclarationReflection, ReflectionKind } from 'typedoc'; /** * Renders a top-level member that contains group and child members such as Classes, Interfaces and Enums. @@ -32,11 +32,14 @@ export function memberWithGroups( if (model.typeParameters?.length) { md.push( - heading(options.headingLevel, this.getText('kind.typeParameter.plural')), + heading( + options.headingLevel, + this.internationalization.kindPluralString( + ReflectionKind.TypeParameter, + ), + ), ); - if ( - this.options.getValue('parametersFormat').toLowerCase().includes('table') - ) { + if (this.options.getValue('parametersFormat') === 'table') { md.push(this.partials.typeParametersTable(model.typeParameters)); } else { md.push(this.partials.typeParametersList(model.typeParameters)); @@ -44,7 +47,7 @@ export function memberWithGroups( } if (model.implementedTypes?.length) { - md.push(heading(options.headingLevel, this.getText('label.implements'))); + md.push(heading(options.headingLevel, this.i18n.theme_implements())); md.push( unorderedList( model.implementedTypes.map((implementedType) => @@ -64,16 +67,37 @@ export function memberWithGroups( }); } - if ('indexSignature' in model && model.indexSignature) { - md.push(heading(options.headingLevel, this.getText('label.indexable'))); - md.push(this.partials.indexSignature(model.indexSignature)); + if (model.indexSignatures?.length) { + md.push(heading(options.headingLevel, this.i18n.theme_indexable())); + model.indexSignatures.forEach((indexSignature) => { + md.push(this.partials.indexSignature(indexSignature)); + }); } - if (model?.groups?.some((group) => group.allChildrenHaveOwnDocument())) { - md.push(heading(options.headingLevel, this.getText('label.index'))); + if ( + model.documents || + model?.groups?.some((group) => group.allChildrenHaveOwnDocument()) + ) { + const isAbsoluteIndex = model?.groups?.every( + (group) => group.owningReflection.kind !== ReflectionKind.Document, + ); + if (isAbsoluteIndex) { + md.push(heading(options.headingLevel, this.i18n.theme_index())); + } + + if (model.documents) { + md.push( + this.partials.documents(model, { + headingLevel: options.headingLevel, + }), + ); + } + md.push( this.partials.reflectionIndex(model, { - headingLevel: options.headingLevel + 1, + headingLevel: isAbsoluteIndex + ? options.headingLevel + 1 + : options.headingLevel, }), ); } diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.parametersTable.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.parametersTable.ts index 4e3c67884..a95870e3f 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.parametersTable.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.parametersTable.ts @@ -45,16 +45,16 @@ export function parametersTable( const hasComments = parsedParams.some((param) => Boolean(param.comment)); const headers = [ - this.getText('kind.parameter.singular'), - this.getText('label.type'), + this.internationalization.kindSingularString(ReflectionKind.Parameter), + this.i18n.theme_type(), ]; if (showDefaults) { - headers.push(this.getText('label.defaultValue')); + headers.push(this.i18n.theme_default_value()); } if (hasComments) { - headers.push(this.getText('label.description')); + headers.push(this.i18n.theme_description()); } const firstOptionalParamIndex = model.findIndex( diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.propertiesTable.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.propertiesTable.ts index 789221769..5a9934065 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.propertiesTable.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.propertiesTable.ts @@ -6,7 +6,7 @@ import { } from '@plugin/libs/markdown'; import { removeLineBreaks } from '@plugin/libs/utils'; import { MarkdownThemeContext } from '@plugin/theme'; -import { DeclarationReflection } from 'typedoc'; +import { DeclarationReflection, ReflectionKind } from 'typedoc'; import { getPropertyDefaultValue } from '../helpers/get-property-default-value'; /** @@ -57,38 +57,38 @@ export function declarationsTable( headers.push( options?.isEventProps - ? this.getText('kind.event.singular') - : this.getText('kind.property.singular'), + ? this.i18n.theme_event() + : this.internationalization.kindSingularString(ReflectionKind.Property), ); if (hasModifiers) { - headers.push(this.getText('label.modifier')); + headers.push(this.i18n.theme_modifier()); } if (hasFlags) { - headers.push(this.getText('label.flags')); + headers.push(this.i18n.theme_flags()); } - headers.push(this.getText('label.type')); + headers.push(this.i18n.theme_type()); if (hasDefaults) { - headers.push(this.getText('label.defaultValue')); + headers.push(this.i18n.theme_default_value()); } if (hasComments) { - headers.push(this.getText('label.description')); + headers.push(this.i18n.theme_description()); } if (hasOverrides) { - headers.push(this.getText('label.overrides')); + headers.push(this.i18n.theme_overrides()); } if (hasInheritance) { - headers.push(this.getText('label.inheritedFrom')); + headers.push(this.i18n.theme_inherited_from()); } if (hasSources) { - headers.push(this.getText('label.source')); + headers.push(this.i18n.theme_defined_in()); } const rows: string[][] = []; diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reference.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reference.ts index ea92ef2b4..6cf92ec83 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reference.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reference.ts @@ -13,8 +13,8 @@ export function referenceMember( ): string { let referenced = model.tryGetTargetReflectionDeep(); - const reExportsText = this.getText('label.reExports'); - const renamesAndReExportsText = this.getText('label.renamesAndReExports'); + const reExportsText = this.i18n.theme_re_exports(); + const renamesAndReExportsText = this.i18n.theme_renames_and_re_exports(); if (!referenced) { return `${reExportsText} ${model.name}`; diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reflectionIndex.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reflectionIndex.ts index f205eba41..1a0db41ed 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reflectionIndex.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.reflectionIndex.ts @@ -1,18 +1,12 @@ -import { heading, link, table } from '@plugin/libs/markdown'; -import { escapeChars } from '@plugin/libs/utils'; -import { PLURAL_KIND_KEY_MAP } from '@plugin/options/text-mappings'; +import { heading } from '@plugin/libs/markdown'; import { MarkdownThemeContext } from '@plugin/theme'; -import { TextContentMappings } from 'public-api'; import { DeclarationReflection, + DocumentReflection, ProjectReflection, - ReflectionCategory, - ReflectionGroup, - ReflectionKind, } from 'typedoc'; /** - * Renders the index section of a reflection. * * @category Member Partials */ @@ -23,26 +17,19 @@ export function reflectionIndex( ): string { const md: string[] = []; - const getGroup = (group: ReflectionGroup | ReflectionCategory) => { - if (this.options.getValue('indexFormat') === 'table') { - return getTable(this, group.children); - } - return getList(this, group.children); - }; - - const subHeadingLevel = options.headingLevel; - if (model.categories) { model.categories.forEach((categoryGroup) => { - md.push(heading(subHeadingLevel, categoryGroup.title) + '\n'); + md.push(heading(options.headingLevel, categoryGroup.title) + '\n'); if (categoryGroup.description) { md.push(this.partials.commentParts(categoryGroup.description) + '\n'); } - md.push(getGroup(categoryGroup) + '\n'); + md.push(this.helpers.getGroupIndex(categoryGroup) + '\n'); }); } else { - const groups = model.groups?.filter((group) => - group.allChildrenHaveOwnDocument(), + const groups = model.groups?.filter( + (group) => + group.allChildrenHaveOwnDocument() && + !(group.owningReflection instanceof DocumentReflection), ); if (this.options.getValue('excludeGroups')) { @@ -50,100 +37,42 @@ export function reflectionIndex( return [...acc, ...group.children]; }, []); if (this.options.getValue('indexFormat') === 'table') { - md.push(getTable(this, children || [])); + md.push( + heading(options.headingLevel, this.i18n.theme_member_plural()) + '\n', + ); + md.push( + this.helpers.getGroupIndexTable( + (children as DeclarationReflection[]) || [], + ), + ); } else { - md.push(getList(this, children || [])); + md.push( + this.helpers.getGroupIndexList( + (children as DeclarationReflection[]) || [], + ), + ); } } else { groups?.forEach((reflectionGroup) => { if (reflectionGroup.categories) { - md.push(heading(subHeadingLevel, reflectionGroup.title) + '\n'); + md.push(heading(options.headingLevel, reflectionGroup.title) + '\n'); reflectionGroup.categories.forEach((categoryGroup) => { - md.push(heading(subHeadingLevel + 1, categoryGroup.title) + '\n'); + md.push( + heading(options.headingLevel + 1, categoryGroup.title) + '\n', + ); if (categoryGroup.description) { md.push( this.partials.commentParts(categoryGroup.description) + '\n', ); } - md.push(getGroup(categoryGroup) + '\n'); + md.push(this.helpers.getGroupIndex(categoryGroup) + '\n'); }); } else { - const kindKey = PLURAL_KIND_KEY_MAP[ - reflectionGroup.title - ] as keyof TextContentMappings; - md.push( - heading( - subHeadingLevel, - this.getText(kindKey) || reflectionGroup.title, - ) + '\n', - ); - md.push(getGroup(reflectionGroup) + '\n'); + md.push(heading(options.headingLevel, reflectionGroup.title) + '\n'); + md.push(this.helpers.getGroupIndex(reflectionGroup) + '\n'); } }); } } return md.join('\n'); } - -function getTable( - context: MarkdownThemeContext, - children: DeclarationReflection[], -) { - const tableColumnsOptions = context.options.getValue('tableColumns'); - - const headers = [ - context.options.getValue('excludeGroups') - ? context.getText('label.member') - : ReflectionKind.singularString(children[0].kind), - context.getText('label.description'), - ]; - - const rows: string[][] = []; - - children.forEach((child) => { - const row: string[] = []; - - if (child.url) { - row.push( - link(escapeChars(child.name), context.getRelativeUrl(child.url)), - ); - } - - const comment = context.helpers.getDeclarationComment(child); - - if (comment?.summary?.length) { - row.push( - context.partials - .commentParts(comment.summary) - ?.split('\n\n')[0] - .replace(/\n/g, ' '), - ); - } else { - row.push('-'); - } - rows.push(row); - }); - return table(headers, rows, tableColumnsOptions.leftAlignHeadings); -} - -function getList( - context: MarkdownThemeContext, - children: DeclarationReflection[], -) { - const filteredChildren = children - .filter((child) => Boolean(child.url)) - .map((child) => { - const name = - child.name === 'constructor' - ? `${ - child.signatures - ? child.signatures[0].name - : context.getText('kind.constructor.singular') - }` - : child.name; - return child.url - ? `- ${link(escapeChars(name), context.getRelativeUrl(child.url))}` - : ''; - }); - return filteredChildren.join('\n'); -} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signature.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signature.ts index 0164bb201..7f463b572 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signature.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signature.ts @@ -14,6 +14,7 @@ export function signature( headingLevel: number; nested?: boolean; accessor?: string; + multipleSignatures?: boolean; }, ): string { const md: string[] = []; @@ -28,25 +29,38 @@ export function signature( ); } - if (model.comment) { + const modelComments = model.comment || model.parent?.comment; + + if (modelComments) { md.push( - this.partials.comment(model.comment, { + this.partials.comment(modelComments, { headingLevel: options.headingLevel, showTags: false, }), ); } + if (!options.multipleSignatures && model.parent?.documents) { + md.push( + this.partials.documents(model?.parent, { + headingLevel: options.headingLevel, + }), + ); + } + if ( model.typeParameters?.length && model.kind !== ReflectionKind.ConstructorSignature ) { md.push( - heading(options.headingLevel, this.getText('kind.typeParameter.plural')), + heading( + options.headingLevel, + this.internationalization.kindPluralString( + ReflectionKind.TypeParameter, + ), + ), ); - if ( - this.options.getValue('parametersFormat').toLowerCase().includes('table') - ) { + if (this.options.getValue('parametersFormat') === 'table') { md.push(this.partials.typeParametersTable(model.typeParameters)); } else { md.push(this.partials.typeParametersList(model.typeParameters)); @@ -55,11 +69,12 @@ export function signature( if (model.parameters?.length) { md.push( - heading(options.headingLevel, this.getText('kind.parameter.plural')), + heading( + options.headingLevel, + this.internationalization.kindPluralString(ReflectionKind.Parameter), + ), ); - if ( - this.options.getValue('parametersFormat').toLowerCase().includes('table') - ) { + if (this.options.getValue('parametersFormat') === 'table') { md.push(this.partials.parametersTable(model.parameters)); } else { md.push(this.partials.parametersList(model.parameters)); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatureReturns.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatureReturns.ts index ff0ae5679..ff262ffbd 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatureReturns.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatureReturns.ts @@ -20,7 +20,7 @@ export function signatureReturns( const typeDeclaration = (model.type as any) ?.declaration as DeclarationReflection; - md.push(heading(options.headingLevel, this.getText('label.returns'))); + md.push(heading(options.headingLevel, this.i18n.theme_returns())); if (typeDeclaration?.signatures) { md.push(backTicks('Function')); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatures.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatures.ts new file mode 100644 index 000000000..1f6688917 --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.signatures.ts @@ -0,0 +1,62 @@ +import { heading } from '@plugin/libs/markdown'; +import { escapeChars } from '@plugin/libs/utils'; +import { MarkdownThemeContext } from '@plugin/theme'; +import { DeclarationReflection } from 'typedoc'; + +/** + * Renders a signature collection. + * + * @category Member Partials + */ +export function signatures( + this: MarkdownThemeContext, + model: DeclarationReflection, + options: { + headingLevel: number; + nested?: boolean; + }, +): string { + const md: string[] = []; + + const multipleSignatures = model.signatures && model.signatures?.length > 1; + + if (model.comment && multipleSignatures) { + md.push( + this.partials.comment(model.comment, { + headingLevel: options.headingLevel + 1, + }), + ); + } + + if (multipleSignatures && model.documents) { + md.push( + this.partials.documents(model, { + headingLevel: options.headingLevel + 1, + }), + ); + } + + model.signatures?.forEach((signature) => { + if (multipleSignatures) { + md.push( + heading( + options.headingLevel + 1, + `${escapeChars(signature.name)}(${signature.parameters + ?.map((param) => param.name) + .join(', ')})`, + ), + ); + } + md.push( + this.partials.signature(signature, { + headingLevel: multipleSignatures + ? options.headingLevel + 2 + : options.headingLevel + 1, + nested: options.nested, + multipleSignatures, + }), + ); + }); + + return md.join('\n\n'); +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.sources.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.sources.ts index ca6919341..0fb3249ee 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.sources.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.sources.ts @@ -14,7 +14,7 @@ export function sources( const md: string[] = []; if (options.headingLevel !== -1) { - md.push(heading(options.headingLevel, this.getText('label.source'))); + md.push(heading(options.headingLevel, this.i18n.theme_source())); } model.sources?.forEach((source, index) => { if (index === 0) { diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.ts index 2f13f44ec..14ede8127 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.ts @@ -1,5 +1,3 @@ -import { heading } from '@plugin/libs/markdown'; -import { escapeChars } from '@plugin/libs/utils'; import { MarkdownThemeContext } from '@plugin/theme'; import { DeclarationReflection, @@ -15,86 +13,43 @@ export function member( model: DeclarationReflection, options: { headingLevel: number; nested?: boolean }, ): string { - const md: string[] = []; - - if (this.options.getValue('useHTMLAnchors')) { - md.push(``); + if ( + [ + ReflectionKind.Class, + ReflectionKind.Interface, + ReflectionKind.Enum, + ].includes(model.kind) + ) { + return this.partials.memberWithGroups(model, { + headingLevel: options.headingLevel + 1, + }); } - if (!model.hasOwnDocument && !(model.kind === ReflectionKind.Constructor)) { - md.push(heading(options.headingLevel, this.partials.memberTitle(model))); + if (model.kind === ReflectionKind.Constructor) { + return this.partials.constructor(model, { + headingLevel: options.headingLevel, + }); } - const getMember = (reflection: DeclarationReflection) => { - if ( - [ - ReflectionKind.Class, - ReflectionKind.Interface, - ReflectionKind.Enum, - ].includes(reflection.kind) - ) { - return this.partials.memberWithGroups(reflection, { - headingLevel: options.headingLevel + 1, - }); - } - - if (reflection.kind === ReflectionKind.Constructor) { - return this.partials.constructor(reflection, { - headingLevel: options.headingLevel, - }); - } - - if (reflection.kind === ReflectionKind.Accessor) { - return this.partials.accessor(reflection, { - headingLevel: options.headingLevel + 1, - }); - } - - if (reflection.signatures) { - return reflection.signatures - ?.map((signature) => { - const signatureMd: string[] = []; - const multipleSignatures = - reflection.signatures && reflection.signatures?.length > 1; - - if (multipleSignatures) { - signatureMd.push( - heading( - options.headingLevel + 1, - `${escapeChars(signature.name)}(${signature.parameters - ?.map((param) => param.name) - .join(', ')})`, - ), - ); - } - signatureMd.push( - this.partials.signature(signature, { - headingLevel: multipleSignatures - ? options.headingLevel + 2 - : options.headingLevel + 1, - nested: options.nested, - }), - ); - return signatureMd.join('\n\n'); - }) - .join('\n\n'); - } - - if (reflection instanceof ReferenceReflection) { - return this.partials.referenceMember(reflection); - } - - return this.partials.declaration(reflection, { + if (model.kind === ReflectionKind.Accessor) { + return this.partials.accessor(model, { headingLevel: options.headingLevel + 1, - nested: options.nested, }); - }; + } - const member = getMember(model); + if (model.signatures) { + return this.partials.signatures(model, { + headingLevel: options.headingLevel, + nested: options.nested, + }); + } - if (member) { - md.push(member); + if (model instanceof ReferenceReflection) { + return this.partials.referenceMember(model); } - return md.join('\n\n'); + return this.partials.declaration(model, { + headingLevel: options.headingLevel + 1, + nested: options.nested, + }); } diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationList.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationList.ts index 5299bdf01..ebf3fe845 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationList.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationList.ts @@ -13,7 +13,7 @@ export function typeDeclarationList( const declarations = this.helpers.getFlattenedDeclarations(model); declarations?.forEach((declaration: DeclarationReflection) => { md.push( - this.partials.member(declaration, { + this.partials.memberContainer(declaration, { headingLevel: headingLevel + 1, nested: true, }), diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationTable.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationTable.ts index 9c374dfed..7bd12710e 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationTable.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeDeclarationTable.ts @@ -26,16 +26,16 @@ export function typeDeclarationTable( Boolean(declaration.defaultValue), ); - headers.push(this.getText('label.member')); + headers.push(this.i18n.theme_member()); - headers.push(this.getText('label.type')); + headers.push(this.i18n.theme_type()); if (hasDefaultValues) { - headers.push(this.getText('label.value')); + headers.push(this.i18n.theme_value()); } if (hasComments) { - headers.push(this.getText('label.description')); + headers.push(this.i18n.theme_description()); } const rows: string[][] = []; diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeParametersTable.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeParametersTable.ts index 65a71eb75..0638f4d93 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeParametersTable.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/member.typeParametersTable.ts @@ -1,6 +1,6 @@ import { backTicks, htmlTable, italic, table } from '@plugin/libs/markdown'; import { MarkdownThemeContext } from '@plugin/theme'; -import { TypeParameterReflection } from 'typedoc'; +import { ReflectionKind, TypeParameterReflection } from 'typedoc'; /** * @category Member Partials @@ -19,16 +19,17 @@ export function typeParametersTable( Boolean(typeParameter.comment), ); - const headers = [this.getText('kind.typeParameter.singular')]; + const headers = [ + this.internationalization.kindSingularString(ReflectionKind.TypeParameter), + ]; if (hasDefault) { - headers.push(this.getText('label.value')); + headers.push(this.i18n.theme_value()); } if (hasComments) { - headers.push(this.getText('label.description')); + headers.push(this.i18n.theme_description()); } - const rows: string[][] = []; model?.forEach((typeParameter) => { const row: string[] = []; diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.breadcrumbs.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.breadcrumbs.ts index ea7d7565b..8ab3cc779 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.breadcrumbs.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.breadcrumbs.ts @@ -23,9 +23,8 @@ export function breadcrumbs(this: MarkdownThemeContext): string { const name = this.page.project.name; const version = this.page.project.packageVersion; - const homeLabel = this.getText('breadcrumbs.home') - .replace('{projectName}', name) - .replace('{version}', version ? `v${version}` : '') + const homeLabel = this.i18n + .theme_breadcrumbs_home(name, version ? `v${version}` : '') .replace(/\s+/g, ' ') .trim(); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.footer.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.footer.ts index 1bf38cff5..796b70c49 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.footer.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.footer.ts @@ -4,6 +4,6 @@ import { MarkdownThemeContext } from '@plugin/theme'; * @category Page Partials */ export function footer(this: MarkdownThemeContext): string { - const text = this.getText('footer.text'); + const text = this.i18n.theme_footer_text(); return text ? `***\n\n${text}` : ``; } diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts index 36ea1d77c..a1e761d8f 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts @@ -34,13 +34,12 @@ export function header(this: MarkdownThemeContext): string { const name = this.page.project.name; const version = this.page.project.packageVersion; - const title = this.getText('header.title') - .replace('{projectName}', name) - .replace('{version}', version ? `v${version}` : '') + const title = this.i18n + .theme_header_title(name, version ? `v${version}` : '') .replace(/\s+/g, ' ') .trim(); - const indexLabel = this.getText('header.docs'); + const indexLabel = this.i18n.theme_header_docs(); if (this.page.url === entryFileName) { md.push(bold(title)); @@ -93,7 +92,7 @@ export function header(this: MarkdownThemeContext): string { const md: string[] = []; - const indexLabel = this.getText('header.docs'); + const indexLabel = this.i18n.theme_header_docs(); const ignoreScopes = this.options.getValue('excludeScopesInPaths'); const fileExtension = this.options.getValue('fileExtension'); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.packagesIndex.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.packagesIndex.ts index 16d6079a4..52fce11f0 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.packagesIndex.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.packagesIndex.ts @@ -15,7 +15,7 @@ export function packagesIndex( const md: string[] = []; - md.push(heading(2, this.getText('label.packages'))); + md.push(heading(2, this.i18n.theme_packages())); const includeVersion = model.children?.some((projectPackage) => Boolean(projectPackage.packageVersion), @@ -29,11 +29,11 @@ export function packagesIndex( ); if (this.options.getValue('indexFormat') === 'table') { - const headers = [this.getText('label.name')]; + const headers = [this.i18n.theme_name()]; if (includeVersion) { - headers.push('Version'); + headers.push(this.i18n.theme_version()); } - headers.push('Description'); + headers.push(this.i18n.theme_description()); const packageRows = model.children?.map((projectPackage) => { const packageMeta = this.getPackageMetaData(projectPackage.name); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.pageTitle.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.pageTitle.ts index 00a8241ee..50ab4c7c6 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.pageTitle.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.pageTitle.ts @@ -1,6 +1,5 @@ -import { SINGULAR_KIND_KEY_MAP } from '@plugin/options/text-mappings'; import { DeclarationReflection, ReflectionKind } from 'typedoc'; -import { MarkdownThemeContext, TextContentMappings } from '../../..'; +import { MarkdownThemeContext } from '../../..'; /** * @category Page Partials @@ -8,28 +7,19 @@ import { MarkdownThemeContext, TextContentMappings } from '../../..'; export function pageTitle(this: MarkdownThemeContext): string { const page = this.page; if (page.model?.url === page.project.url) { - const titleContent = this.getText('title.indexPage'); - return titleContent - .replace('{projectName}', page.project.name) - .replace( - '{version}', - page.project.packageVersion ? `v${page.project.packageVersion}` : '', - ) - .replace(/\s+/g, ' ') - .trim(); + const titleContent = this.i18n.theme_title_index_page( + page.project.name, + page.project.packageVersion ? `v${page.project.packageVersion}` : '', + ); + return titleContent.replace(/\s+/g, ' ').trim(); } const name = this.partials.memberTitle(page.model as DeclarationReflection); + const moduleTitle = this.i18n.theme_title_module_page(name); + const memberTitle = this.i18n.theme_title_member_page( + this.internationalization.kindSingularString(page.model.kind), + name, + ); - const textContent = - page.model.kind === ReflectionKind.Module - ? this.getText('title.modulePage') - : this.getText('title.memberPage'); - - const kindKey = SINGULAR_KIND_KEY_MAP[ - ReflectionKind.singularString(page.model.kind) - ] as keyof TextContentMappings; - return textContent - .replace('{name}', name) - .replace('{kind}', this.getText(kindKey)); + return page.model.kind === ReflectionKind.Module ? moduleTitle : memberTitle; } diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reflection.declaration.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reflection.declaration.ts index 8ede9b0bd..d9ff1b694 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reflection.declaration.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reflection.declaration.ts @@ -11,19 +11,19 @@ export function declarationType( ): string { const shouldFormat = this.options.getValue('useCodeBlocks'); - if (model.indexSignature || model.children) { - let indexSignature = ''; - const declarationIndexSignature = model.indexSignature; - if (declarationIndexSignature) { - const key = declarationIndexSignature.parameters - ? declarationIndexSignature.parameters.map( - (param) => `\`[${param.name}: ${param.type}]\``, - ) - : ''; - const obj = this.partials.someType( - declarationIndexSignature.type as SomeType, - ); - indexSignature = `${key}: ${obj}; `; + if (model.indexSignatures || model.children) { + const indexSignatureMd: string[] = []; + + if (model.indexSignatures?.length) { + model.indexSignatures.forEach((indexSignature) => { + const key = indexSignature.parameters + ? indexSignature.parameters.map( + (param) => `\`[${param.name}: ${param.type}]\``, + ) + : ''; + const obj = this.partials.someType(indexSignature.type as SomeType); + indexSignatureMd.push(`${key}: ${obj}; `); + }); } const children = model.children; @@ -56,8 +56,10 @@ export function declarationType( return `${name.join(' ')}: ${indentBlock(typeString, true)};`; }); - if (indexSignature) { - types?.unshift(indexSignature); + if (indexSignatureMd) { + indexSignatureMd.forEach((indexSignature) => { + types?.unshift(indexSignature); + }); } return types ? `\\{${shouldFormat ? '\n' : ''}${types.join('')} \\}` diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/templates/document.ts b/packages/typedoc-plugin-markdown/src/theme/resources/templates/document.ts new file mode 100644 index 000000000..1cfbe5982 --- /dev/null +++ b/packages/typedoc-plugin-markdown/src/theme/resources/templates/document.ts @@ -0,0 +1,27 @@ +import { MarkdownPageEvent } from '@plugin/app/events'; +import { MarkdownThemeContext } from '@plugin/theme'; +import { DocumentReflection } from 'typedoc'; + +/** + * Template that maps to a project document. + */ +export function document( + this: MarkdownThemeContext, + page: MarkdownPageEvent, +) { + const md: string[] = []; + + if (!this.options.getValue('hidePageHeader')) { + md.push(this.partials.header()); + } + + if (!this.options.getValue('hideBreadcrumbs')) { + md.push(this.partials.breadcrumbs()); + } + + md.push(this.partials.commentParts(page.model.content)); + + md.push(this.partials.footer()); + + return md.join('\n\n'); +} diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/templates/project.ts b/packages/typedoc-plugin-markdown/src/theme/resources/templates/project.ts index 43f2ec6e9..51ee4efd0 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/templates/project.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/templates/project.ts @@ -1,3 +1,4 @@ +import { MarkdownPageEvent } from '@plugin/app/events'; import { heading } from '@plugin/libs/markdown'; import { MarkdownThemeContext } from '@plugin/theme'; import { EntryPointStrategy, ProjectReflection } from 'typedoc'; @@ -5,11 +6,12 @@ import { EntryPointStrategy, ProjectReflection } from 'typedoc'; /** * Template that maps to the root project reflection. This will be the index page / documentation root page. */ -export function project(this: MarkdownThemeContext) { +export function project( + this: MarkdownThemeContext, + page: MarkdownPageEvent, +) { const md: string[] = []; - const model = this.page.model as ProjectReflection; - md.push(this.hook('index.page.begin').join('\n')); if (!this.options.getValue('hidePageHeader')) { @@ -21,10 +23,10 @@ export function project(this: MarkdownThemeContext) { } const includeReadme = - this.options.getValue('mergeReadme') && Boolean(model.readme); + this.options.getValue('mergeReadme') && Boolean(page.model.readme); - if (includeReadme && model.readme) { - md.push(this.partials.commentParts(model.readme)); + if (includeReadme && page.model.readme) { + md.push(this.partials.commentParts(page.model.readme)); } if (!this.options.getValue('hidePageTitle') && !includeReadme) { @@ -33,16 +35,21 @@ export function project(this: MarkdownThemeContext) { md.push(this.hook('content.begin').join('\n')); - if (model.comment) { - md.push(this.partials.comment(model.comment, { headingLevel: 2 })); + if (page.model.comment) { + md.push(this.partials.comment(page.model.comment, { headingLevel: 2 })); } - if (model?.groups?.some((group) => group.allChildrenHaveOwnDocument())) { + if (page.model?.groups?.some((group) => group.allChildrenHaveOwnDocument())) { if (includeReadme) { - md.push(heading(2, this.getText('label.apiIndex'))); + md.push(heading(2, this.i18n.theme_api_index())); } md.push( - this.partials.reflectionIndex(model, { + this.partials.documents(page.model, { + headingLevel: includeReadme ? 3 : 2, + }), + ); + md.push( + this.partials.reflectionIndex(page.model, { headingLevel: includeReadme ? 3 : 2, }), ); @@ -52,10 +59,10 @@ export function project(this: MarkdownThemeContext) { this.page.project.url === this.page.url && this.options.getValue('entryPointStrategy') === EntryPointStrategy.Packages; - if (isPackages && model.children?.length) { - md.push(this.partials.packagesIndex(model)); + if (isPackages && page.model.children?.length) { + md.push(this.partials.packagesIndex(page.model)); } else { - md.push(this.partials.body(model, { headingLevel: 2 })); + md.push(this.partials.body(page.model, { headingLevel: 2 })); } md.push(this.partials.footer()); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/templates/read-me.ts b/packages/typedoc-plugin-markdown/src/theme/resources/templates/read-me.ts index 0f1813449..7d2d2e844 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/templates/read-me.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/templates/read-me.ts @@ -1,14 +1,16 @@ +import { MarkdownPageEvent } from '@plugin/app/events'; import { MarkdownThemeContext } from '@plugin/theme'; import { CommentDisplayPart, ProjectReflection } from 'typedoc'; /** * Template that specifically maps to the resolved readme file. This template is not used when 'readme' is set to 'none'. */ -export function readme(this: MarkdownThemeContext) { +export function readme( + this: MarkdownThemeContext, + page: MarkdownPageEvent, +) { const md: string[] = []; - const model = this.page.model as ProjectReflection; - if (!this.options.getValue('hidePageHeader')) { md.push(this.partials.header()); } @@ -17,8 +19,10 @@ export function readme(this: MarkdownThemeContext) { md.push(this.partials.breadcrumbs()); } - if (Boolean(model.readme)) { - md.push(this.partials.commentParts(model.readme as CommentDisplayPart[])); + if (Boolean(page.model.readme)) { + md.push( + this.partials.commentParts(page.model.readme as CommentDisplayPart[]), + ); } md.push(this.partials.footer()); diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/templates/reflection.ts b/packages/typedoc-plugin-markdown/src/theme/resources/templates/reflection.ts index 4d5462744..a113533bb 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/templates/reflection.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/templates/reflection.ts @@ -1,3 +1,4 @@ +import { MarkdownPageEvent } from '@plugin/app/events'; import { heading } from '@plugin/libs/markdown'; import { MarkdownThemeContext } from '@plugin/theme'; import { DeclarationReflection, ReflectionKind } from 'typedoc'; @@ -5,11 +6,12 @@ import { DeclarationReflection, ReflectionKind } from 'typedoc'; /** * Template that maps to individual reflection models. */ -export function reflection(this: MarkdownThemeContext) { +export function reflection( + this: MarkdownThemeContext, + page: MarkdownPageEvent, +) { const md: string[] = []; - const model = this.page.model as DeclarationReflection; - md.push(this.hook('page.begin').join('\n')); if (!this.options.getValue('hidePageHeader')) { @@ -33,11 +35,11 @@ export function reflection(this: MarkdownThemeContext) { ReflectionKind.Enum, ReflectionKind.Class, ReflectionKind.Interface, - ].includes(model.kind) + ].includes(page.model.kind) ) { - md.push(this.partials.memberWithGroups(model, { headingLevel: 2 })); + md.push(this.partials.memberWithGroups(page.model, { headingLevel: 2 })); } else { - md.push(this.partials.member(model, { headingLevel: 1 })); + md.push(this.partials.memberContainer(page.model, { headingLevel: 1 })); } md.push(this.partials.footer()); diff --git a/packages/typedoc-plugin-markdown/test/fixtures/PROJECT_DOC_1.md b/packages/typedoc-plugin-markdown/test/fixtures/PROJECT_DOC_1.md new file mode 100644 index 000000000..5a3c556b5 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/PROJECT_DOC_1.md @@ -0,0 +1,8 @@ +--- +title: 'Project Document 1' +description: 'A description of the document' +--- + +## Project Document 1 + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/config.ts b/packages/typedoc-plugin-markdown/test/fixtures/config.ts index 27dd94bdb..b244ed018 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/config.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/config.ts @@ -129,8 +129,8 @@ const config: Record = { hideBreadcrumbs: true, readme: 'none', disableSources: true, - media: './test/fixtures/media', - includes: './test/fixtures/inc', + inlineDocuments: true, + //media: './test/fixtures/media', }, options: [ { @@ -263,6 +263,58 @@ const config: Record = { }, ], }, + documents: { + only: false, + entryPoints: ['/documents/module-1.ts', '/documents/module-2.ts'], + commonOptions: { + hidePageHeader: true, + plugin: [ + path.join(__dirname, 'custom-plugins', 'stub-documents-theme.mjs'), + path.join(__dirname, 'custom-plugins', 'navigation-plugin.mjs'), + ], + theme: 'stub-documents', + readme: 'none', + disableSources: true, + projectDocuments: [ + './test/fixtures/PROJECT_DOC_1.md', + './test/fixtures/docs/project/PROJECT_DOC_2.md', + './test/fixtures/docs/project/PROJECT_DOC_3.md', + ], + }, + options: [ + {}, + { + indexFormat: 'table', + flattenOutputFiles: true, + }, + ], + }, + documentsSingleModule: { + only: false, + entryPoints: ['/documents/module-1.ts'], + commonOptions: { + hidePageHeader: true, + plugin: [ + path.join(__dirname, 'custom-plugins', 'stub-documents-theme.mjs'), + path.join(__dirname, 'custom-plugins', 'navigation-plugin.mjs'), + ], + theme: 'stub-documents', + readme: 'none', + disableSources: true, + projectDocuments: [ + './test/fixtures/PROJECT_DOC_1.md', + './test/fixtures/docs/project/PROJECT_DOC_2.md', + './test/fixtures/docs/project/PROJECT_DOC_3.md', + ], + }, + options: [ + {}, + { + indexFormat: 'table', + inlineDocuments: true, + }, + ], + }, }; export default config; diff --git a/packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/stub-documents-theme.mjs b/packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/stub-documents-theme.mjs new file mode 100644 index 000000000..3d3ff3462 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/stub-documents-theme.mjs @@ -0,0 +1,42 @@ +// @ts-check +import { MarkdownTheme, MarkdownThemeContext } from 'typedoc-plugin-markdown'; + +/** + * @param {import('typedoc-plugin-markdown').MarkdownApplication} app + */ +export function load(app) { + app.renderer.defineTheme('stub-documents', StubTheme); +} + +class StubTheme extends MarkdownTheme { + /** + * @param {import('typedoc-plugin-markdown').MarkdownPageEvent} page + */ + getRenderContext(page) { + return new MyMarkdownThemeContext(this, page, this.application.options); + } +} + +class MyMarkdownThemeContext extends MarkdownThemeContext { + partials = { + ...this.partials, + constructor: () => { + return `_CONSTRUCTOR_MEMBER_PARTIAL_`; + }, + declarationTitle: () => { + return `_DECLARATION_TITLE_PARTIAL_`; + }, + parametersList: () => { + return `_PARAMETERS_LIST_PARTIAL_`; + }, + signatureReturns: () => { + return `_SIGNATURE_RETURNS_PARTIAL_`; + }, + signatureTitle: () => { + return `_SIGNATURE_TITLE_PARTIAL_`; + }, + typeDeclaration: () => { + return `_TYPE_DECLARATION_PARTIAL_`; + }, + }; +} diff --git a/packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/urls-plugin.mjs b/packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/urls-plugin.mjs new file mode 100644 index 000000000..ff734253c --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/custom-plugins/urls-plugin.mjs @@ -0,0 +1,19 @@ +// @ts-check + +import * as fs from 'fs'; + +/** + * @param {import('typedoc-plugin-markdown').MarkdownApplication} app + */ +export function load(app) { + app.renderer.postRenderAsyncJobs.push(async (output) => { + fs.writeFileSync( + `${output.outputDirectory}/urls.json`, + JSON.stringify( + output.urls.map((url) => url.url), + null, + 2, + ), + ); + }); +} diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_2.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_2.md new file mode 100644 index 000000000..59d102bb8 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_2.md @@ -0,0 +1,3 @@ +## Project Document 2 + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_3.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_3.md new file mode 100644 index 000000000..666b46995 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/project/PROJECT_DOC_3.md @@ -0,0 +1,3 @@ +## Project Document 3 + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/CLASS_DOC.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/CLASS_DOC.md new file mode 100644 index 000000000..d6e3ef1eb --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/CLASS_DOC.md @@ -0,0 +1,3 @@ +> Class Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/ENUM_DOC.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/ENUM_DOC.md new file mode 100644 index 000000000..ef7aca49e --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/ENUM_DOC.md @@ -0,0 +1,3 @@ +> Enum Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_1.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_1.md new file mode 100644 index 000000000..df8d52fc8 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_1.md @@ -0,0 +1,3 @@ +> Function Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_2.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_2.md new file mode 100644 index 000000000..df8d52fc8 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_2.md @@ -0,0 +1,3 @@ +> Function Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_3.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_3.md new file mode 100644 index 000000000..df8d52fc8 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/FUNCTION_DOC_3.md @@ -0,0 +1,3 @@ +> Function Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/INTERFACE_DOC.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/INTERFACE_DOC.md new file mode 100644 index 000000000..7dc30c384 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/INTERFACE_DOC.md @@ -0,0 +1,3 @@ +> Interface Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/MODULE_DOC.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/MODULE_DOC.md new file mode 100644 index 000000000..21c632c9e --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/MODULE_DOC.md @@ -0,0 +1,3 @@ +> Module Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/NAMESPACE_DOC.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/NAMESPACE_DOC.md new file mode 100644 index 000000000..239ddb8b8 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/NAMESPACE_DOC.md @@ -0,0 +1,3 @@ +> Namespace Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/TYPE_DOC.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/TYPE_DOC.md new file mode 100644 index 000000000..6ed74e3d3 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/TYPE_DOC.md @@ -0,0 +1,3 @@ +> Type Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/VARIABLE_DOC.md b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/VARIABLE_DOC.md new file mode 100644 index 000000000..d42420cd7 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/docs/reflection/VARIABLE_DOC.md @@ -0,0 +1,3 @@ +> Variable Documentation + +Document content diff --git a/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts b/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts index 03cdfda56..5c721147c 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts @@ -2,7 +2,7 @@ * * Comments form module comments * - * @links + * > links * * Links using `{@link}` inline tags. * @@ -23,11 +23,11 @@ * * @module * - * @tagA + * @see * * Comments for a tag * - * @tagB Comments for tag written on same line + * @see Comments for tag written on same line * * ## Html And Jsx * @@ -47,7 +47,8 @@ * A in a code block * Some

html

inside codeblock * ``` - * @media + * + * > media * * You can include media in doc comments: * @@ -55,9 +56,7 @@ * * And include other files: * - * [[include:example.md]] [[include:not-found.md]] - * - * @codeBlocks + * > codeBlocks * * ```css * .class {color:red} @@ -68,6 +67,8 @@ * ``` * * `single line {block}` + * + * @document ../../inc/example.md */ export interface CommentInterface { @@ -165,7 +166,7 @@ export class ClassPropertiesTable extends BaseClassProperties { */ readonly prop2: RegExp; /** - * ### Example of Triple Code Block + * > Example of Triple Code Block * * ```python * def greet(name): @@ -198,7 +199,7 @@ export interface InterfacePropertiesTable extends BaseInterfaceProperties { */ prop2: RegExp; /** - * ### Example of Triple Code Block + * > Example of Triple Code Block * * ```python * def greet(name): diff --git a/packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-1.ts b/packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-1.ts new file mode 100644 index 000000000..61d529607 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-1.ts @@ -0,0 +1,77 @@ +/* eslint-disable @typescript-eslint/no-namespace */ +/** + * @document ../../docs/reflection/MODULE_DOC.md + * + * @module ModuleWithDocuments1 + */ + +/** + * @document ../../docs/reflection/INTERFACE_DOC.md + */ +export interface InterfaceWithDocuments { + prop: string; +} + +/** + * @document ../../docs/reflection/ENUM_DOC.md + */ +export enum EnumWithDocuments { + EnumMember, +} + +/** + * Comments for multipleFunctionWithDocumentsA + * + * @document ../../docs/reflection/FUNCTION_DOC_1.md + */ +export function multipleFunctionWithDocuments(value: boolean): string; + +/** + * Comments for multipleFunctionWithDocumentsB + * + * @document ../../docs/reflection/FUNCTION_DOC_2.md + */ +export function multipleFunctionWithDocuments(value: string): string; + +/** + * Comments for multipleFunctionWithDocuments + * + * @document ../../docs/reflection/FUNCTION_DOC_3.md + */ +export function multipleFunctionWithDocuments() { + return ''; +} + +/** + * Comments for functionWithDocuments + * + * @document ../../docs/reflection/FUNCTION_DOC_1.md + */ +export function functionWithDocuments() { + return ''; +} + +/** + * @document ../../docs/reflection/CLASS_DOC.md + */ +export class ClassWithDocuments {} + +/** + * @document ../../docs/reflection/VARIABLE_DOC.md + */ +export const variableWithDocuments = 1; + +/** + * @document ../../docs/reflection/TYPE_DOC.md + */ +export type TypeWithDocuments = 'string'; + +/** + * @document ../../docs/reflection/NAMESPACE_DOC.md + */ +export namespace NamespaceWithDocuments { + /** + * @document ../../docs/reflection/CLASS_DOC.md + */ + export class NamespaceClassWithDocuments {} +} diff --git a/packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-2.ts b/packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-2.ts new file mode 100644 index 000000000..18f0f551f --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/src/documents/module-2.ts @@ -0,0 +1,66 @@ +/** + * @document ../../docs/reflection/MODULE_DOC.md + * + * @module ModuleWithDocuments2 + */ + +/** + * @document ../../docs/reflection/INTERFACE_DOC.md + */ +export interface InterfaceWithDocuments { + prop: string; +} + +/** + * @document ../../docs/reflection/ENUM_DOC.md + */ +export enum EnumWithDocuments { + EnumMember, +} + +/** + * Comments for multipleFunctionWithDocumentsA + * + * @document ../../docs/reflection/FUNCTION_DOC_1.md + */ +export function multipleFunctionWithDocuments(value: boolean): string; + +/** + * Comments for multipleFunctionWithDocumentsB + * + * @document ../../docs/reflection/FUNCTION_DOC_2.md + */ +export function multipleFunctionWithDocuments(value: string): string; + +/** + * Comments for multipleFunctionWithDocuments + * + * @document ../../docs/reflection/FUNCTION_DOC_3.md + */ +export function multipleFunctionWithDocuments() { + return ''; +} + +/** + * Comments for functionWithDocuments + * + * @document ../../docs/reflection/FUNCTION_DOC_1.md + */ +export function functionWithDocuments() { + return ''; +} + +/** + * @document ../../docs/reflection/CLASS_DOC.md + */ +export class ClassWithDocuments {} + +/** + * @document ../../docs/reflection/VARIABLE_DOC.md + */ +export const variableWithDocuments = 1; + +/** + * @document ../../docs/reflection/TYPE_DOC.md + */ +export type TypeWithDocuments = 'string'; diff --git a/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/classes.ts b/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/classes.ts index fe4468fe1..dcffaec4c 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/classes.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/classes.ts @@ -41,8 +41,6 @@ export class ClassWithSimpleProps { propC: string; /** * Comments for propE - * - * @tag SomeTag */ propD: string; } @@ -168,8 +166,6 @@ export class ClassWithAccessors { /** * Comments for ClassWithModifiers - * - * @Modifiers */ export abstract class ClassWithModifiers { /** diff --git a/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/functions.ts b/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/functions.ts index 0f484fb28..f8dced552 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/functions.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/functions.ts @@ -120,8 +120,7 @@ export function functionWithMultipleSignatures(value: string): string; export function functionWithMultipleSignatures(value: { name: string }): string; /** - * This is the actual implementation, this comment will not be visible in the generated documentation. - * + * Main function comment. */ export function functionWithMultipleSignatures(): string { return ''; diff --git a/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/interfaces.ts b/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/interfaces.ts index 3d43fa8c7..cc15fc2ea 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/interfaces.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/src/reflections/interfaces.ts @@ -18,7 +18,7 @@ export interface BasicInterface { * * This prop is deprecated * - * @someTag + * @see * * Comments for some tag */ diff --git a/packages/typedoc-plugin-markdown/test/fixtures/typedoc-documents.json b/packages/typedoc-plugin-markdown/test/fixtures/typedoc-documents.json new file mode 100644 index 000000000..7e2d84b6f --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/fixtures/typedoc-documents.json @@ -0,0 +1,775 @@ +{ + "id": 0, + "name": "typedoc-stubs", + "variant": "project", + "kind": 1, + "flags": {}, + "children": [ + { + "id": 4, + "name": "ModuleWithDocuments1", + "variant": "declaration", + "kind": 2, + "flags": {}, + "children": [ + { + "id": 31, + "name": "NamespaceWithDocuments", + "variant": "declaration", + "kind": 4, + "flags": {}, + "children": [ + { + "id": 33, + "name": "NamespaceClassWithDocuments", + "variant": "declaration", + "kind": 128, + "flags": {}, + "children": [ + { + "id": 35, + "name": "constructor", + "variant": "declaration", + "kind": 512, + "flags": {}, + "signatures": [ + { + "id": 36, + "name": "new NamespaceClassWithDocuments", + "variant": "signature", + "kind": 16384, + "flags": {}, + "type": { + "type": "reference", + "target": 33, + "name": "NamespaceClassWithDocuments", + "package": "typedoc-stubs", + "qualifiedName": "NamespaceWithDocuments.NamespaceClassWithDocuments" + } + } + ] + } + ], + "documents": [ + { + "id": 34, + "name": "CLASS_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Class Documentation" + } + ], + "frontmatter": {} + } + ], + "childrenIncludingDocuments": [ + 34, + 35 + ], + "groups": [ + { + "title": "Documents", + "children": [ + 34 + ] + }, + { + "title": "Constructors", + "children": [ + 35 + ] + } + ] + } + ], + "documents": [ + { + "id": 32, + "name": "NAMESPACE_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Namespace Documentation" + } + ], + "frontmatter": {} + } + ], + "childrenIncludingDocuments": [ + 32, + 33 + ], + "groups": [ + { + "title": "Documents", + "children": [ + 32 + ] + }, + { + "title": "Classes", + "children": [ + 33 + ] + } + ] + }, + { + "id": 20, + "name": "EnumWithDocuments", + "variant": "declaration", + "kind": 8, + "flags": {}, + "children": [ + { + "id": 22, + "name": "EnumMember", + "variant": "declaration", + "kind": 16, + "flags": {}, + "type": { + "type": "literal", + "value": 0 + } + } + ], + "documents": [ + { + "id": 21, + "name": "ENUM_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Enum Documentation" + } + ], + "frontmatter": {} + } + ], + "childrenIncludingDocuments": [ + 21, + 22 + ], + "groups": [ + { + "title": "Documents", + "children": [ + 21 + ] + }, + { + "title": "Enumeration Members", + "children": [ + 22 + ] + } + ] + }, + { + "id": 23, + "name": "ClassWithDocuments", + "variant": "declaration", + "kind": 128, + "flags": {}, + "children": [ + { + "id": 25, + "name": "constructor", + "variant": "declaration", + "kind": 512, + "flags": {}, + "signatures": [ + { + "id": 26, + "name": "new ClassWithDocuments", + "variant": "signature", + "kind": 16384, + "flags": {}, + "type": { + "type": "reference", + "target": 23, + "name": "ClassWithDocuments", + "package": "typedoc-stubs" + } + } + ] + } + ], + "documents": [ + { + "id": 24, + "name": "CLASS_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Class Documentation" + } + ], + "frontmatter": {} + } + ], + "childrenIncludingDocuments": [ + 24, + 25 + ], + "groups": [ + { + "title": "Documents", + "children": [ + 24 + ] + }, + { + "title": "Constructors", + "children": [ + 25 + ] + } + ] + }, + { + "id": 17, + "name": "InterfaceWithDocuments", + "variant": "declaration", + "kind": 256, + "flags": {}, + "children": [ + { + "id": 19, + "name": "prop", + "variant": "declaration", + "kind": 1024, + "flags": {}, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "documents": [ + { + "id": 18, + "name": "INTERFACE_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Interface Documentation" + } + ], + "frontmatter": {} + } + ], + "childrenIncludingDocuments": [ + 18, + 19 + ], + "groups": [ + { + "title": "Documents", + "children": [ + 18 + ] + }, + { + "title": "Properties", + "children": [ + 19 + ] + } + ] + }, + { + "id": 29, + "name": "TypeWithDocuments", + "variant": "declaration", + "kind": 2097152, + "flags": {}, + "documents": [ + { + "id": 30, + "name": "TYPE_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Type Documentation" + } + ], + "frontmatter": {} + } + ], + "groups": [ + { + "title": "Documents", + "children": [ + 30 + ] + } + ], + "type": { + "type": "literal", + "value": "string" + } + }, + { + "id": 27, + "name": "variableWithDocuments", + "variant": "declaration", + "kind": 32, + "flags": { + "isConst": true + }, + "documents": [ + { + "id": 28, + "name": "VARIABLE_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Variable Documentation" + } + ], + "frontmatter": {} + } + ], + "groups": [ + { + "title": "Documents", + "children": [ + 28 + ] + } + ], + "type": { + "type": "literal", + "value": 1 + }, + "defaultValue": "1" + }, + { + "id": 14, + "name": "functionWithDocuments", + "variant": "declaration", + "kind": 64, + "flags": {}, + "documents": [ + { + "id": 16, + "name": "FUNCTION_DOC_1", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Function Documentation" + } + ], + "frontmatter": {} + } + ], + "groups": [ + { + "title": "Documents", + "children": [ + 16 + ] + } + ], + "signatures": [ + { + "id": 15, + "name": "functionWithDocuments", + "variant": "signature", + "kind": 4096, + "flags": {}, + "comment": { + "summary": [ + { + "kind": "text", + "text": "Comments for functionWithDocuments" + } + ] + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ] + }, + { + "id": 6, + "name": "multipleFunctionWithDocuments", + "variant": "declaration", + "kind": 64, + "flags": {}, + "comment": { + "summary": [ + { + "kind": "text", + "text": "Comments for multipleFunctionWithDocuments" + } + ] + }, + "documents": [ + { + "id": 9, + "name": "FUNCTION_DOC_1", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Function Documentation" + } + ], + "frontmatter": {} + }, + { + "id": 12, + "name": "FUNCTION_DOC_2", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Function Documentation" + } + ], + "frontmatter": {} + }, + { + "id": 7, + "name": "FUNCTION_DOC_3", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Function Documentation" + } + ], + "frontmatter": {} + } + ], + "groups": [ + { + "title": "Documents", + "children": [ + 9, + 12, + 7 + ] + } + ], + "signatures": [ + { + "id": 8, + "name": "multipleFunctionWithDocuments", + "variant": "signature", + "kind": 4096, + "flags": {}, + "comment": { + "summary": [ + { + "kind": "text", + "text": "Comments for multipleFunctionWithDocumentsA" + } + ] + }, + "parameters": [ + { + "id": 10, + "name": "value", + "variant": "param", + "kind": 32768, + "flags": {}, + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 11, + "name": "multipleFunctionWithDocuments", + "variant": "signature", + "kind": 4096, + "flags": {}, + "comment": { + "summary": [ + { + "kind": "text", + "text": "Comments for multipleFunctionWithDocumentsB" + } + ] + }, + "parameters": [ + { + "id": 13, + "name": "value", + "variant": "param", + "kind": 32768, + "flags": {}, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + ], + "documents": [ + { + "id": 5, + "name": "MODULE_DOC", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Module Documentation" + } + ], + "frontmatter": {} + } + ], + "childrenIncludingDocuments": [ + 5, + 31, + 20, + 23, + 17, + 29, + 27, + 14, + 6 + ], + "groups": [ + { + "title": "Documents", + "children": [ + 5 + ] + }, + { + "title": "Namespaces", + "children": [ + 31 + ] + }, + { + "title": "Enumerations", + "children": [ + 20 + ] + }, + { + "title": "Classes", + "children": [ + 23 + ] + }, + { + "title": "Interfaces", + "children": [ + 17 + ] + }, + { + "title": "Type Aliases", + "children": [ + 29 + ] + }, + { + "title": "Variables", + "children": [ + 27 + ] + }, + { + "title": "Functions", + "children": [ + 14, + 6 + ] + } + ] + } + ], + "documents": [ + { + "id": 1, + "name": "Project Document 1", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Project Document 1" + } + ], + "frontmatter": {} + }, + { + "id": 2, + "name": "docs/project/PROJECT_DOC_2", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Document 1" + } + ], + "frontmatter": {} + }, + { + "id": 3, + "name": "docs/project/PROJECT_DOC_3", + "variant": "document", + "kind": 8388608, + "flags": {}, + "content": [ + { + "kind": "text", + "text": "# Document 2" + } + ], + "frontmatter": {} + } + ], + "childrenIncludingDocuments": [ + 1, + 2, + 3, + 4 + ], + "groups": [ + { + "title": "Documents", + "children": [ + 1, + 2, + 3 + ] + }, + { + "title": "Modules", + "children": [ + 4 + ] + } + ], + "packageName": "typedoc-stubs", + "symbolIdMap": { + "4": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "" + }, + "6": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "multipleFunctionWithDocuments" + }, + "8": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "multipleFunctionWithDocuments" + }, + "10": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "value" + }, + "11": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "multipleFunctionWithDocuments" + }, + "13": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "value" + }, + "14": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "functionWithDocuments" + }, + "15": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "functionWithDocuments" + }, + "17": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "InterfaceWithDocuments" + }, + "19": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "InterfaceWithDocuments.prop" + }, + "20": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "EnumWithDocuments" + }, + "22": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "EnumWithDocuments.EnumMember" + }, + "23": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "ClassWithDocuments" + }, + "27": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "variableWithDocuments" + }, + "29": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "TypeWithDocuments" + }, + "31": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "NamespaceWithDocuments" + }, + "33": { + "sourceFileName": "test/fixtures/src/documents/module-1.ts", + "qualifiedName": "NamespaceWithDocuments.NamespaceClassWithDocuments" + } + } +} \ No newline at end of file diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap index e2df22429..7ef711937 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap @@ -5,7 +5,7 @@ exports[`Comments should compile comments for module: (Output File Strategy "mem Comments form module comments -## Links +> links Links using \`{@link}\` inline tags. @@ -24,13 +24,10 @@ External links: - [Google](https://www.google.com) - [\`https://www.google.com\`](https://www.google.com) -## Tag A +## See -Comments for a tag - -## Tag B - -Comments for tag written on same line + - Comments for a tag + - Comments for tag written on same line ## Html And Jsx @@ -51,20 +48,15 @@ A in a code block Some

html

inside codeblock \`\`\` -## Media +> media You can include media in doc comments: -![alt SomeAlt](media/logo.png) +![alt SomeAlt](media://logo.png) And include other files: -This is a simple example on how to use include. - -![My image alt text](media/logo.png) - [[include:not-found.md]] - -## Code Blocks +> codeBlocks \`\`\`css .class {color:red} @@ -76,6 +68,12 @@ This is a simple example on how to use include. \`single line {block}\` +## Documents + +This is a simple example on how to use include. + +![My image alt text](media://logo.png) + ## Enumerations - [CommentEnum](enumerations/CommentEnum.md) @@ -159,15 +157,15 @@ exports[`Comments should get tables for parameters: (Output File Strategy "membe Adds two numbers together. -## Type parameters +## Type Parameters -| Type parameter | Value | Description | +| Type Parameter | Value | Description | | ------ | ------ | ------ | | \`T\` | \`string\` | The type of the numbers to be added. | ## Parameters -| Parameter | Type | Default value | Description | +| Parameter | Type | Default Value | Description | | ------ | ------ | ------ | ------ | | \`param1\` | \`number\` | \`undefined\` | The first param to be added. | | \`param2\` | \`number\` | \`undefined\` | The second param to be added. Some additional text for num2. | @@ -202,11 +200,11 @@ exports[`Comments should get tables for properties: (Output File Strategy "membe ## Properties -| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | +| Property | Modifier | Type | Default Value | Description | Overrides | Inherited from | | ------ | ------ | ------ | ------ | ------ | ------ | ------ | | \`prop1\` | \`private\` | \`boolean\` | \`undefined\` | The subroutine recursively parsed the hexadecimal data. to generate the binary output for input validation. | - | - | | \`prop2\` | \`readonly\` | \`RegExp\` | \`undefined\` | Below is a breakdown of the notable performances: - The CPU executed the instruction set in parallel with the GPU computations. - The RAM efficiently cached the frequently accessed data for faster retrieval. - The SSD accessed the stored files with lightning speed due to its high read/write capabilities. | - | - | -| \`prop3?\` | \`public\` | \`string\` | \`undefined\` | ### Example of Triple Code Block \`def greet(name): print("Hello, " + name + "!")\` | - | - | +| \`prop3?\` | \`public\` | \`string\` | \`undefined\` | > Example of Triple Code Block \`def greet(name): print("Hello, " + name + "!")\` | - | - | | ~~\`propA\`~~ | \`public\` | \`string\` | \`'propAValue'\` | **Deprecated** | [\`BaseClassProperties\`](BaseClassProperties.md).\`propA\` | - | | \`propB\` | \`public\` | \`string\` | \`undefined\` | - | - | [\`BaseClassProperties\`](BaseClassProperties.md).\`propB\` | " @@ -238,7 +236,7 @@ exports[`Comments should get tables for properties: (Output File Strategy "membe ## Properties - +
PropertyTypeDefault valueDescription
PropertyTypeDefault ValueDescription
@@ -306,7 +304,7 @@ Below is a breakdown of the notable performances: -### Example of Triple Code Block +> Example of Triple Code Block \`\`\`python def greet(name): @@ -364,7 +362,7 @@ print("Hello, " + name + "!") `; exports[`Comments should get tables for type declarations: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: TypeDeclarationTable +"# Type Alias: TypeDeclarationTable > **TypeDeclarationTable**: \`object\` @@ -379,7 +377,7 @@ exports[`Comments should get tables for type declarations: (Output File Strategy `; exports[`Comments should get tables for type declarations: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: TypeDeclarationTable +"# Type Alias: TypeDeclarationTable > **TypeDeclarationTable**: \`object\` diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/documents.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/documents.spec.ts.snap new file mode 100644 index 000000000..58eb4d813 --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/documents.spec.ts.snap @@ -0,0 +1,336 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Documents Class should compile a module document: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../../README.md) / [ModuleWithDocuments1](../../README.md) / [ClassWithDocuments](../ClassWithDocuments.md) / CLASS\\_DOC + +> Class Documentation + +Document content +" +`; + +exports[`Documents Class should compile index page for class: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../README.md) / [ModuleWithDocuments1](../README.md) / ClassWithDocuments + +# Class: ClassWithDocuments + +## Documents + +- [CLASS\\_DOC](documents/CLASS_DOC.md) + +## Constructors + +_CONSTRUCTOR_MEMBER_PARTIAL_ +" +`; + +exports[`Documents Enum should compile a module document: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../../README.md) / [ModuleWithDocuments1](../../README.md) / [EnumWithDocuments](../EnumWithDocuments.md) / ENUM\\_DOC + +> Enum Documentation + +Document content +" +`; + +exports[`Documents Enum should compile index page for enum: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../README.md) / [ModuleWithDocuments1](../README.md) / EnumWithDocuments + +# Enumeration: EnumWithDocuments + +## Documents + +- [ENUM\\_DOC](documents/ENUM_DOC.md) + +## Enumeration Members + +### EnumMember + +_DECLARATION_TITLE_PARTIAL_ +" +`; + +exports[`Documents Interface should compile a interface document: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../../README.md) / [ModuleWithDocuments1](../../README.md) / [InterfaceWithDocuments](../InterfaceWithDocuments.md) / INTERFACE\\_DOC + +> Interface Documentation + +Document content +" +`; + +exports[`Documents Interface should compile a interface document: (Output File Strategy "members") (Option Group "1") 2`] = ` +"[typedoc-stubs](../../../README.md) / [ModuleWithDocuments1](../../README.md) / [InterfaceWithDocuments](../InterfaceWithDocuments.md) / INTERFACE\\_DOC + +> Interface Documentation + +Document content +" +`; + +exports[`Documents Interface should compile index page for interface: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../README.md) / [ModuleWithDocuments1](../README.md) / InterfaceWithDocuments + +# Interface: InterfaceWithDocuments + +## Documents + +- [INTERFACE\\_DOC](documents/INTERFACE_DOC.md) + +## Properties + +### prop + +_DECLARATION_TITLE_PARTIAL_ +" +`; + +exports[`Documents Interface should compile index page for interface: (Output File Strategy "members") (Option Group "1") 2`] = ` +"[typedoc-stubs](../../README.md) / [ModuleWithDocuments1](../README.md) / InterfaceWithDocuments + +# Interface: InterfaceWithDocuments + +## Documents + +- [INTERFACE\\_DOC](documents/INTERFACE_DOC.md) + +## Properties + +### prop + +_DECLARATION_TITLE_PARTIAL_ +" +`; + +exports[`Documents Module should compile index page for module: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../README.md) / ModuleWithDocuments1 + +# ModuleWithDocuments1 + +## Documents + +- [MODULE\\_DOC](documents/MODULE_DOC.md) + +## Namespaces + +- [NamespaceWithDocuments](namespaces/NamespaceWithDocuments/README.md) + +## Enumerations + +- [EnumWithDocuments](enumerations/EnumWithDocuments.md) + +## Classes + +- [ClassWithDocuments](classes/ClassWithDocuments.md) + +## Interfaces + +- [InterfaceWithDocuments](interfaces/InterfaceWithDocuments.md) + +## Type Aliases + +- [TypeWithDocuments](type-aliases/TypeWithDocuments.md) + +## Variables + +- [variableWithDocuments](variables/variableWithDocuments.md) + +## Functions + +- [functionWithDocuments](functions/functionWithDocuments.md) +- [multipleFunctionWithDocuments](functions/multipleFunctionWithDocuments.md) +" +`; + +exports[`Documents Module should compile index page for module: (Output File Strategy "modules") (Option Group "1") 1`] = ` +"[typedoc-stubs](../README.md) / ModuleWithDocuments1 + +# ModuleWithDocuments1 + +## Documents + +- [MODULE\\_DOC](documents/MODULE_DOC.md) + +## Namespaces + +- [NamespaceWithDocuments](namespaces/NamespaceWithDocuments/README.md) + +## Enumerations + +### EnumWithDocuments + +#### Documents + +- [ENUM\\_DOC](documents/Enumeration.ENUM_DOC.md) + +#### Enumeration Members + +##### EnumMember + +_DECLARATION_TITLE_PARTIAL_ + +## Classes + +### ClassWithDocuments + +#### Documents + +- [CLASS\\_DOC](documents/Class.CLASS_DOC.md) + +#### Constructors + +_CONSTRUCTOR_MEMBER_PARTIAL_ + +## Interfaces + +### InterfaceWithDocuments + +#### Documents + +- [INTERFACE\\_DOC](documents/Interface.INTERFACE_DOC.md) + +#### Properties + +##### prop + +_DECLARATION_TITLE_PARTIAL_ + +## Type Aliases + +### TypeWithDocuments + +_DECLARATION_TITLE_PARTIAL_ + +#### Documents + +- [TYPE\\_DOC](documents/TypeAlias.TYPE_DOC.md) + +## Variables + +### variableWithDocuments + +_DECLARATION_TITLE_PARTIAL_ + +#### Documents + +- [VARIABLE\\_DOC](documents/Variable.VARIABLE_DOC.md) + +## Functions + +### functionWithDocuments() + +_SIGNATURE_TITLE_PARTIAL_ + +Comments for functionWithDocuments + +#### Documents + +- [FUNCTION\\_DOC\\_1](documents/Function.FUNCTION_DOC_1.md) + +_SIGNATURE_RETURNS_PARTIAL_ + +*** + +### multipleFunctionWithDocuments() + +Comments for multipleFunctionWithDocuments + +#### Documents + +- [FUNCTION\\_DOC\\_1](documents/Function.FUNCTION_DOC_1.md) +- [FUNCTION\\_DOC\\_2](documents/Function.FUNCTION_DOC_2.md) +- [FUNCTION\\_DOC\\_3](documents/Function.FUNCTION_DOC_3.md) + +#### multipleFunctionWithDocuments(value) + +_SIGNATURE_TITLE_PARTIAL_ + +Comments for multipleFunctionWithDocumentsA + +##### Parameters + +_PARAMETERS_LIST_PARTIAL_ + +_SIGNATURE_RETURNS_PARTIAL_ + +#### multipleFunctionWithDocuments(value) + +_SIGNATURE_TITLE_PARTIAL_ + +Comments for multipleFunctionWithDocumentsB + +##### Parameters + +_PARAMETERS_LIST_PARTIAL_ + +_SIGNATURE_RETURNS_PARTIAL_ +" +`; + +exports[`Documents Module should compile module documents: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../README.md) / [ModuleWithDocuments1](../README.md) / MODULE\\_DOC + +> Module Documentation + +Document content +" +`; + +exports[`Documents Module should compile module documents: (Output File Strategy "modules") (Option Group "1") 1`] = ` +"[typedoc-stubs](../../README.md) / [ModuleWithDocuments1](../README.md) / MODULE\\_DOC + +> Module Documentation + +Document content +" +`; + +exports[`Documents Project should compile a project document: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[typedoc-stubs](../README.md) / Project Document 1 + +## Project Document 1 + +Document content +" +`; + +exports[`Documents Project should compile a project document: (Output File Strategy "modules") (Option Group "1") 1`] = ` +"[typedoc-stubs](../README.md) / Project Document 1 + +## Project Document 1 + +Document content +" +`; + +exports[`Documents Project should compile index page for project: (Output File Strategy "members") (Option Group "1") 1`] = ` +"# typedoc-stubs + +## Documents + +- [Project Document 1](documents/Project-Document-1.md) +- [docs/project/PROJECT\\_DOC\\_2](documents/docs/project/PROJECT_DOC_2.md) +- [docs/project/PROJECT\\_DOC\\_3](documents/docs/project/PROJECT_DOC_3.md) + +## Modules + +- [ModuleWithDocuments1](ModuleWithDocuments1/README.md) +- [ModuleWithDocuments2](ModuleWithDocuments2/README.md) +" +`; + +exports[`Documents Project should compile index page for project: (Output File Strategy "modules") (Option Group "1") 1`] = ` +"# typedoc-stubs + +## Documents + +- [Project Document 1](documents/Project-Document-1.md) +- [docs/project/PROJECT\\_DOC\\_2](documents/docs/project/PROJECT_DOC_2.md) +- [docs/project/PROJECT\\_DOC\\_3](documents/docs/project/PROJECT_DOC_3.md) + +## Modules + +- [ModuleWithDocuments1](ModuleWithDocuments1/README.md) +- [ModuleWithDocuments2](ModuleWithDocuments2/README.md) +" +`; diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap index 7aec8e807..af916ebbd 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap @@ -57,6 +57,8 @@ A basic module ## Index +### Members + | Member | Description | | :------ | :------ | | [EnumA](enumerations/EnumA.md) | EnumA function. | @@ -629,6 +631,8 @@ exports[`Groups should compile index page for project: (Output File Strategy "me # typedoc-stubs +## Members + | Member | Description | | :------ | :------ | | [42-module-name](42-module-name/index.md) | - | @@ -671,6 +675,8 @@ exports[`Groups should compile index page for project: (Output File Strategy "mo # typedoc-stubs +## Members + | Member | Description | | :------ | :------ | | [42-module-name](42-module-name.md) | - | @@ -717,6 +723,8 @@ exports[`Groups should compile module index for a namespace: (Output File Strate ## Index +### Members + | Member | Description | | :------ | :------ | | [NestedNamespace](namespaces/NestedNamespace/index.md) | - | @@ -756,6 +764,8 @@ exports[`Groups should compile module index for a namespace: (Output File Strate ## Index +### Members + | Member | Description | | :------ | :------ | | [NestedNamespace](namespaces/NestedNamespace.md) | - | @@ -829,6 +839,8 @@ A module that contains namespaces ## Index +### Members + | Member | Description | | :------ | :------ | | [NamespaceB](namespaces/NamespaceB/index.md) | - | @@ -965,6 +977,8 @@ A module that contains namespaces ## Index +### Members + | Member | Description | | :------ | :------ | | [NamespaceB](namespaces/NamespaceB.md) | - | @@ -1207,6 +1221,8 @@ A module that contains references ## Index +### Members + | Member | Description | | :------ | :------ | | [defaultFunction](functions/defaultFunction.md) | - | diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/navigation.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/navigation.spec.ts.snap index bb0216835..04631209c 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/navigation.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/navigation.spec.ts.snap @@ -922,6 +922,1154 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate ]" `; +exports[`Navigation should gets Navigation Json for documents multi module: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608, + "path": "documents/Project-Document-1.md" + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_2.md" + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_3.md" + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1/README.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/documents/MODULE_DOC.md" + }, + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "children": [ + { + "title": "NAMESPACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md" + }, + { + "title": "Classes", + "children": [ + { + "title": "NamespaceClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/NamespaceClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/documents/CLASS_DOC.md" + } + ] + } + ] + } + ] + } + ] + }, + { + "title": "Enumerations", + "children": [ + { + "title": "EnumWithDocuments", + "kind": 8, + "path": "ModuleWithDocuments1/enumerations/EnumWithDocuments.md", + "children": [ + { + "title": "ENUM_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/enumerations/documents/ENUM_DOC.md" + } + ] + } + ] + }, + { + "title": "Classes", + "children": [ + { + "title": "ClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1/classes/ClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/classes/documents/CLASS_DOC.md" + } + ] + } + ] + }, + { + "title": "Interfaces", + "children": [ + { + "title": "InterfaceWithDocuments", + "kind": 256, + "path": "ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md", + "children": [ + { + "title": "INTERFACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/interfaces/documents/INTERFACE_DOC.md" + } + ] + } + ] + }, + { + "title": "Type Aliases", + "children": [ + { + "title": "TypeWithDocuments", + "kind": 2097152, + "path": "ModuleWithDocuments1/type-aliases/TypeWithDocuments.md", + "children": [ + { + "title": "TYPE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/type-aliases/documents/TYPE_DOC.md" + } + ] + } + ] + }, + { + "title": "Variables", + "children": [ + { + "title": "variableWithDocuments", + "kind": 32, + "path": "ModuleWithDocuments1/variables/variableWithDocuments.md", + "children": [ + { + "title": "VARIABLE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/variables/documents/VARIABLE_DOC.md" + } + ] + } + ] + }, + { + "title": "Functions", + "children": [ + { + "title": "functionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1/functions/functionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_1.md" + } + ] + }, + { + "title": "multipleFunctionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1/functions/multipleFunctionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_1.md" + } + ] + } + ] + } + ] + }, + { + "title": "ModuleWithDocuments2", + "kind": 2, + "path": "ModuleWithDocuments2/README.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2/documents/MODULE_DOC.md" + }, + { + "title": "Enumerations", + "children": [ + { + "title": "EnumWithDocuments", + "kind": 8, + "path": "ModuleWithDocuments2/enumerations/EnumWithDocuments.md", + "children": [ + { + "title": "ENUM_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2/enumerations/documents/ENUM_DOC.md" + } + ] + } + ] + }, + { + "title": "Classes", + "children": [ + { + "title": "ClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments2/classes/ClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2/classes/documents/CLASS_DOC.md" + } + ] + } + ] + }, + { + "title": "Interfaces", + "children": [ + { + "title": "InterfaceWithDocuments", + "kind": 256, + "path": "ModuleWithDocuments2/interfaces/InterfaceWithDocuments.md", + "children": [ + { + "title": "INTERFACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2/interfaces/documents/INTERFACE_DOC.md" + } + ] + } + ] + }, + { + "title": "Type Aliases", + "children": [ + { + "title": "TypeWithDocuments", + "kind": 2097152, + "path": "ModuleWithDocuments2/type-aliases/TypeWithDocuments.md", + "children": [ + { + "title": "TYPE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2/type-aliases/documents/TYPE_DOC.md" + } + ] + } + ] + }, + { + "title": "Variables", + "children": [ + { + "title": "variableWithDocuments", + "kind": 32, + "path": "ModuleWithDocuments2/variables/variableWithDocuments.md", + "children": [ + { + "title": "VARIABLE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2/variables/documents/VARIABLE_DOC.md" + } + ] + } + ] + }, + { + "title": "Functions", + "children": [ + { + "title": "functionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments2/functions/functionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments2/functions/documents/FUNCTION_DOC_1.md" + } + ] + }, + { + "title": "multipleFunctionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments2/functions/multipleFunctionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments2/functions/documents/FUNCTION_DOC_1.md" + } + ] + } + ] + } + ] + } +]" +`; + +exports[`Navigation should gets Navigation Json for documents multi module: (Output File Strategy "members") (Option Group "2") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608, + "path": "Document.Project-Document-1.md" + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608, + "path": "Document.docs.project.PROJECT_DOC_2.md" + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608, + "path": "Document.docs.project.PROJECT_DOC_3.md" + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.Document.MODULE_DOC.md" + }, + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1.Namespace.NamespaceWithDocuments.md", + "children": [ + { + "title": "NAMESPACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.NamespaceWithDocuments.Document.NAMESPACE_DOC.md" + }, + { + "title": "Classes", + "children": [ + { + "title": "NamespaceClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1.NamespaceWithDocuments.Class.NamespaceClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.NamespaceWithDocuments.NamespaceClassWithDocuments.Document.CLASS_DOC.md" + } + ] + } + ] + } + ] + } + ] + }, + { + "title": "Enumerations", + "children": [ + { + "title": "EnumWithDocuments", + "kind": 8, + "path": "ModuleWithDocuments1.Enumeration.EnumWithDocuments.md", + "children": [ + { + "title": "ENUM_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.EnumWithDocuments.Document.ENUM_DOC.md" + } + ] + } + ] + }, + { + "title": "Classes", + "children": [ + { + "title": "ClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1.Class.ClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.ClassWithDocuments.Document.CLASS_DOC.md" + } + ] + } + ] + }, + { + "title": "Interfaces", + "children": [ + { + "title": "InterfaceWithDocuments", + "kind": 256, + "path": "ModuleWithDocuments1.Interface.InterfaceWithDocuments.md", + "children": [ + { + "title": "INTERFACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.InterfaceWithDocuments.Document.INTERFACE_DOC.md" + } + ] + } + ] + }, + { + "title": "Type Aliases", + "children": [ + { + "title": "TypeWithDocuments", + "kind": 2097152, + "path": "ModuleWithDocuments1.TypeAlias.TypeWithDocuments.md", + "children": [ + { + "title": "TYPE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.TypeWithDocuments.Document.TYPE_DOC.md" + } + ] + } + ] + }, + { + "title": "Variables", + "children": [ + { + "title": "variableWithDocuments", + "kind": 32, + "path": "ModuleWithDocuments1.Variable.variableWithDocuments.md", + "children": [ + { + "title": "VARIABLE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.variableWithDocuments.Document.VARIABLE_DOC.md" + } + ] + } + ] + }, + { + "title": "Functions", + "children": [ + { + "title": "functionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1.Function.functionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments1.functionWithDocuments.Document.FUNCTION_DOC_1.md" + } + ] + }, + { + "title": "multipleFunctionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1.Function.multipleFunctionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments1.multipleFunctionWithDocuments.Document.FUNCTION_DOC_1.md" + } + ] + } + ] + } + ] + }, + { + "title": "ModuleWithDocuments2", + "kind": 2, + "path": "ModuleWithDocuments2.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2.Document.MODULE_DOC.md" + }, + { + "title": "Enumerations", + "children": [ + { + "title": "EnumWithDocuments", + "kind": 8, + "path": "ModuleWithDocuments2.Enumeration.EnumWithDocuments.md", + "children": [ + { + "title": "ENUM_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2.EnumWithDocuments.Document.ENUM_DOC.md" + } + ] + } + ] + }, + { + "title": "Classes", + "children": [ + { + "title": "ClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments2.Class.ClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2.ClassWithDocuments.Document.CLASS_DOC.md" + } + ] + } + ] + }, + { + "title": "Interfaces", + "children": [ + { + "title": "InterfaceWithDocuments", + "kind": 256, + "path": "ModuleWithDocuments2.Interface.InterfaceWithDocuments.md", + "children": [ + { + "title": "INTERFACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2.InterfaceWithDocuments.Document.INTERFACE_DOC.md" + } + ] + } + ] + }, + { + "title": "Type Aliases", + "children": [ + { + "title": "TypeWithDocuments", + "kind": 2097152, + "path": "ModuleWithDocuments2.TypeAlias.TypeWithDocuments.md", + "children": [ + { + "title": "TYPE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2.TypeWithDocuments.Document.TYPE_DOC.md" + } + ] + } + ] + }, + { + "title": "Variables", + "children": [ + { + "title": "variableWithDocuments", + "kind": 32, + "path": "ModuleWithDocuments2.Variable.variableWithDocuments.md", + "children": [ + { + "title": "VARIABLE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2.variableWithDocuments.Document.VARIABLE_DOC.md" + } + ] + } + ] + }, + { + "title": "Functions", + "children": [ + { + "title": "functionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments2.Function.functionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments2.functionWithDocuments.Document.FUNCTION_DOC_1.md" + } + ] + }, + { + "title": "multipleFunctionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments2.Function.multipleFunctionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments2.multipleFunctionWithDocuments.Document.FUNCTION_DOC_1.md" + } + ] + } + ] + } + ] + } +]" +`; + +exports[`Navigation should gets Navigation Json for documents multi module: (Output File Strategy "modules") (Option Group "1") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608, + "path": "documents/Project-Document-1.md" + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_2.md" + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_3.md" + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1/README.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/documents/MODULE_DOC.md" + }, + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "children": [ + { + "title": "NAMESPACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md" + } + ] + } + ] + } + ] + }, + { + "title": "ModuleWithDocuments2", + "kind": 2, + "path": "ModuleWithDocuments2/README.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2/documents/MODULE_DOC.md" + } + ] + } +]" +`; + +exports[`Navigation should gets Navigation Json for documents multi module: (Output File Strategy "modules") (Option Group "2") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608, + "path": "Document.Project-Document-1.md" + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608, + "path": "Document.docs.project.PROJECT_DOC_2.md" + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608, + "path": "Document.docs.project.PROJECT_DOC_3.md" + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.Document.MODULE_DOC.md" + }, + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1.Namespace.NamespaceWithDocuments.md", + "children": [ + { + "title": "NAMESPACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1.NamespaceWithDocuments.Document.NAMESPACE_DOC.md" + } + ] + } + ] + } + ] + }, + { + "title": "ModuleWithDocuments2", + "kind": 2, + "path": "ModuleWithDocuments2.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments2.Document.MODULE_DOC.md" + } + ] + } +]" +`; + +exports[`Navigation should gets Navigation Json for documents single module: (Output File Strategy "members") (Option Group "1") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608, + "path": "documents/Project-Document-1.md" + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_2.md" + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_3.md" + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1/README.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/documents/MODULE_DOC.md" + }, + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "children": [ + { + "title": "NAMESPACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md" + }, + { + "title": "Classes", + "children": [ + { + "title": "NamespaceClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/NamespaceClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/documents/CLASS_DOC.md" + } + ] + } + ] + } + ] + } + ] + }, + { + "title": "Enumerations", + "children": [ + { + "title": "EnumWithDocuments", + "kind": 8, + "path": "ModuleWithDocuments1/enumerations/EnumWithDocuments.md", + "children": [ + { + "title": "ENUM_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/enumerations/documents/ENUM_DOC.md" + } + ] + } + ] + }, + { + "title": "Classes", + "children": [ + { + "title": "ClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1/classes/ClassWithDocuments.md", + "children": [ + { + "title": "CLASS_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/classes/documents/CLASS_DOC.md" + } + ] + } + ] + }, + { + "title": "Interfaces", + "children": [ + { + "title": "InterfaceWithDocuments", + "kind": 256, + "path": "ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md", + "children": [ + { + "title": "INTERFACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/interfaces/documents/INTERFACE_DOC.md" + } + ] + } + ] + }, + { + "title": "Type Aliases", + "children": [ + { + "title": "TypeWithDocuments", + "kind": 2097152, + "path": "ModuleWithDocuments1/type-aliases/TypeWithDocuments.md", + "children": [ + { + "title": "TYPE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/type-aliases/documents/TYPE_DOC.md" + } + ] + } + ] + }, + { + "title": "Variables", + "children": [ + { + "title": "variableWithDocuments", + "kind": 32, + "path": "ModuleWithDocuments1/variables/variableWithDocuments.md", + "children": [ + { + "title": "VARIABLE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/variables/documents/VARIABLE_DOC.md" + } + ] + } + ] + }, + { + "title": "Functions", + "children": [ + { + "title": "functionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1/functions/functionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_1.md" + } + ] + }, + { + "title": "multipleFunctionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1/functions/multipleFunctionWithDocuments.md", + "children": [ + { + "title": "FUNCTION_DOC_1", + "kind": 8388608, + "path": "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_1.md" + } + ] + } + ] + } + ] + } +]" +`; + +exports[`Navigation should gets Navigation Json for documents single module: (Output File Strategy "members") (Option Group "2") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608 + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608 + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608 + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1/README.md", + "children": [ + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "children": [ + { + "title": "Classes", + "children": [ + { + "title": "NamespaceClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/NamespaceClassWithDocuments.md" + } + ] + } + ] + } + ] + }, + { + "title": "Enumerations", + "children": [ + { + "title": "EnumWithDocuments", + "kind": 8, + "path": "ModuleWithDocuments1/enumerations/EnumWithDocuments.md" + } + ] + }, + { + "title": "Classes", + "children": [ + { + "title": "ClassWithDocuments", + "kind": 128, + "path": "ModuleWithDocuments1/classes/ClassWithDocuments.md" + } + ] + }, + { + "title": "Interfaces", + "children": [ + { + "title": "InterfaceWithDocuments", + "kind": 256, + "path": "ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md" + } + ] + }, + { + "title": "Type Aliases", + "children": [ + { + "title": "TypeWithDocuments", + "kind": 2097152, + "path": "ModuleWithDocuments1/type-aliases/TypeWithDocuments.md" + } + ] + }, + { + "title": "Variables", + "children": [ + { + "title": "variableWithDocuments", + "kind": 32, + "path": "ModuleWithDocuments1/variables/variableWithDocuments.md" + } + ] + }, + { + "title": "Functions", + "children": [ + { + "title": "functionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1/functions/functionWithDocuments.md" + }, + { + "title": "multipleFunctionWithDocuments", + "kind": 64, + "path": "ModuleWithDocuments1/functions/multipleFunctionWithDocuments.md" + } + ] + } + ] + } +]" +`; + +exports[`Navigation should gets Navigation Json for documents single module: (Output File Strategy "modules") (Option Group "1") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608, + "path": "documents/Project-Document-1.md" + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_2.md" + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608, + "path": "documents/docs/project/PROJECT_DOC_3.md" + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1/README.md", + "children": [ + { + "title": "MODULE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/documents/MODULE_DOC.md" + }, + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "children": [ + { + "title": "NAMESPACE_DOC", + "kind": 8388608, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md" + } + ] + } + ] + } + ] + } +]" +`; + +exports[`Navigation should gets Navigation Json for documents single module: (Output File Strategy "modules") (Option Group "2") 1`] = ` +"[ + { + "title": "Documents", + "children": [ + { + "title": "Project Document 1", + "kind": 8388608 + }, + { + "title": "docs/project/PROJECT_DOC_2", + "kind": 8388608 + }, + { + "title": "docs/project/PROJECT_DOC_3", + "kind": 8388608 + } + ] + }, + { + "title": "ModuleWithDocuments1", + "kind": 2, + "path": "ModuleWithDocuments1/README.md", + "children": [ + { + "title": "Namespaces", + "children": [ + { + "title": "NamespaceWithDocuments", + "kind": 4, + "path": "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md" + } + ] + } + ] + } +]" +`; + exports[`Navigation should gets Navigation Json for entry modules: (Output File Strategy "members") (Option Group "1") 1`] = ` "[ { @@ -1544,12 +2692,12 @@ exports[`Navigation should gets Navigation Json for modules with parts: (Output { "title": "TypeA", "kind": 2097152, - "path": "@scope.namespace.Type.TypeA.md" + "path": "@scope.namespace.TypeAlias.TypeA.md" }, { "title": "TypeB", "kind": 2097152, - "path": "@scope.namespace.Type.TypeB.md" + "path": "@scope.namespace.TypeAlias.TypeB.md" } ] } @@ -1611,12 +2759,12 @@ exports[`Navigation should gets Navigation Json for modules with parts: (Output { "title": "TypeA", "kind": 2097152, - "path": "module-1.submodules.submodule-1.Type.TypeA.md" + "path": "module-1.submodules.submodule-1.TypeAlias.TypeA.md" }, { "title": "TypeB", "kind": 2097152, - "path": "module-1.submodules.submodule-1.Type.TypeB.md" + "path": "module-1.submodules.submodule-1.TypeAlias.TypeB.md" } ] } @@ -1678,12 +2826,12 @@ exports[`Navigation should gets Navigation Json for modules with parts: (Output { "title": "TypeA", "kind": 2097152, - "path": "module-1.submodules.submodule-2.Type.TypeA.md" + "path": "module-1.submodules.submodule-2.TypeAlias.TypeA.md" }, { "title": "TypeB", "kind": 2097152, - "path": "module-1.submodules.submodule-2.Type.TypeB.md" + "path": "module-1.submodules.submodule-2.TypeAlias.TypeB.md" } ] } @@ -1745,12 +2893,12 @@ exports[`Navigation should gets Navigation Json for modules with parts: (Output { "title": "TypeA", "kind": 2097152, - "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Type.TypeA.md" + "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-1.TypeAlias.TypeA.md" }, { "title": "TypeB", "kind": 2097152, - "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Type.TypeB.md" + "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-1.TypeAlias.TypeB.md" } ] } @@ -1812,12 +2960,12 @@ exports[`Navigation should gets Navigation Json for modules with parts: (Output { "title": "TypeA", "kind": 2097152, - "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Type.TypeA.md" + "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-2.TypeAlias.TypeA.md" }, { "title": "TypeB", "kind": 2097152, - "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Type.TypeB.md" + "path": "module-1.submodules.submodule-3-with-modules.nested-submodule-2.TypeAlias.TypeB.md" } ] } @@ -1879,12 +3027,12 @@ exports[`Navigation should gets Navigation Json for modules with parts: (Output { "title": "TypeA", "kind": 2097152, - "path": "module-2.Type.TypeA.md" + "path": "module-2.TypeAlias.TypeA.md" }, { "title": "TypeB", "kind": 2097152, - "path": "module-2.Type.TypeB.md" + "path": "module-2.TypeAlias.TypeB.md" } ] } diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap index e39abd22e..05150ad2a 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap @@ -5,7 +5,7 @@ exports[`Objects And Params should compile basic interface: (Output File Strateg Comments for BasicInterface -## Extended by +## Extended By - [\`ExtendedInterface\`](ExtendedInterface.md) @@ -19,7 +19,7 @@ Comments for BasicInterface This prop is deprecated -#### Some Tag +#### See Comments for some tag @@ -196,7 +196,7 @@ exports[`Objects And Params should compile basic interface: (Output File Strateg Comments for BasicInterface -## Extended by +## Extended By - [\`ExtendedInterface\`](ExtendedInterface.md) @@ -204,7 +204,7 @@ Comments for BasicInterface | Property | Type | Description | | :------ | :------ | :------ | -| ~~\`deprecatedProp\`~~ | \`string\` | **Deprecated** This prop is deprecated **Some Tag** Comments for some tag | +| ~~\`deprecatedProp\`~~ | \`string\` | **Deprecated** This prop is deprecated **See** Comments for some tag | | \`functionProp\` | (\`s\`: \`string\`) => \`boolean\` | Comments for functionProper | | \`optionalProp?\` | \`string\` | Comments for optional prop | | \`prop\` | \`string\` | Comments for prop | @@ -462,7 +462,7 @@ Some nested params. `; exports[`Objects And Params should compile intersection type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: IntersectionType +"# Type Alias: IntersectionType > **IntersectionType**: [\`TupleType\`](TupleType.md) & [\`ArrayType\`](ArrayType.md) & \\{\`bar\`: \`number\`; \\} @@ -477,7 +477,7 @@ Comments for IntersectionType `; exports[`Objects And Params should compile intersection type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: IntersectionType +"# Type Alias: IntersectionType \`\`\`ts type IntersectionType: TupleType & ArrayType & { @@ -498,7 +498,7 @@ bar: number; `; exports[`Objects And Params should compile literal type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: LiteralType +"# Type Alias: LiteralType > **LiteralType**: \\{\`x\`: \`string\`;\`y\`: \\{\`x\`: \`string\`;\`y\`: \`boolean\` \\| \`string\`;\`z\`: (\`x\`: \`string\`) => \`string\`; \\};\`z\`: (\`x\`: \`string\`) => \`string\`;get set \`accessorA\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>;get set \`accessorB\`: \`string\`;\`someFunction\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\>; \\} @@ -603,7 +603,7 @@ Comments for someFunction `; exports[`Objects And Params should compile literal type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: LiteralType +"# Type Alias: LiteralType \`\`\`ts type LiteralType: { @@ -795,7 +795,7 @@ Comments for symbol `; exports[`Objects And Params should compile union type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: UnionType +"# Type Alias: UnionType > **UnionType**: \`string\` \\| \`boolean\` \\| \\{\`z\`: \`string\`; \\} @@ -804,7 +804,7 @@ Comments for UnionType `; exports[`Objects And Params should compile union type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: UnionType +"# Type Alias: UnionType \`\`\`ts type UnionType: string | boolean | { diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.class.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.class.spec.ts.snap index 174cf1f25..1f71999e8 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.class.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.class.spec.ts.snap @@ -3,7 +3,7 @@ exports[`Class Reflection should compile abstract class: (Output File Strategy "members") (Option Group "1") 1`] = ` "# Class: \`abstract\` AbstractClass -## Extended by +## Extended By - [\`DerivedClassA\`](DerivedClassA.md) - [\`DerivedClassB\`](DerivedClassB.md) @@ -51,7 +51,7 @@ Comments for abstractMethod exports[`Class Reflection should compile abstract class: (Output File Strategy "members") (Option Group "2") 1`] = ` "# Class: \`abstract\` AbstractClass -## Extended by +## Extended By - [\`DerivedClassA\`](DerivedClassA.md) - [\`DerivedClassB\`](DerivedClassB.md) @@ -418,7 +418,7 @@ new ClassWithComplexProps(): ClassWithComplexProps ## Properties -| Property | Type | Default value | +| Property | Type | Default Value | | :------ | :------ | :------ | | \`objecLiteralProp\` | \`object\` | \`...\` | | \`objecLiteralProp.someFunction\` | (\`a\`: \`string\`) => \`string\` | \`...\` | @@ -699,8 +699,6 @@ exports[`Class Reflection should compile class with modifiers: (Output File Stra Comments for ClassWithModifiers -## Modifiers - ## Constructors ### new ClassWithModifiers() @@ -826,8 +824,6 @@ exports[`Class Reflection should compile class with modifiers: (Output File Stra Comments for ClassWithModifiers -## Modifiers - ## Constructors ### new ClassWithModifiers() @@ -842,7 +838,7 @@ new ClassWithModifiers(): ClassWithModifiers ## Properties -| Property | Modifier | Type | Default value | Description | +| Property | Modifier | Type | Default Value | Description | | :------ | :------ | :------ | :------ | :------ | | \`privateProp\` | \`private\` | \`string\` | \`undefined\` | Comments for privateProp | | \`protectedProp\` | \`protected\` | \`string\` | \`undefined\` | Comments for protectedProp | @@ -978,10 +974,6 @@ on two lines Comments for propE -#### Tag - -SomeTag - #### Source [classes.ts:1](http://source-url) @@ -1007,12 +999,12 @@ new ClassWithSimpleProps(): ClassWithSimpleProps ## Properties -| Property | Type | Default value | Description | +| Property | Type | Default Value | Description | | :------ | :------ | :------ | :------ | | \`propA\` | \`string\` | \`'propAValue'\` | Comments for propA | | \`propB\` | \`string\` | \`'propBDefaultValue'\` | Comments for propB | | \`propC\` | \`string\` | \`'propCDefaultValue'\` | Comments for propB on two lines | -| \`propD\` | \`string\` | \`undefined\` | Comments for propE **Tag** SomeTag | +| \`propD\` | \`string\` | \`undefined\` | Comments for propE | " `; @@ -1045,7 +1037,7 @@ exports[`Class Reflection should compile class with symbols: (Output File Strate ## Methods -### \`[dispose]\`() +### \\[dispose\\]() > **\\[dispose\\]**(): \`void\` @@ -1064,7 +1056,7 @@ exports[`Class Reflection should compile class with type parameters: (Output Fil Comments for ClassWithTypeParameters -## Type parameters +## Type Parameters • **A** @@ -1093,9 +1085,9 @@ exports[`Class Reflection should compile class with type parameters: (Output Fil Comments for ClassWithTypeParameters -## Type parameters +## Type Parameters -| Type parameter | Value | Description | +| Type Parameter | Value | Description | | :------ | :------ | :------ | | \`A\` | - | Comments for param A | | \`B\` *extends* \`string\` | - | Comments for param B | @@ -1227,7 +1219,7 @@ new DerivedClassA(): DerivedClassA ## Properties -| Property | Type | Default value | Description | Overrides | +| Property | Type | Default Value | Description | Overrides | | :------ | :------ | :------ | :------ | :------ | | \`abstractProp\` | \`string\` | \`'abstractProp'\` | Comments for abstractProp | [\`AbstractClass\`](AbstractClass.md).\`abstractProp\` | | \`derivedProp\` | \`string\` | \`undefined\` | - | - | @@ -1291,7 +1283,7 @@ exports[`Class Reflection should compile disposable class: (Output File Strategy ## Methods -### \`[dispose]\`() +### \\[dispose\\]() > **\\[dispose\\]**(): \`void\` @@ -1312,7 +1304,7 @@ exports[`Class Reflection should compile disposable class: (Output File Strategy exports[`Class Reflection should compile hierarchy for BaseClass: (Output File Strategy "members") (Option Group "1") 1`] = ` "# Class: BaseClass -## Extended by +## Extended By - [\`ChildClassA\`](ChildClassA.md) - [\`ChildClassB\`](ChildClassB.md) @@ -1336,7 +1328,7 @@ exports[`Class Reflection should compile hierarchy for ChildClassA: (Output File - [\`BaseClass\`](BaseClass.md) -## Extended by +## Extended By - [\`GrandChildClassA\`](GrandChildClassA.md) - [\`GrandChildClassB\`](GrandChildClassB.md) diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap index c8f01f42b..0fe1fe726 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap @@ -11,7 +11,7 @@ Comments for function \`Function\` -### Type parameters +### Type Parameters • **T** @@ -42,9 +42,9 @@ Comments for function \`Function\` -### Type parameters +### Type Parameters -| Type parameter | +| Type Parameter | | :------ | | \`T\` | @@ -415,7 +415,7 @@ This is a function with a parameter that has a default value. ## Parameters -| Parameter | Type | Default value | Description | +| Parameter | Type | Default Value | Description | | :------ | :------ | :------ | :------ | | \`valueA\` | \`string\` | \`'defaultValue'\` | A parameter with a default string value. | | \`valueB\` | \`number\` | \`100\` | A parameter with a default numeric value. | @@ -437,6 +437,8 @@ This is a function with a parameter that has a default value. exports[`Function Reflection should compile function with multiple signatures: (Output File Strategy "members") (Option Group "1") 1`] = ` "# Function: functionWithMultipleSignatures() +Main function comment. + ## functionWithMultipleSignatures(value) > **functionWithMultipleSignatures**(\`value\`): \`string\` @@ -486,6 +488,8 @@ A value of the object. exports[`Function Reflection should compile function with multiple signatures: (Output File Strategy "members") (Option Group "2") 1`] = ` "# Function: functionWithMultipleSignatures() +Main function comment. + ## functionWithMultipleSignatures(value) \`\`\`ts @@ -749,7 +753,7 @@ This is a function with a parameters. ## Parameters -| Parameter | Type | Default value | Description | +| Parameter | Type | Default Value | Description | | :------ | :------ | :------ | :------ | | \`firstParamWithDefault\` | \`boolean\` | \`true\` | - | | \`requiredParam\` | \`string\` | \`undefined\` | A normal parameter. | @@ -781,7 +785,7 @@ This is a function with a parameters. ## Parameters -| Parameter | Type | Default value | Description | +| Parameter | Type | Default Value | Description | | :------ | :------ | :------ | :------ | | \`firstParamWithDefault\` | \`boolean\` | \`true\` | - | | \`requiredParam\` | \`string\` | \`undefined\` | A normal parameter. | @@ -854,7 +858,7 @@ exports[`Function Reflection should compile function with type parameters: (Outp Function with type parameters -## Type parameters +## Type Parameters • **T** @@ -881,9 +885,9 @@ function functionWithTypeParameters(): boolean Function with type parameters -## Type parameters +## Type Parameters -| Type parameter | Value | Description | +| Type Parameter | Value | Description | | :------ | :------ | :------ | | \`T\` | - | Comments for T | | \`Item\` | \`string\` \\| \`boolean\` | - | diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.interface.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.interface.spec.ts.snap index a2cfd0ad4..0378b01da 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.interface.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.interface.spec.ts.snap @@ -5,7 +5,7 @@ exports[`Interface Reflection should compile basic interface: (Output File Strat Comments for BasicInterface -## Extended by +## Extended By - [\`ExtendedInterface\`](ExtendedInterface.md) @@ -19,7 +19,7 @@ Comments for BasicInterface This prop is deprecated -#### Some Tag +#### See Comments for some tag @@ -236,7 +236,7 @@ exports[`Interface Reflection should compile basic interface: (Output File Strat Comments for BasicInterface -## Extended by +## Extended By - [\`ExtendedInterface\`](ExtendedInterface.md) @@ -244,7 +244,7 @@ Comments for BasicInterface | Property | Type | Description | | :------ | :------ | :------ | -| ~~\`deprecatedProp\`~~ | \`string\` | **Deprecated** This prop is deprecated **Some Tag** Comments for some tag | +| ~~\`deprecatedProp\`~~ | \`string\` | **Deprecated** This prop is deprecated **See** Comments for some tag | | \`functionProp\` | (\`s\`: \`string\`) => \`boolean\` | Comments for functionProper | | \`optionalProp?\` | \`string\` | Comments for optional prop | | \`prop\` | \`string\` | Comments for prop | @@ -284,7 +284,7 @@ Comments for ExtendedInterface This prop is deprecated -#### Some Tag +#### See Comments for some tag @@ -559,7 +559,7 @@ Comments for ExtendedInterface | Property | Type | Description | Inherited from | | :------ | :------ | :------ | :------ | -| ~~\`deprecatedProp\`~~ | \`string\` | **Deprecated** This prop is deprecated **Some Tag** Comments for some tag | [\`BasicInterface\`](BasicInterface.md).\`deprecatedProp\` | +| ~~\`deprecatedProp\`~~ | \`string\` | **Deprecated** This prop is deprecated **See** Comments for some tag | [\`BasicInterface\`](BasicInterface.md).\`deprecatedProp\` | | \`extendedProp\` | \`string\` | - | - | | \`functionProp\` | (\`s\`: \`string\`) => \`boolean\` | Comments for functionProper | [\`BasicInterface\`](BasicInterface.md).\`functionProp\` | | \`optionalProp?\` | \`string\` | Comments for optional prop | [\`BasicInterface\`](BasicInterface.md).\`optionalProp\` | @@ -627,7 +627,7 @@ over two lines And some more comments -## Type parameters +## Type Parameters • **A** @@ -686,9 +686,9 @@ over two lines And some more comments -## Type parameters +## Type Parameters -| Type parameter | Description | +| Type Parameter | Description | | :------ | :------ | | \`A\` | This is a parameter. | | \`B\` | Comments for a parameter. This sentence is on a soft new line. | @@ -824,7 +824,7 @@ exports[`Interface Reflection should compile interface with type parameters: (Ou Comments for InterfaceWithTypeParameters -## Type parameters +## Type Parameters • **A** @@ -847,9 +847,9 @@ exports[`Interface Reflection should compile interface with type parameters: (Ou Comments for InterfaceWithTypeParameters -## Type parameters +## Type Parameters -| Type parameter | +| Type Parameter | | :------ | | \`A\` | diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap index f40dcbcbf..904afb9e6 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Type Alias Reflection should compile array type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: ArrayType +"# Type Alias: ArrayType > **ArrayType**: \`string\`[] @@ -14,7 +14,7 @@ Comments for ArrayType `; exports[`Type Alias Reflection should compile array type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: ArrayType +"# Type Alias: ArrayType \`\`\`ts type ArrayType: string[]; @@ -29,13 +29,13 @@ Comments for ArrayType `; exports[`Type Alias Reflection should compile conditional type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: ConditionalType\\ +"# Type Alias: ConditionalType\\ > **ConditionalType**\\<\`T\`\\>: \`T\` *extends* \`string\` ? \`"string"\` : \`T\` *extends* \`number\` ? \`"number"\` : \`T\` *extends* \`boolean\` ? \`"boolean"\` : \`T\` *extends* \`undefined\` ? \`"undefined"\` : \`"object"\` Comments for ConditionalType -## Type parameters +## Type Parameters • **T** @@ -46,7 +46,7 @@ Comments for ConditionalType `; exports[`Type Alias Reflection should compile conditional type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: ConditionalType\\ +"# Type Alias: ConditionalType\\ \`\`\`ts type ConditionalType: T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends undefined ? "undefined" : "object"; @@ -54,9 +54,9 @@ type ConditionalType: T extends string ? "string" : T extends number ? "numbe Comments for ConditionalType -## Type parameters +## Type Parameters -| Type parameter | +| Type Parameter | | :------ | | \`T\` | @@ -67,7 +67,7 @@ Comments for ConditionalType `; exports[`Type Alias Reflection should compile external link symbol type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: TypeWithExternalSymbolLinkMapping +"# Type Alias: TypeWithExternalSymbolLinkMapping > **TypeWithExternalSymbolLinkMapping**: [\`Application\`](https://typedoc.org/api/classes/Application.html) @@ -80,7 +80,7 @@ Comments for TypeWithExternalSymbolLinkMapping `; exports[`Type Alias Reflection should compile external link symbol type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: TypeWithExternalSymbolLinkMapping +"# Type Alias: TypeWithExternalSymbolLinkMapping \`\`\`ts type TypeWithExternalSymbolLinkMapping: Application; @@ -95,7 +95,7 @@ Comments for TypeWithExternalSymbolLinkMapping `; exports[`Type Alias Reflection should compile external literal type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: LiteralType +"# Type Alias: LiteralType > **LiteralType**: \`object\` @@ -204,7 +204,7 @@ Comments for someFunction `; exports[`Type Alias Reflection should compile external literal type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: LiteralType +"# Type Alias: LiteralType \`\`\`ts type LiteralType: object; @@ -235,7 +235,7 @@ Comments for LiteralType `; exports[`Type Alias Reflection should compile external reference type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: ExternalReferenceType +"# Type Alias: ExternalReferenceType > **ExternalReferenceType**: [\`ClassWithTypeParameters\`](../classes/ClassWithTypeParameters.md)\\<\`"x"\`, \`"y"\`\\> @@ -248,7 +248,7 @@ Comments for ExternalReferenceType `; exports[`Type Alias Reflection should compile external reference type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: ExternalReferenceType +"# Type Alias: ExternalReferenceType \`\`\`ts type ExternalReferenceType: ClassWithTypeParameters<"x", "y">; @@ -263,7 +263,7 @@ Comments for ExternalReferenceType `; exports[`Type Alias Reflection should compile function type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: FunctionType() +"# Type Alias: FunctionType() > **FunctionType**: (\`name\`, \`value\`) => \`void\` @@ -286,7 +286,7 @@ Comments for FunctionType `; exports[`Type Alias Reflection should compile function type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: FunctionType() +"# Type Alias: FunctionType() \`\`\`ts type FunctionType: (name: string, value: unknown) => void; @@ -312,7 +312,7 @@ Comments for FunctionType `; exports[`Type Alias Reflection should compile index access type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: IndexAccessType +"# Type Alias: IndexAccessType > **IndexAccessType**: [\`ArrayOfStuff\`](ArrayOfStuff.md)\\[\`number\`\\] @@ -325,7 +325,7 @@ Comments for IndexAccessType `; exports[`Type Alias Reflection should compile index access type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: IndexAccessType +"# Type Alias: IndexAccessType \`\`\`ts type IndexAccessType: ArrayOfStuff[number]; @@ -340,7 +340,7 @@ Comments for IndexAccessType `; exports[`Type Alias Reflection should compile intersection type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: IntersectionType +"# Type Alias: IntersectionType > **IntersectionType**: [\`TupleType\`](TupleType.md) & [\`ArrayType\`](ArrayType.md) & \`object\` @@ -359,7 +359,7 @@ Comments for IntersectionType `; exports[`Type Alias Reflection should compile intersection type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: IntersectionType +"# Type Alias: IntersectionType \`\`\`ts type IntersectionType: TupleType & ArrayType & object; @@ -380,13 +380,13 @@ Comments for IntersectionType `; exports[`Type Alias Reflection should compile partial mapped type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: PartialMappedType\\ +"# Type Alias: PartialMappedType\\ > **PartialMappedType**\\<\`T\`\\>: \`{ [P in keyof T]?: T[P] }\` Comments for PartialMappedType -## Type parameters +## Type Parameters • **T** @@ -397,7 +397,7 @@ Comments for PartialMappedType `; exports[`Type Alias Reflection should compile partial mapped type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: PartialMappedType\\ +"# Type Alias: PartialMappedType\\ \`\`\`ts type PartialMappedType: { [P in keyof T]?: T[P] }; @@ -405,9 +405,9 @@ type PartialMappedType: { [P in keyof T]?: T[P] }; Comments for PartialMappedType -## Type parameters +## Type Parameters -| Type parameter | +| Type Parameter | | :------ | | \`T\` | @@ -418,7 +418,7 @@ Comments for PartialMappedType `; exports[`Type Alias Reflection should compile primitive type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: PrimitiveType +"# Type Alias: PrimitiveType > **PrimitiveType**: \`boolean\` @@ -431,7 +431,7 @@ Comments for PrimitiveType `; exports[`Type Alias Reflection should compile primitive type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: PrimitiveType +"# Type Alias: PrimitiveType \`\`\`ts type PrimitiveType: boolean; @@ -446,7 +446,7 @@ Comments for PrimitiveType `; exports[`Type Alias Reflection should compile query type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: QueryType +"# Type Alias: QueryType > **QueryType**: *typeof* [\`someQuery\`](../variables/someQuery.md) @@ -459,7 +459,7 @@ Comments for query type `; exports[`Type Alias Reflection should compile query type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: QueryType +"# Type Alias: QueryType \`\`\`ts type QueryType: typeof someQuery; @@ -474,13 +474,13 @@ Comments for query type `; exports[`Type Alias Reflection should compile readonly mapped type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: ReadonlyMappedType\\ +"# Type Alias: ReadonlyMappedType\\ > **ReadonlyMappedType**\\<\`T\`\\>: \`{ readonly [P in keyof T]: T[P] }\` Comments for ReadonlyMapedType -## Type parameters +## Type Parameters • **T** @@ -491,7 +491,7 @@ Comments for ReadonlyMapedType `; exports[`Type Alias Reflection should compile readonly mapped type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: ReadonlyMappedType\\ +"# Type Alias: ReadonlyMappedType\\ \`\`\`ts type ReadonlyMappedType: { readonly [P in keyof T]: T[P] }; @@ -499,9 +499,9 @@ type ReadonlyMappedType: { readonly [P in keyof T]: T[P] }; Comments for ReadonlyMapedType -## Type parameters +## Type Parameters -| Type parameter | +| Type Parameter | | :------ | | \`T\` | @@ -512,7 +512,7 @@ Comments for ReadonlyMapedType `; exports[`Type Alias Reflection should compile string literal type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: StringLiteralType +"# Type Alias: StringLiteralType > **StringLiteralType**: \`" "\` \\| \`"string"\` \\| "string\\|with\\|pipes" \\| "string\\\`with\\\`backticks" \\| \`""\` \\| \`"*"\` @@ -525,7 +525,7 @@ Comments for StringLiteralType `; exports[`Type Alias Reflection should compile string literal type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: StringLiteralType +"# Type Alias: StringLiteralType \`\`\`ts type StringLiteralType: @@ -546,7 +546,7 @@ Comments for StringLiteralType `; exports[`Type Alias Reflection should compile string tuple type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: TupleType +"# Type Alias: TupleType > **TupleType**: [\`string\`, \`number\`] @@ -559,7 +559,7 @@ Comments for TupleType `; exports[`Type Alias Reflection should compile string tuple type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: TupleType +"# Type Alias: TupleType \`\`\`ts type TupleType: [string, number]; @@ -574,13 +574,13 @@ Comments for TupleType `; exports[`Type Alias Reflection should compile type parameter type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: TypeWithTypeParams\\ +"# Type Alias: TypeWithTypeParams\\ > **TypeWithTypeParams**\\<\`T\`, \`R\`\\>: [\`T\`, \`R\`] Comments for TypeWithTypeParams -## Type parameters +## Type Parameters • **T** @@ -593,7 +593,7 @@ Comments for TypeWithTypeParams `; exports[`Type Alias Reflection should compile type parameter type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: TypeWithTypeParams\\ +"# Type Alias: TypeWithTypeParams\\ \`\`\`ts type TypeWithTypeParams: [T, R]; @@ -601,9 +601,9 @@ type TypeWithTypeParams: [T, R]; Comments for TypeWithTypeParams -## Type parameters +## Type Parameters -| Type parameter | +| Type Parameter | | :------ | | \`T\` | | \`R\` | @@ -615,7 +615,7 @@ Comments for TypeWithTypeParams `; exports[`Type Alias Reflection should compile union type with template strings: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: UnionTypeWithTemplateStrings +"# Type Alias: UnionTypeWithTemplateStrings > **UnionTypeWithTemplateStrings**: \\\`v$\\{number\\}\\\` \\| \\\`v$\\{number\\}.$\\{number\\}\\\` \\| \\\`v$\\{number\\}.$\\{number\\}.$\\{number\\}\\\` @@ -628,7 +628,7 @@ Union with template strings `; exports[`Type Alias Reflection should compile union type with template strings: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: UnionTypeWithTemplateStrings +"# Type Alias: UnionTypeWithTemplateStrings \`\`\`ts type UnionTypeWithTemplateStrings: \`v\${number}\` | \`v\${number}.\${number}\` | \`v\${number}.\${number}.\${number}\`; @@ -643,7 +643,7 @@ Union with template strings `; exports[`Type Alias Reflection should compile union type: (Output File Strategy "members") (Option Group "1") 1`] = ` -"# Type alias: UnionType +"# Type Alias: UnionType > **UnionType**: \`string\` \\| \`boolean\` \\| \`object\` @@ -656,7 +656,7 @@ Comments for UnionType `; exports[`Type Alias Reflection should compile union type: (Output File Strategy "members") (Option Group "2") 1`] = ` -"# Type alias: UnionType +"# Type Alias: UnionType \`\`\`ts type UnionType: string | boolean | object; diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap index ff1894b9f..fae1e209b 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap @@ -33,9 +33,9 @@ exports[`Text should get translations for member page: (Output File Strategy "me | :------ | :------ | :------ | | \`someProp?\` | \`boolean\` | Description for prop someProp | -## My Events +## Events -| Event! | Type | +| Event | Type | | :------ | :------ | | \`someEvent\` | \`MouseEvent\` | @@ -52,11 +52,11 @@ exports[`Text should get translations for module page: (Output File Strategy "me [typedoc-stubs v0.0](../modules.md) / module-1 -# Module - module-1 +# module-1 - module-1 ## Index -### 多变的 +### Interfaces - [SomeInterface](interfaces/SomeInterface.md) @@ -73,9 +73,9 @@ exports[`Text should get translations for modules page: (Output File Strategy "m [typedoc-stubs v0.0](modules.md) / module-2 -# Module - module-2 +# module-2 - module-2 -## CoolVars +## Variables ### constA @@ -95,7 +95,7 @@ exports[`Text should get translations for sidebar: (Output File Strategy "member "path": "module-1/README.md", "children": [ { - "title": "多变的", + "title": "Interfaces", "children": [ { "title": "SomeInterface", @@ -112,7 +112,7 @@ exports[`Text should get translations for sidebar: (Output File Strategy "member "path": "module-2/README.md", "children": [ { - "title": "CoolVars", + "title": "Variables", "children": [ { "title": "constA", diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap index ce87a0168..af5023229 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap @@ -1,5 +1,232 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Urls should gets Urls for documents multi modules: outputFileStrategy: members 1`] = ` +[ + "ModuleWithDocuments1/README.md", + "ModuleWithDocuments1/classes/ClassWithDocuments.md", + "ModuleWithDocuments1/classes/documents/CLASS_DOC.md", + "ModuleWithDocuments1/documents/MODULE_DOC.md", + "ModuleWithDocuments1/enumerations/EnumWithDocuments.md", + "ModuleWithDocuments1/enumerations/documents/ENUM_DOC.md", + "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_1.md", + "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_2.md", + "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_3.md", + "ModuleWithDocuments1/functions/functionWithDocuments.md", + "ModuleWithDocuments1/functions/multipleFunctionWithDocuments.md", + "ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md", + "ModuleWithDocuments1/interfaces/documents/INTERFACE_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/NamespaceClassWithDocuments.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/documents/CLASS_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md", + "ModuleWithDocuments1/type-aliases/TypeWithDocuments.md", + "ModuleWithDocuments1/type-aliases/documents/TYPE_DOC.md", + "ModuleWithDocuments1/variables/documents/VARIABLE_DOC.md", + "ModuleWithDocuments1/variables/variableWithDocuments.md", + "ModuleWithDocuments2/README.md", + "ModuleWithDocuments2/classes/ClassWithDocuments.md", + "ModuleWithDocuments2/classes/documents/CLASS_DOC.md", + "ModuleWithDocuments2/documents/MODULE_DOC.md", + "ModuleWithDocuments2/enumerations/EnumWithDocuments.md", + "ModuleWithDocuments2/enumerations/documents/ENUM_DOC.md", + "ModuleWithDocuments2/functions/documents/FUNCTION_DOC_1.md", + "ModuleWithDocuments2/functions/documents/FUNCTION_DOC_2.md", + "ModuleWithDocuments2/functions/documents/FUNCTION_DOC_3.md", + "ModuleWithDocuments2/functions/functionWithDocuments.md", + "ModuleWithDocuments2/functions/multipleFunctionWithDocuments.md", + "ModuleWithDocuments2/interfaces/InterfaceWithDocuments.md", + "ModuleWithDocuments2/interfaces/documents/INTERFACE_DOC.md", + "ModuleWithDocuments2/type-aliases/TypeWithDocuments.md", + "ModuleWithDocuments2/type-aliases/documents/TYPE_DOC.md", + "ModuleWithDocuments2/variables/documents/VARIABLE_DOC.md", + "ModuleWithDocuments2/variables/variableWithDocuments.md", + "README.md", + "documents/Project-Document-1.md", + "documents/docs/project/PROJECT_DOC_2.md", + "documents/docs/project/PROJECT_DOC_3.md", +] +`; + +exports[`Urls should gets Urls for documents multi modules: outputFileStrategy: members 2`] = ` +[ + "Document.Project-Document-1.md", + "Document.docs.project.PROJECT_DOC_2.md", + "Document.docs.project.PROJECT_DOC_3.md", + "ModuleWithDocuments1.Class.ClassWithDocuments.md", + "ModuleWithDocuments1.ClassWithDocuments.Document.CLASS_DOC.md", + "ModuleWithDocuments1.Document.MODULE_DOC.md", + "ModuleWithDocuments1.EnumWithDocuments.Document.ENUM_DOC.md", + "ModuleWithDocuments1.Enumeration.EnumWithDocuments.md", + "ModuleWithDocuments1.Function.functionWithDocuments.md", + "ModuleWithDocuments1.Function.multipleFunctionWithDocuments.md", + "ModuleWithDocuments1.Interface.InterfaceWithDocuments.md", + "ModuleWithDocuments1.InterfaceWithDocuments.Document.INTERFACE_DOC.md", + "ModuleWithDocuments1.Namespace.NamespaceWithDocuments.md", + "ModuleWithDocuments1.NamespaceWithDocuments.Class.NamespaceClassWithDocuments.md", + "ModuleWithDocuments1.NamespaceWithDocuments.Document.NAMESPACE_DOC.md", + "ModuleWithDocuments1.NamespaceWithDocuments.NamespaceClassWithDocuments.Document.CLASS_DOC.md", + "ModuleWithDocuments1.TypeAlias.TypeWithDocuments.md", + "ModuleWithDocuments1.TypeWithDocuments.Document.TYPE_DOC.md", + "ModuleWithDocuments1.Variable.variableWithDocuments.md", + "ModuleWithDocuments1.functionWithDocuments.Document.FUNCTION_DOC_1.md", + "ModuleWithDocuments1.md", + "ModuleWithDocuments1.multipleFunctionWithDocuments.Document.FUNCTION_DOC_1.md", + "ModuleWithDocuments1.multipleFunctionWithDocuments.Document.FUNCTION_DOC_2.md", + "ModuleWithDocuments1.multipleFunctionWithDocuments.Document.FUNCTION_DOC_3.md", + "ModuleWithDocuments1.variableWithDocuments.Document.VARIABLE_DOC.md", + "ModuleWithDocuments2.Class.ClassWithDocuments.md", + "ModuleWithDocuments2.ClassWithDocuments.Document.CLASS_DOC.md", + "ModuleWithDocuments2.Document.MODULE_DOC.md", + "ModuleWithDocuments2.EnumWithDocuments.Document.ENUM_DOC.md", + "ModuleWithDocuments2.Enumeration.EnumWithDocuments.md", + "ModuleWithDocuments2.Function.functionWithDocuments.md", + "ModuleWithDocuments2.Function.multipleFunctionWithDocuments.md", + "ModuleWithDocuments2.Interface.InterfaceWithDocuments.md", + "ModuleWithDocuments2.InterfaceWithDocuments.Document.INTERFACE_DOC.md", + "ModuleWithDocuments2.TypeAlias.TypeWithDocuments.md", + "ModuleWithDocuments2.TypeWithDocuments.Document.TYPE_DOC.md", + "ModuleWithDocuments2.Variable.variableWithDocuments.md", + "ModuleWithDocuments2.functionWithDocuments.Document.FUNCTION_DOC_1.md", + "ModuleWithDocuments2.md", + "ModuleWithDocuments2.multipleFunctionWithDocuments.Document.FUNCTION_DOC_1.md", + "ModuleWithDocuments2.multipleFunctionWithDocuments.Document.FUNCTION_DOC_2.md", + "ModuleWithDocuments2.multipleFunctionWithDocuments.Document.FUNCTION_DOC_3.md", + "ModuleWithDocuments2.variableWithDocuments.Document.VARIABLE_DOC.md", + "README.md", +] +`; + +exports[`Urls should gets Urls for documents multi modules: outputFileStrategy: modules 1`] = ` +[ + "ModuleWithDocuments1/README.md", + "ModuleWithDocuments1/documents/Class.CLASS_DOC.md", + "ModuleWithDocuments1/documents/Enumeration.ENUM_DOC.md", + "ModuleWithDocuments1/documents/Function.FUNCTION_DOC_1.md", + "ModuleWithDocuments1/documents/Function.FUNCTION_DOC_2.md", + "ModuleWithDocuments1/documents/Function.FUNCTION_DOC_3.md", + "ModuleWithDocuments1/documents/Interface.INTERFACE_DOC.md", + "ModuleWithDocuments1/documents/MODULE_DOC.md", + "ModuleWithDocuments1/documents/TypeAlias.TYPE_DOC.md", + "ModuleWithDocuments1/documents/Variable.VARIABLE_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/Class.CLASS_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md", + "ModuleWithDocuments2/README.md", + "ModuleWithDocuments2/documents/Class.CLASS_DOC.md", + "ModuleWithDocuments2/documents/Enumeration.ENUM_DOC.md", + "ModuleWithDocuments2/documents/Function.FUNCTION_DOC_1.md", + "ModuleWithDocuments2/documents/Function.FUNCTION_DOC_2.md", + "ModuleWithDocuments2/documents/Function.FUNCTION_DOC_3.md", + "ModuleWithDocuments2/documents/Interface.INTERFACE_DOC.md", + "ModuleWithDocuments2/documents/MODULE_DOC.md", + "ModuleWithDocuments2/documents/TypeAlias.TYPE_DOC.md", + "ModuleWithDocuments2/documents/Variable.VARIABLE_DOC.md", + "README.md", + "documents/Project-Document-1.md", + "documents/docs/project/PROJECT_DOC_2.md", + "documents/docs/project/PROJECT_DOC_3.md", +] +`; + +exports[`Urls should gets Urls for documents multi modules: outputFileStrategy: modules 2`] = ` +[ + "Document.Class.CLASS_DOC.md", + "Document.Enumeration.ENUM_DOC.md", + "Document.Function.FUNCTION_DOC_1.md", + "Document.Function.FUNCTION_DOC_2.md", + "Document.Function.FUNCTION_DOC_3.md", + "Document.Interface.INTERFACE_DOC.md", + "Document.Project-Document-1.md", + "Document.TypeAlias.TYPE_DOC.md", + "Document.Variable.VARIABLE_DOC.md", + "Document.docs.project.PROJECT_DOC_2.md", + "Document.docs.project.PROJECT_DOC_3.md", + "ModuleWithDocuments1.Document.MODULE_DOC.md", + "ModuleWithDocuments1.Namespace.NamespaceWithDocuments.md", + "ModuleWithDocuments1.NamespaceWithDocuments.Document.NAMESPACE_DOC.md", + "ModuleWithDocuments1.md", + "ModuleWithDocuments2.Document.MODULE_DOC.md", + "ModuleWithDocuments2.md", + "README.md", +] +`; + +exports[`Urls should gets Urls for documents single module: outputFileStrategy: members 1`] = ` +[ + "ModuleWithDocuments1/README.md", + "ModuleWithDocuments1/classes/ClassWithDocuments.md", + "ModuleWithDocuments1/classes/documents/CLASS_DOC.md", + "ModuleWithDocuments1/documents/MODULE_DOC.md", + "ModuleWithDocuments1/enumerations/EnumWithDocuments.md", + "ModuleWithDocuments1/enumerations/documents/ENUM_DOC.md", + "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_1.md", + "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_2.md", + "ModuleWithDocuments1/functions/documents/FUNCTION_DOC_3.md", + "ModuleWithDocuments1/functions/functionWithDocuments.md", + "ModuleWithDocuments1/functions/multipleFunctionWithDocuments.md", + "ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md", + "ModuleWithDocuments1/interfaces/documents/INTERFACE_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/NamespaceClassWithDocuments.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/documents/CLASS_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md", + "ModuleWithDocuments1/type-aliases/TypeWithDocuments.md", + "ModuleWithDocuments1/type-aliases/documents/TYPE_DOC.md", + "ModuleWithDocuments1/variables/documents/VARIABLE_DOC.md", + "ModuleWithDocuments1/variables/variableWithDocuments.md", + "README.md", + "documents/Project-Document-1.md", + "documents/docs/project/PROJECT_DOC_2.md", + "documents/docs/project/PROJECT_DOC_3.md", +] +`; + +exports[`Urls should gets Urls for documents single module: outputFileStrategy: members 2`] = ` +[ + "ModuleWithDocuments1/README.md", + "ModuleWithDocuments1/classes/ClassWithDocuments.md", + "ModuleWithDocuments1/enumerations/EnumWithDocuments.md", + "ModuleWithDocuments1/functions/functionWithDocuments.md", + "ModuleWithDocuments1/functions/multipleFunctionWithDocuments.md", + "ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/classes/NamespaceClassWithDocuments.md", + "ModuleWithDocuments1/type-aliases/TypeWithDocuments.md", + "ModuleWithDocuments1/variables/variableWithDocuments.md", + "README.md", +] +`; + +exports[`Urls should gets Urls for documents single module: outputFileStrategy: modules 1`] = ` +[ + "ModuleWithDocuments1/README.md", + "ModuleWithDocuments1/documents/Class.CLASS_DOC.md", + "ModuleWithDocuments1/documents/Enumeration.ENUM_DOC.md", + "ModuleWithDocuments1/documents/Function.FUNCTION_DOC_1.md", + "ModuleWithDocuments1/documents/Function.FUNCTION_DOC_2.md", + "ModuleWithDocuments1/documents/Function.FUNCTION_DOC_3.md", + "ModuleWithDocuments1/documents/Interface.INTERFACE_DOC.md", + "ModuleWithDocuments1/documents/MODULE_DOC.md", + "ModuleWithDocuments1/documents/TypeAlias.TYPE_DOC.md", + "ModuleWithDocuments1/documents/Variable.VARIABLE_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/Class.CLASS_DOC.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/documents/NAMESPACE_DOC.md", + "README.md", + "documents/Project-Document-1.md", + "documents/docs/project/PROJECT_DOC_2.md", + "documents/docs/project/PROJECT_DOC_3.md", +] +`; + +exports[`Urls should gets Urls for documents single module: outputFileStrategy: modules 2`] = ` +[ + "ModuleWithDocuments1/README.md", + "ModuleWithDocuments1/namespaces/NamespaceWithDocuments/README.md", + "README.md", +] +`; + exports[`Urls should gets Urls for entry module: outputFileStrategy: members 1`] = ` [ "@scope/module-1/README.mdx", @@ -110,8 +337,8 @@ exports[`Urls should gets Urls for modules parts: outputFileStrategy: members 2` "@scope.namespace.Enumeration.EnumB.md", "@scope.namespace.Interface.InterfaceA.md", "@scope.namespace.Interface.InterfaceB.md", - "@scope.namespace.Type.TypeA.md", - "@scope.namespace.Type.TypeB.md", + "@scope.namespace.TypeAlias.TypeA.md", + "@scope.namespace.TypeAlias.TypeB.md", "@scope.namespace.md", "README.md", "Test.Module.Name.Interface.InterfaceA.md", @@ -122,8 +349,8 @@ exports[`Urls should gets Urls for modules parts: outputFileStrategy: members 2` "module-1.submodules.submodule-1.Enumeration.EnumB.md", "module-1.submodules.submodule-1.Interface.InterfaceA.md", "module-1.submodules.submodule-1.Interface.InterfaceB.md", - "module-1.submodules.submodule-1.Type.TypeA.md", - "module-1.submodules.submodule-1.Type.TypeB.md", + "module-1.submodules.submodule-1.TypeAlias.TypeA.md", + "module-1.submodules.submodule-1.TypeAlias.TypeB.md", "module-1.submodules.submodule-1.md", "module-1.submodules.submodule-2.Class.ClassA.md", "module-1.submodules.submodule-2.Class.ClassB.md", @@ -131,8 +358,8 @@ exports[`Urls should gets Urls for modules parts: outputFileStrategy: members 2` "module-1.submodules.submodule-2.Enumeration.EnumB.md", "module-1.submodules.submodule-2.Interface.InterfaceA.md", "module-1.submodules.submodule-2.Interface.InterfaceB.md", - "module-1.submodules.submodule-2.Type.TypeA.md", - "module-1.submodules.submodule-2.Type.TypeB.md", + "module-1.submodules.submodule-2.TypeAlias.TypeA.md", + "module-1.submodules.submodule-2.TypeAlias.TypeB.md", "module-1.submodules.submodule-2.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Class.ClassA.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Class.ClassB.md", @@ -140,8 +367,8 @@ exports[`Urls should gets Urls for modules parts: outputFileStrategy: members 2` "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Enumeration.EnumB.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Interface.InterfaceA.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Interface.InterfaceB.md", - "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Type.TypeA.md", - "module-1.submodules.submodule-3-with-modules.nested-submodule-1.Type.TypeB.md", + "module-1.submodules.submodule-3-with-modules.nested-submodule-1.TypeAlias.TypeA.md", + "module-1.submodules.submodule-3-with-modules.nested-submodule-1.TypeAlias.TypeB.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-1.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Class.ClassA.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Class.ClassB.md", @@ -149,8 +376,8 @@ exports[`Urls should gets Urls for modules parts: outputFileStrategy: members 2` "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Enumeration.EnumB.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Interface.InterfaceA.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Interface.InterfaceB.md", - "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Type.TypeA.md", - "module-1.submodules.submodule-3-with-modules.nested-submodule-2.Type.TypeB.md", + "module-1.submodules.submodule-3-with-modules.nested-submodule-2.TypeAlias.TypeA.md", + "module-1.submodules.submodule-3-with-modules.nested-submodule-2.TypeAlias.TypeB.md", "module-1.submodules.submodule-3-with-modules.nested-submodule-2.md", "module-2.Class.ClassA.md", "module-2.Class.ClassB.md", @@ -158,8 +385,8 @@ exports[`Urls should gets Urls for modules parts: outputFileStrategy: members 2` "module-2.Enumeration.EnumB.md", "module-2.Interface.InterfaceA.md", "module-2.Interface.InterfaceB.md", - "module-2.Type.TypeA.md", - "module-2.Type.TypeB.md", + "module-2.TypeAlias.TypeA.md", + "module-2.TypeAlias.TypeB.md", "module-2.md", ] `; diff --git a/packages/typedoc-plugin-markdown/test/specs/comments.spec.ts b/packages/typedoc-plugin-markdown/test/specs/comments.spec.ts index d719917ab..19254e980 100644 --- a/packages/typedoc-plugin-markdown/test/specs/comments.spec.ts +++ b/packages/typedoc-plugin-markdown/test/specs/comments.spec.ts @@ -35,7 +35,7 @@ describe(`Comments`, () => { test(`should get tables for type declarations`, () => { expectFileToEqual('comments', 'members', [ '/type-aliases/TypeDeclarationTable.md', - '/Type.TypeDeclarationTable.md', + '/TypeAlias.TypeDeclarationTable.md', ]); }); diff --git a/packages/typedoc-plugin-markdown/test/specs/documents.spec.ts b/packages/typedoc-plugin-markdown/test/specs/documents.spec.ts new file mode 100644 index 000000000..0c9d8437b --- /dev/null +++ b/packages/typedoc-plugin-markdown/test/specs/documents.spec.ts @@ -0,0 +1,118 @@ +import { expectFileToEqual } from '@devtools/testing'; + +describe(`Documents`, () => { + describe(`Project`, () => { + test(`should compile index page for project`, () => { + expectFileToEqual('documents', ['modules', 'members'], 'README.md', 1); + }); + + test(`should compile a project document`, () => { + expectFileToEqual( + 'documents', + ['modules', 'members'], + 'documents/Project-Document-1.md', + 1, + ); + }); + }); + + describe(`Module`, () => { + test(`should compile index page for module`, () => { + expectFileToEqual( + 'documents', + ['modules', 'members'], + 'ModuleWithDocuments1/README.md', + 1, + ); + }); + + test(`should compile module documents`, () => { + expectFileToEqual( + 'documents', + ['modules', 'members'], + 'ModuleWithDocuments1/documents/MODULE_DOC.md', + 1, + ); + }); + }); + + describe(`Enum`, () => { + test(`should compile index page for enum`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/enumerations/EnumWithDocuments.md', + 1, + ); + }); + + test(`should compile a module document`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/enumerations/documents/ENUM_DOC.md', + 1, + ); + }); + }); + + describe(`Class`, () => { + test(`should compile index page for class`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/classes/ClassWithDocuments.md', + 1, + ); + }); + + test(`should compile a module document`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/classes/documents/CLASS_DOC.md', + 1, + ); + }); + }); + + describe(`Interface`, () => { + test(`should compile index page for interface`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md', + 1, + ); + }); + + test(`should compile a interface document`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/interfaces/documents/INTERFACE_DOC.md', + 1, + ); + }); + }); + + describe(`Interface`, () => { + test(`should compile index page for interface`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/interfaces/InterfaceWithDocuments.md', + 1, + ); + }); + + test(`should compile a interface document`, () => { + expectFileToEqual( + 'documents', + ['members'], + 'ModuleWithDocuments1/interfaces/documents/INTERFACE_DOC.md', + 1, + ); + }); + }); +}); diff --git a/packages/typedoc-plugin-markdown/test/specs/navigation.spec.ts b/packages/typedoc-plugin-markdown/test/specs/navigation.spec.ts index bb97f2a39..59811015d 100644 --- a/packages/typedoc-plugin-markdown/test/specs/navigation.spec.ts +++ b/packages/typedoc-plugin-markdown/test/specs/navigation.spec.ts @@ -20,4 +20,16 @@ describe(`Navigation`, () => { test(`should gets Navigation Json for modules with parts`, () => { expectFileToEqual('modules', ['members', 'modules'], 'sidebar.json'); }); + + test(`should gets Navigation Json for documents multi module`, () => { + expectFileToEqual('documents', ['members', 'modules'], 'sidebar.json'); + }); + + test(`should gets Navigation Json for documents single module`, () => { + expectFileToEqual( + 'documentsSingleModule', + ['members', 'modules'], + 'sidebar.json', + ); + }); }); diff --git a/packages/typedoc-plugin-markdown/test/specs/urls.spec.ts b/packages/typedoc-plugin-markdown/test/specs/urls.spec.ts index 567554c40..febdab99c 100644 --- a/packages/typedoc-plugin-markdown/test/specs/urls.spec.ts +++ b/packages/typedoc-plugin-markdown/test/specs/urls.spec.ts @@ -27,4 +27,12 @@ describe(`Urls`, () => { test(`should gets Urls for modules parts`, () => { expectUrlsToEqual('modules', ['members', 'modules']); }); + + test(`should gets Urls for documents multi modules`, () => { + expectUrlsToEqual('documents', ['members', 'modules']); + }); + + test(`should gets Urls for documents single module`, () => { + expectUrlsToEqual('documentsSingleModule', ['members', 'modules']); + }); }); diff --git a/packages/typedoc-plugin-remark/src/defs/typedoc.d.ts b/packages/typedoc-plugin-remark/src/defs/typedoc.d.ts new file mode 100644 index 000000000..b8886a02a --- /dev/null +++ b/packages/typedoc-plugin-remark/src/defs/typedoc.d.ts @@ -0,0 +1,10 @@ +// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'; +import { RemarkPlugins } from '../options/option-types'; +import { RemarkStringifyOptions } from '../options/option-types'; +declare module 'typedoc' { + export interface TypeDocOptionMap { + remarkPlugins: ManuallyValidatedOption; + remarkStringifyOptions: ManuallyValidatedOption; + } +} diff --git a/packages/typedoc-plugin-remark/src/options/option-types.ts b/packages/typedoc-plugin-remark/src/options/option-types.ts index 30935c581..855a13fd5 100644 --- a/packages/typedoc-plugin-remark/src/options/option-types.ts +++ b/packages/typedoc-plugin-remark/src/options/option-types.ts @@ -1,14 +1,5 @@ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. -import { ManuallyValidatedOption } from 'typedoc'; - -declare module 'typedoc' { - export interface TypeDocOptionMap { - remarkPlugins: ManuallyValidatedOption; - remarkStringifyOptions: ManuallyValidatedOption; - } -} - /** * Describes the options declared by the plugin. * diff --git a/packages/typedoc-plugin-remark/test/specs/__snapshots__/remark.spec.ts.snap b/packages/typedoc-plugin-remark/test/specs/__snapshots__/remark.spec.ts.snap index 311825330..276c20ee2 100644 --- a/packages/typedoc-plugin-remark/test/specs/__snapshots__/remark.spec.ts.snap +++ b/packages/typedoc-plugin-remark/test/specs/__snapshots__/remark.spec.ts.snap @@ -25,7 +25,7 @@ exports[`Remark should parse globals page 1`] = ` #### Parameters | Parameter | Type | -| :-------- | :------- | +| --------- | -------- | | \`param\` | \`string\` | #### Returns @@ -52,7 +52,7 @@ exports[`Remark should parse globals page without toc 1`] = ` #### Parameters | Parameter | Type | -| :-------- | :------- | +| --------- | -------- | | \`param\` | \`string\` | #### Returns @@ -72,16 +72,16 @@ title: 'test' ## Contents -- [Type parameters](#type-parameters) +- [Type Parameters](#type-parameters) - [Constructors](#constructors) - [new SomeClass()](#new-someclass) - [Properties](#properties) - [someProp](#someprop) -## Type parameters +## Type Parameters -| Type parameter | -| :------------- | +| Type Parameter | +| -------------- | | \`T\` | ## Constructors @@ -201,10 +201,10 @@ javascript + list item 1 -#### Type parameters +#### Type Parameters -| Type parameter | -| :------------- | +| Type Parameter | +| -------------- | | \`T\` | #### Constructors @@ -227,10 +227,10 @@ javascript ### SomeInterface\\ -#### Type parameters +#### Type Parameters -| Type parameter | -| :------------- | +| Type Parameter | +| -------------- | | \`T\` | #### Properties @@ -258,7 +258,7 @@ javascript #### Parameters | Parameter | Type | -| :-------- | :-------------------- | +| --------- | --------------------- | | \`param\` | \`string\` \\| \`boolean\` | #### Returns diff --git a/packages/typedoc-vitepress-theme/src/defs/typedoc.d.ts b/packages/typedoc-vitepress-theme/src/defs/typedoc.d.ts new file mode 100644 index 000000000..0793a496e --- /dev/null +++ b/packages/typedoc-vitepress-theme/src/defs/typedoc.d.ts @@ -0,0 +1,9 @@ +// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. +import { ManuallyValidatedOption } from 'typedoc'; +import { Sidebar } from '../options/option-types'; +declare module 'typedoc' { + export interface TypeDocOptionMap { + docsRoot: string; + sidebar: ManuallyValidatedOption; + } +} diff --git a/packages/typedoc-vitepress-theme/src/options/option-types.ts b/packages/typedoc-vitepress-theme/src/options/option-types.ts index 78f88acdf..3a7112f20 100644 --- a/packages/typedoc-vitepress-theme/src/options/option-types.ts +++ b/packages/typedoc-vitepress-theme/src/options/option-types.ts @@ -1,14 +1,5 @@ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY. -import { ManuallyValidatedOption } from 'typedoc'; - -declare module 'typedoc' { - export interface TypeDocOptionMap { - docsRoot: string; - sidebar: ManuallyValidatedOption; - } -} - /** * Describes the options declared by the plugin. *