mirror of
https://github.com/tauri-apps/typedoc-plugin-markdown.git
synced 2026-01-31 00:45:20 +01:00
fix: refactor tweaks
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<DeclarationReflection | ProjectReflection>,
|
||||
) => string;
|
||||
breadcrumbs: (page: PageEvent<DeclarationReflection | ProjectReflection>) => string;
|
||||
commentParts: (parts: CommentDisplayPart[]) => string;
|
||||
comment: (comment: Comment) => string;
|
||||
header: (page: PageEvent<DeclarationReflection>) => 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),
|
||||
});
|
||||
});
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<K extends keyof TypedocPluginMarkdownOptions>(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) {
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user