From beaa7f42ca320b7d71b1a4e40ee347c33f685b91 Mon Sep 17 00:00:00 2001 From: tgreyuk Date: Mon, 5 Dec 2022 23:16:36 +0000 Subject: [PATCH] fix: refactor tweaks --- .../scripts/build-resources.ts | 18 ++-- .../src/{types.ts => models.ts} | 0 .../src/partials/breadcrumbs.ts | 2 +- .../src/partials/comment.ts | 2 +- .../src/partials/header.ts | 2 +- .../src/partials/hierarchy.ts | 2 +- .../src/partials/member.constructor.ts | 2 +- .../src/partials/member.declaration.title.ts | 4 +- .../src/partials/member.declaration.ts | 2 +- .../src/partials/member.signature.title.ts | 12 ++- .../src/partials/member.signature.ts | 2 +- .../src/partials/member.ts | 2 +- .../src/partials/members.ts | 2 +- .../src/partials/reflection.title.ts | 2 +- .../src/partials/reflection.ts | 2 +- .../src/partials/sources.ts | 4 +- .../src/partials/table.parameters.ts | 22 +++-- .../src/partials/table.properties.ts | 2 +- .../src/partials/table.typeParameters.ts | 2 +- .../src/partials/toc.ts | 4 +- .../src/partials/type.declaration.ts | 4 +- .../src/partials/type.inferred.ts | 2 +- .../src/partials/type.intrinsic.ts | 2 +- .../src/partials/type.reference.ts | 11 +-- .../src/partials/type.reflection.ts | 2 +- .../src/partials/type.some.ts | 5 +- .../src/partials/type.unknown.ts | 3 +- .../src/partials/typeParameters.ts | 2 +- .../typedoc-plugin-markdown/src/resources.ts | 93 ++++++++----------- .../src/{ => support}/constants.ts | 0 .../src/{ => support}/els.ts | 0 .../src/{ => support}/utils.ts | 0 .../src/templates/project.ts | 2 +- .../src/templates/reflection.ts | 2 +- .../src/theme-context.ts | 13 +-- packages/typedoc-plugin-markdown/src/theme.ts | 7 +- 36 files changed, 113 insertions(+), 125 deletions(-) rename packages/typedoc-plugin-markdown/src/{types.ts => models.ts} (100%) rename packages/typedoc-plugin-markdown/src/{ => support}/constants.ts (100%) rename packages/typedoc-plugin-markdown/src/{ => support}/els.ts (100%) rename packages/typedoc-plugin-markdown/src/{ => support}/utils.ts (100%) diff --git a/packages/typedoc-plugin-markdown/scripts/build-resources.ts b/packages/typedoc-plugin-markdown/scripts/build-resources.ts index 5e1d0a4..9e2506c 100644 --- a/packages/typedoc-plugin-markdown/scripts/build-resources.ts +++ b/packages/typedoc-plugin-markdown/scripts/build-resources.ts @@ -19,7 +19,6 @@ const typedocSymbols = [ 'ParameterReflection', 'ProjectReflection', 'QueryType', - 'ReflectionGroup', 'ReferenceReflection', 'ReferenceType', 'ReflectionType', @@ -38,6 +37,8 @@ const project = new Project({ tsConfigFilePath: 'tsconfig.json', }); +const themePath = path.join(__dirname, '..', 'src'); + const templateFiles = getFiles('templates'); const templateSymbols = getSymbols(templateFiles, 'templates'); @@ -45,10 +46,10 @@ const partialsFiles = getFiles('partials'); const partialsSymbols = getSymbols(partialsFiles, 'partials'); const out = [ - `import { \n ${typedocSymbols.join(',\n ')} } from 'typedoc'; - + `// THIS FILE IS AUTOGENERATED - DO NOT EDIT DIRECTLY +import { \n ${typedocSymbols.join(',\n ')} } from 'typedoc'; import { MarkdownThemeRenderContext } from './theme-context'; -import { ${pluginSymbols.join(',\n')} } from './types';`, +import { ${pluginSymbols.join(',\n')} } from './models';`, ]; templateFiles.forEach((file, index) => { @@ -98,13 +99,10 @@ partialsSymbols.forEach((symbol) => { }); out.push(`});`); -fs.writeFileSync( - path.join(__dirname, '..', 'src', 'resources.ts'), - out.join('\n'), -); +fs.writeFileSync(path.join(themePath, 'resources.ts'), out.join('\n')); function getFiles(type: string) { - const partialsFolder = path.join(__dirname, '..', 'src', type); + const partialsFolder = path.join(themePath, type); return fs .readdirSync(partialsFolder) .map((partialsFile) => path.parse(partialsFile).name); @@ -113,7 +111,7 @@ function getFiles(type: string) { function getSymbols(files: string[], type: string) { return files.map((file) => { const tsFile = project.getSourceFile( - path.join(__dirname, '..', 'src', type, file + '.ts'), + path.join(themePath, type, file + '.ts'), ); const symbolName = tsFile?.getExportSymbols()[0]?.getEscapedName(); diff --git a/packages/typedoc-plugin-markdown/src/types.ts b/packages/typedoc-plugin-markdown/src/models.ts similarity index 100% rename from packages/typedoc-plugin-markdown/src/types.ts rename to packages/typedoc-plugin-markdown/src/models.ts diff --git a/packages/typedoc-plugin-markdown/src/partials/breadcrumbs.ts b/packages/typedoc-plugin-markdown/src/partials/breadcrumbs.ts index 3948b86..da9e95a 100644 --- a/packages/typedoc-plugin-markdown/src/partials/breadcrumbs.ts +++ b/packages/typedoc-plugin-markdown/src/partials/breadcrumbs.ts @@ -4,7 +4,7 @@ import { ProjectReflection, ReflectionKind, } from 'typedoc'; -import { link } from '../els'; +import { link } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; export function breadcrumbs( diff --git a/packages/typedoc-plugin-markdown/src/partials/comment.ts b/packages/typedoc-plugin-markdown/src/partials/comment.ts index 6da7aad..3362dcd 100644 --- a/packages/typedoc-plugin-markdown/src/partials/comment.ts +++ b/packages/typedoc-plugin-markdown/src/partials/comment.ts @@ -1,6 +1,6 @@ import { Comment } from 'typedoc'; +import { camelToTitleCase } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { camelToTitleCase } from '../utils'; export function comment(context: MarkdownThemeRenderContext, comment: Comment) { const md: string[] = []; diff --git a/packages/typedoc-plugin-markdown/src/partials/header.ts b/packages/typedoc-plugin-markdown/src/partials/header.ts index 284c222..ec2c41e 100644 --- a/packages/typedoc-plugin-markdown/src/partials/header.ts +++ b/packages/typedoc-plugin-markdown/src/partials/header.ts @@ -1,5 +1,5 @@ import { DeclarationReflection, PageEvent, ReflectionKind } from 'typedoc'; -import { heading } from '../els'; +import { heading } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; export function header( diff --git a/packages/typedoc-plugin-markdown/src/partials/hierarchy.ts b/packages/typedoc-plugin-markdown/src/partials/hierarchy.ts index cbf2205..8895c84 100644 --- a/packages/typedoc-plugin-markdown/src/partials/hierarchy.ts +++ b/packages/typedoc-plugin-markdown/src/partials/hierarchy.ts @@ -1,5 +1,5 @@ import { DeclarationHierarchy, SomeType } from 'typedoc'; -import { bold } from '../els'; +import { bold } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; export function hierarchy( diff --git a/packages/typedoc-plugin-markdown/src/partials/member.constructor.ts b/packages/typedoc-plugin-markdown/src/partials/member.constructor.ts index 50ad3d5..e1608c7 100644 --- a/packages/typedoc-plugin-markdown/src/partials/member.constructor.ts +++ b/packages/typedoc-plugin-markdown/src/partials/member.constructor.ts @@ -1,5 +1,5 @@ import { SignatureReflection } from 'typedoc'; -import { bold } from '../els'; +import { bold } from '../support/els'; import { getTeritiaryHeadingLevel } from '../support/helpers'; import { MarkdownThemeRenderContext } from '../theme-context'; diff --git a/packages/typedoc-plugin-markdown/src/partials/member.declaration.title.ts b/packages/typedoc-plugin-markdown/src/partials/member.declaration.title.ts index b7e7c9e..f607eac 100644 --- a/packages/typedoc-plugin-markdown/src/partials/member.declaration.title.ts +++ b/packages/typedoc-plugin-markdown/src/partials/member.declaration.title.ts @@ -5,9 +5,9 @@ import { ReflectionKind, ReflectionType, } from 'typedoc'; -import { backTicks } from '../els'; +import { backTicks } from '../support/els'; +import { escapeChars, stripComments, stripLineBreaks } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars, stripComments, stripLineBreaks } from '../utils'; export function declarationMemberTitle( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/member.declaration.ts b/packages/typedoc-plugin-markdown/src/partials/member.declaration.ts index d84924e..ec7c3ce 100644 --- a/packages/typedoc-plugin-markdown/src/partials/member.declaration.ts +++ b/packages/typedoc-plugin-markdown/src/partials/member.declaration.ts @@ -1,5 +1,5 @@ import { DeclarationReflection } from 'typedoc'; -import { bold } from '../els'; +import { bold } from '../support/els'; import { getQuaternaryHeadingLevel } from '../support/helpers'; import { MarkdownThemeRenderContext } from '../theme-context'; diff --git a/packages/typedoc-plugin-markdown/src/partials/member.signature.title.ts b/packages/typedoc-plugin-markdown/src/partials/member.signature.title.ts index a17e0b7..93ded4b 100644 --- a/packages/typedoc-plugin-markdown/src/partials/member.signature.title.ts +++ b/packages/typedoc-plugin-markdown/src/partials/member.signature.title.ts @@ -4,8 +4,9 @@ import { MarkdownThemeRenderContext } from '../theme-context'; export function signatureTitle( context: MarkdownThemeRenderContext, signature: SignatureReflection, + accessor?: string, ) { - const md: string[] = ['']; + const md: string[] = ['» ']; if (signature.parent && signature.parent.flags?.length > 0) { md.push( @@ -13,6 +14,10 @@ export function signatureTitle( ); } + if (accessor) { + md.push(accessor + ' '); + } + if (!['__call', '__type'].includes(signature.name)) { md.push(`**${signature.name}**`); } @@ -28,11 +33,14 @@ export function signatureTitle( const getParameters = (parameters: ParameterReflection[] = []) => { return parameters .map((param) => { + const isDestructuredParam = param.name == '__namedParameters'; const paramsmd: string[] = []; if (param.flags.isRest) { paramsmd.push('...'); } - const paramItem = `\`${param.name}${ + const paramItem = `\`${ + isDestructuredParam ? '«destructured»' : param.name + }${ param.flags.isOptional || param.defaultValue ? '?' : '' }\`: ${context.partials.someType(param.type as SomeType, 'all')}`; paramsmd.push(paramItem); diff --git a/packages/typedoc-plugin-markdown/src/partials/member.signature.ts b/packages/typedoc-plugin-markdown/src/partials/member.signature.ts index d6d04bf..fbc9cbf 100644 --- a/packages/typedoc-plugin-markdown/src/partials/member.signature.ts +++ b/packages/typedoc-plugin-markdown/src/partials/member.signature.ts @@ -1,5 +1,5 @@ import { DeclarationReflection, SignatureReflection } from 'typedoc'; -import { bold } from '../els'; +import { bold } from '../support/els'; import { getQuaternaryHeadingLevel } from '../support/helpers'; import { MarkdownThemeRenderContext } from '../theme-context'; diff --git a/packages/typedoc-plugin-markdown/src/partials/member.ts b/packages/typedoc-plugin-markdown/src/partials/member.ts index 15aef62..edaf3c0 100644 --- a/packages/typedoc-plugin-markdown/src/partials/member.ts +++ b/packages/typedoc-plugin-markdown/src/partials/member.ts @@ -3,7 +3,7 @@ import { ReferenceReflection, ReflectionKind, } from 'typedoc'; -import { heading, backTicks } from '../els'; +import { backTicks, heading } from '../support/els'; import { getTeritiaryHeadingLevel, isConstructor } from '../support/helpers'; import { MarkdownThemeRenderContext } from '../theme-context'; diff --git a/packages/typedoc-plugin-markdown/src/partials/members.ts b/packages/typedoc-plugin-markdown/src/partials/members.ts index 5010188..e1b72c2 100644 --- a/packages/typedoc-plugin-markdown/src/partials/members.ts +++ b/packages/typedoc-plugin-markdown/src/partials/members.ts @@ -1,5 +1,5 @@ import { ContainerReflection } from 'typedoc'; -import { heading, horizontalRule } from '../els'; +import { heading, horizontalRule } from '../support/els'; import { getSecondaryHeadingLevel } from '../support/helpers'; import { MarkdownThemeRenderContext } from '../theme-context'; diff --git a/packages/typedoc-plugin-markdown/src/partials/reflection.title.ts b/packages/typedoc-plugin-markdown/src/partials/reflection.title.ts index 782ee99..85800bf 100644 --- a/packages/typedoc-plugin-markdown/src/partials/reflection.title.ts +++ b/packages/typedoc-plugin-markdown/src/partials/reflection.title.ts @@ -1,6 +1,6 @@ import { DeclarationReflection } from 'typedoc'; +import { escapeChars } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars } from '../utils'; export function reflectionTitle( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/reflection.ts b/packages/typedoc-plugin-markdown/src/partials/reflection.ts index cfed48c..2a2ac0c 100644 --- a/packages/typedoc-plugin-markdown/src/partials/reflection.ts +++ b/packages/typedoc-plugin-markdown/src/partials/reflection.ts @@ -1,5 +1,5 @@ import { DeclarationReflection } from 'typedoc'; -import { bold, heading, horizontalRule, unorderedList } from '../els'; +import { bold, heading, horizontalRule, unorderedList } from '../support/els'; import { getSecondaryHeadingLevel } from '../support/helpers'; import { MarkdownThemeRenderContext } from '../theme-context'; diff --git a/packages/typedoc-plugin-markdown/src/partials/sources.ts b/packages/typedoc-plugin-markdown/src/partials/sources.ts index 6d25262..fd1fbda 100644 --- a/packages/typedoc-plugin-markdown/src/partials/sources.ts +++ b/packages/typedoc-plugin-markdown/src/partials/sources.ts @@ -4,11 +4,11 @@ import { ReferenceType, SignatureReflection, } from 'typedoc'; -import { bold, link } from '../els'; +import { bold, link } from '../support/els'; import { getQuaternaryHeadingLevel } from '../support/helpers'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars } from '../utils'; +import { escapeChars } from '../support/utils'; export function sources( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/table.parameters.ts b/packages/typedoc-plugin-markdown/src/partials/table.parameters.ts index c5a330b..c5420ad 100644 --- a/packages/typedoc-plugin-markdown/src/partials/table.parameters.ts +++ b/packages/typedoc-plugin-markdown/src/partials/table.parameters.ts @@ -1,7 +1,7 @@ import { ParameterReflection, ReflectionKind } from 'typedoc'; +import { stripLineBreaks } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { stripLineBreaks } from '../utils'; export function parametersTable( context: MarkdownThemeRenderContext, @@ -59,11 +59,21 @@ function table(context: MarkdownThemeRenderContext, parameters: any) { const rows = parameters.map((parameter) => { const row: string[] = []; - row.push( - `\`${parameter.flags.isRest ? '...' : ''}${parameter.name}${ - parameter.flags.isOptional ? '?' : '' - }\``, - ); + const nbsp = ' '; // ? <== Unicode no-break space character + const rest = parameter.flags.isRest ? '...' : ''; + const optional = parameter.flags.isOptional ? '?' : ''; + + const isDestructuredParam = parameter.name == '__namedParameters'; + const isDestructuredParamProp = + parameter.name.startsWith('__namedParameters.'); + + if (isDestructuredParam) { + row.push(`\`${rest}«destructured»\``); + } else if (isDestructuredParamProp) { + row.push(`›${nbsp}\`${rest}${parameter.name.slice(18)}${optional}\``); + } else { + row.push(`\`${rest}${parameter.name}${optional}\``); + } row.push( parameter.type diff --git a/packages/typedoc-plugin-markdown/src/partials/table.properties.ts b/packages/typedoc-plugin-markdown/src/partials/table.properties.ts index 6b2b7c1..d619cd1 100644 --- a/packages/typedoc-plugin-markdown/src/partials/table.properties.ts +++ b/packages/typedoc-plugin-markdown/src/partials/table.properties.ts @@ -1,6 +1,6 @@ import { DeclarationReflection, ReflectionType } from 'typedoc'; +import { escapeChars, stripLineBreaks } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars, stripLineBreaks } from '../utils'; export function propertiesTable( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/table.typeParameters.ts b/packages/typedoc-plugin-markdown/src/partials/table.typeParameters.ts index bfc30bb..c7ab231 100644 --- a/packages/typedoc-plugin-markdown/src/partials/table.typeParameters.ts +++ b/packages/typedoc-plugin-markdown/src/partials/table.typeParameters.ts @@ -1,6 +1,6 @@ import { TypeParameterReflection } from 'typedoc'; +import { stripLineBreaks } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { stripLineBreaks } from '../utils'; export function typeParametersTable( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/toc.ts b/packages/typedoc-plugin-markdown/src/partials/toc.ts index 2ea35d9..eb6afb4 100644 --- a/packages/typedoc-plugin-markdown/src/partials/toc.ts +++ b/packages/typedoc-plugin-markdown/src/partials/toc.ts @@ -3,10 +3,10 @@ import { ProjectReflection, ReflectionGroup, } from 'typedoc'; -import { heading } from '../els'; +import { heading } from '../support/els'; import { getSecondaryHeadingLevel } from '../support/helpers'; +import { escapeChars } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars } from '../utils'; export function toc( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/type.declaration.ts b/packages/typedoc-plugin-markdown/src/partials/type.declaration.ts index 62e7301..db3c4df 100644 --- a/packages/typedoc-plugin-markdown/src/partials/type.declaration.ts +++ b/packages/typedoc-plugin-markdown/src/partials/type.declaration.ts @@ -1,7 +1,7 @@ import { DeclarationReflection, SomeType } from 'typedoc'; +import { Collapse } from '../models'; +import { escapeChars } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { Collapse } from '../types'; -import { escapeChars } from '../utils'; export function declarationType( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/type.inferred.ts b/packages/typedoc-plugin-markdown/src/partials/type.inferred.ts index 679d3f5..7eda481 100644 --- a/packages/typedoc-plugin-markdown/src/partials/type.inferred.ts +++ b/packages/typedoc-plugin-markdown/src/partials/type.inferred.ts @@ -1,6 +1,6 @@ import { InferredType } from 'typedoc'; +import { escapeChars } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars } from '../utils'; export function inferredType( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/type.intrinsic.ts b/packages/typedoc-plugin-markdown/src/partials/type.intrinsic.ts index 38e7eaf..1359804 100644 --- a/packages/typedoc-plugin-markdown/src/partials/type.intrinsic.ts +++ b/packages/typedoc-plugin-markdown/src/partials/type.intrinsic.ts @@ -1,6 +1,6 @@ import { IntrinsicType } from 'typedoc'; +import { escapeChars } from '../support/utils'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars } from '../utils'; export function intrinsicType( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/type.reference.ts b/packages/typedoc-plugin-markdown/src/partials/type.reference.ts index f111980..4bd39a4 100644 --- a/packages/typedoc-plugin-markdown/src/partials/type.reference.ts +++ b/packages/typedoc-plugin-markdown/src/partials/type.reference.ts @@ -1,12 +1,11 @@ import { ReferenceType } from 'typedoc'; -import { backTicks } from '../els'; +import { backTicks } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; export function referenceType( context: MarkdownThemeRenderContext, referenceType: ReferenceType, ) { - const externalUrl = context.attemptExternalResolution(referenceType); if ( referenceType.reflection || (referenceType.name && referenceType.typeArguments) @@ -21,8 +20,8 @@ export function referenceType( ); } else { reflection.push( - externalUrl - ? `[${backTicks(referenceType.name)}]( ${externalUrl} )` + referenceType.externalUrl + ? `[${backTicks(referenceType.name)}]( ${referenceType.externalUrl} )` : backTicks(referenceType.name), ); } @@ -35,7 +34,7 @@ export function referenceType( } return reflection.join(''); } - return externalUrl - ? `[${backTicks(referenceType.name)}]( ${externalUrl} )` + return referenceType.externalUrl + ? `[${backTicks(referenceType.name)}]( ${referenceType.externalUrl} )` : backTicks(referenceType.name); } diff --git a/packages/typedoc-plugin-markdown/src/partials/type.reflection.ts b/packages/typedoc-plugin-markdown/src/partials/type.reflection.ts index f71fd02..19ce55f 100644 --- a/packages/typedoc-plugin-markdown/src/partials/type.reflection.ts +++ b/packages/typedoc-plugin-markdown/src/partials/type.reflection.ts @@ -1,6 +1,6 @@ import { ReflectionType } from 'typedoc'; +import { Collapse } from '../models'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { Collapse } from '../types'; export function reflectionType( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/type.some.ts b/packages/typedoc-plugin-markdown/src/partials/type.some.ts index 53aabf8..cf5b51d 100644 --- a/packages/typedoc-plugin-markdown/src/partials/type.some.ts +++ b/packages/typedoc-plugin-markdown/src/partials/type.some.ts @@ -14,10 +14,9 @@ import { UnionType, UnknownType, } from 'typedoc'; -import { backTicks } from '../els'; +import { Collapse } from '../models'; +import { backTicks } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { Collapse } from '../types'; -import { escapeChars } from '../utils'; export function someType( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/type.unknown.ts b/packages/typedoc-plugin-markdown/src/partials/type.unknown.ts index 954b952..0e4aad0 100644 --- a/packages/typedoc-plugin-markdown/src/partials/type.unknown.ts +++ b/packages/typedoc-plugin-markdown/src/partials/type.unknown.ts @@ -1,7 +1,6 @@ import { UnknownType } from 'typedoc'; -import { backTicks } from '../els'; +import { backTicks } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; -import { escapeChars } from '../utils'; export function unknownType( context: MarkdownThemeRenderContext, diff --git a/packages/typedoc-plugin-markdown/src/partials/typeParameters.ts b/packages/typedoc-plugin-markdown/src/partials/typeParameters.ts index 04c695f..a9d2bee 100644 --- a/packages/typedoc-plugin-markdown/src/partials/typeParameters.ts +++ b/packages/typedoc-plugin-markdown/src/partials/typeParameters.ts @@ -1,5 +1,5 @@ import { TypeParameterReflection } from 'typedoc'; -import { backTicks } from '../els'; +import { backTicks } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; export function typeParameters( diff --git a/packages/typedoc-plugin-markdown/src/resources.ts b/packages/typedoc-plugin-markdown/src/resources.ts index 3821f32..0f2ff63 100644 --- a/packages/typedoc-plugin-markdown/src/resources.ts +++ b/packages/typedoc-plugin-markdown/src/resources.ts @@ -1,35 +1,33 @@ -import { - ArrayType, - ConditionalType, - ContainerReflection, - Comment, - CommentDisplayPart, - DeclarationHierarchy, - DeclarationReflection, - InferredType, - IntersectionType, - IntrinsicType, - IndexedAccessType, - LiteralType, - PageEvent, - ParameterReflection, - ProjectReflection, - QueryType, - ReflectionGroup, - ReferenceReflection, - ReferenceType, - ReflectionType, - SignatureReflection, - SomeType, - TupleType, - TypeOperatorType, - TypeParameterReflection, - UnionType, - UnknownType, -} from 'typedoc'; - +// THIS FILE IS AUTOGENERATED - DO NOT EDIT DIRECTLY +import { + ArrayType, + ConditionalType, + ContainerReflection, + Comment, + CommentDisplayPart, + DeclarationHierarchy, + DeclarationReflection, + InferredType, + IntersectionType, + IntrinsicType, + IndexedAccessType, + LiteralType, + PageEvent, + ParameterReflection, + ProjectReflection, + QueryType, + ReferenceReflection, + ReferenceType, + ReflectionType, + SignatureReflection, + SomeType, + TupleType, + TypeOperatorType, + TypeParameterReflection, + UnionType, + UnknownType } from 'typedoc'; import { MarkdownThemeRenderContext } from './theme-context'; -import { Collapse } from './types'; +import { Collapse } from './models'; import { memberTemplate } from './templates/member'; import { projectTemplate } from './templates/project'; import { readmeTemplate } from './templates/readme'; @@ -84,27 +82,20 @@ export type Templates = { }; export type Partials = { - breadcrumbs: ( - page: PageEvent, - ) => string; + breadcrumbs: (page: PageEvent) => string; commentParts: (parts: CommentDisplayPart[]) => string; comment: (comment: Comment) => string; header: (page: PageEvent) => string; hierarchy: (declarationHierarchy: DeclarationHierarchy) => string; constructorMember: (signature: SignatureReflection) => string; - declarationMemberTitle: ( - reflection: DeclarationReflection | ParameterReflection, - ) => string; + declarationMemberTitle: (reflection: DeclarationReflection | ParameterReflection) => string; declarationMember: (reflection: DeclarationReflection) => string; referenceMember: (props: ReferenceReflection) => string; - signatureTitle: (signature: SignatureReflection) => string; + signatureTitle: (signature: SignatureReflection, accessor?: string | undefined) => string; signatureMember: (signature: SignatureReflection) => string; member: (reflection: DeclarationReflection) => string; members: (container: ContainerReflection) => string; - reflectionTitle: ( - reflection: DeclarationReflection, - shouldEscape?: boolean, - ) => string; + reflectionTitle: (reflection: DeclarationReflection, shouldEscape?: boolean) => string; reflection: (reflection: DeclarationReflection) => string; sources: (reflection: DeclarationReflection | SignatureReflection) => string; parametersTable: (parameters: ParameterReflection[]) => string; @@ -113,10 +104,7 @@ export type Partials = { toc: (reflection: DeclarationReflection | ProjectReflection) => string; arrayType: (arrayType: ArrayType, emphasis: boolean) => string; conditionalType: (conditionalType: ConditionalType) => string; - declarationType: ( - declarationReflection: DeclarationReflection, - collapse?: Collapse, - ) => string; + declarationType: (declarationReflection: DeclarationReflection, collapse?: Collapse) => string; functionType: (modelSignatures: SignatureReflection[]) => string; indexAccessType: (model: IndexedAccessType) => string; inferredType: (model: InferredType) => string; @@ -125,15 +113,8 @@ export type Partials = { literalType: (literalType: LiteralType) => string; queryType: (queryType: QueryType) => string; referenceType: (referenceType: ReferenceType) => string; - reflectionType: ( - reflectionType: ReflectionType, - collapse: Collapse, - ) => string; - someType: ( - someType: SomeType, - collapse?: Collapse, - emphasis?: boolean, - ) => string; + reflectionType: (reflectionType: ReflectionType, collapse: Collapse) => string; + someType: (someType: SomeType, collapse?: Collapse, emphasis?: boolean) => string; tupleType: (tupleType: TupleType) => string; typeOperatorType: (model: TypeOperatorType) => string; unionType: (unionType: UnionType, emphasis: boolean) => string; @@ -187,4 +168,4 @@ export const partials = (context: MarkdownThemeRenderContext): Partials => ({ unionType: bind(unionType, context), unknownType: bind(unknownType, context), typeParameters: bind(typeParameters, context), -}); +}); \ No newline at end of file diff --git a/packages/typedoc-plugin-markdown/src/constants.ts b/packages/typedoc-plugin-markdown/src/support/constants.ts similarity index 100% rename from packages/typedoc-plugin-markdown/src/constants.ts rename to packages/typedoc-plugin-markdown/src/support/constants.ts diff --git a/packages/typedoc-plugin-markdown/src/els.ts b/packages/typedoc-plugin-markdown/src/support/els.ts similarity index 100% rename from packages/typedoc-plugin-markdown/src/els.ts rename to packages/typedoc-plugin-markdown/src/support/els.ts diff --git a/packages/typedoc-plugin-markdown/src/utils.ts b/packages/typedoc-plugin-markdown/src/support/utils.ts similarity index 100% rename from packages/typedoc-plugin-markdown/src/utils.ts rename to packages/typedoc-plugin-markdown/src/support/utils.ts diff --git a/packages/typedoc-plugin-markdown/src/templates/project.ts b/packages/typedoc-plugin-markdown/src/templates/project.ts index ef88b4a..7957f30 100644 --- a/packages/typedoc-plugin-markdown/src/templates/project.ts +++ b/packages/typedoc-plugin-markdown/src/templates/project.ts @@ -1,5 +1,5 @@ import { PageEvent, ProjectReflection } from 'typedoc'; -import { heading } from '../els'; +import { heading } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; export function projectTemplate( diff --git a/packages/typedoc-plugin-markdown/src/templates/reflection.ts b/packages/typedoc-plugin-markdown/src/templates/reflection.ts index 55c5431..730f581 100644 --- a/packages/typedoc-plugin-markdown/src/templates/reflection.ts +++ b/packages/typedoc-plugin-markdown/src/templates/reflection.ts @@ -1,5 +1,5 @@ import { DeclarationReflection, PageEvent } from 'typedoc'; -import { bold, heading, unorderedList } from '../els'; +import { bold, heading, unorderedList } from '../support/els'; import { MarkdownThemeRenderContext } from '../theme-context'; export function reflectionTemplate( diff --git a/packages/typedoc-plugin-markdown/src/theme-context.ts b/packages/typedoc-plugin-markdown/src/theme-context.ts index 25383eb..d472583 100644 --- a/packages/typedoc-plugin-markdown/src/theme-context.ts +++ b/packages/typedoc-plugin-markdown/src/theme-context.ts @@ -1,9 +1,8 @@ import * as path from 'path'; -import { Options, ReferenceType, Reflection } from 'typedoc'; -import { URL_PREFIX } from './constants'; +import { Options, Reflection } from 'typedoc'; +import { TypedocPluginMarkdownOptions } from './models'; import { partials, templates } from './resources'; -import { MarkdownTheme } from './theme'; -import { TypedocPluginMarkdownOptions } from './types'; +import { URL_PREFIX } from './support/constants'; export class MarkdownThemeRenderContext { public globalsFile = 'Modules.md'; @@ -18,16 +17,12 @@ export class MarkdownThemeRenderContext { return this._activeLocation; } - constructor(private theme: MarkdownTheme, public options: Options) {} + constructor(public options: Options) {} getOption(name: K) { return this.options.getValue(name) as TypedocPluginMarkdownOptions[K]; } - attemptExternalResolution = (type: ReferenceType) => { - return this.theme.owner.attemptExternalResolution(type); - }; - urlTo = (reflection: Reflection) => this.relativeURL(reflection.url); relativeURL(url: string | undefined) { diff --git a/packages/typedoc-plugin-markdown/src/theme.ts b/packages/typedoc-plugin-markdown/src/theme.ts index 23155af..26f0e9b 100644 --- a/packages/typedoc-plugin-markdown/src/theme.ts +++ b/packages/typedoc-plugin-markdown/src/theme.ts @@ -10,10 +10,10 @@ import { Theme, UrlMapping, } from 'typedoc'; -import { URL_PREFIX } from './constants'; +import { HasOwnDocument, TemplateMapping } from './models'; +import { URL_PREFIX } from './support/constants'; +import { formatContents } from './support/utils'; import { MarkdownThemeRenderContext } from './theme-context'; -import { HasOwnDocument, TemplateMapping } from './types'; -import { formatContents } from './utils'; export class MarkdownTheme extends Theme { @BindOption('entryDocument') entryDocument!: string; @BindOption('entryPoints') entryPoints!: string[]; @@ -41,7 +41,6 @@ export class MarkdownTheme extends Theme { getRenderContext() { if (!this._renderContext) { this._renderContext = new MarkdownThemeRenderContext( - this, this.application.options, ); }