Merge remote-tracking branch 'upstream/next' into next

This commit is contained in:
Lorenzo Lewis
2022-12-03 10:49:29 +00:00
8 changed files with 67 additions and 40 deletions

View File

@@ -17,7 +17,7 @@ const DEFAULT_PLUGIN_OPTIONS: PluginOptions = {
hideBreadcrumbs: true,
hidePageTitle: false,
hideHorizontalDivider: false,
embedTitleInCodeBlocks: false,
embedHeadingsInCodeBlock: false,
entryDocument: 'README.md',
plugin: ['none'],
watch: false,

View File

@@ -15,7 +15,7 @@ export interface PluginOptions {
hideBreadcrumbs: boolean;
hidePageTitle: boolean;
hideHorizontalDivider: boolean;
embedTitleInCodeBlocks: boolean;
embedHeadingsInCodeBlock: boolean;
entryDocument: string;
includeExtension?: boolean;
indexSlug?: string;

View File

@@ -46,6 +46,8 @@ Do not render breadcrumbs in template header. Defaults to `false`.
Determines which symbols should be hoisted to their own document. Expected values are `None`, `All` OR Array of `['class', 'interface', 'enum', 'function', 'variable', 'type']` Defaults to `None` (all symbols included in a single module page). See [directory strategy]().
- **`--namedAnchors`**<br>
Use HTML named anchors tags for implementations that do not assign header ids. Defaults to `false`.
- **`--embedHeadingsInCodeBlock`**<br>
Wraps the heading of a reflection in a code block. Defaults to `false`.
## License

View File

@@ -61,7 +61,7 @@ export function load(app: Application) {
app.options.addDeclaration({
help: '[Markdown Plugin] Wraps the heading of a reflection in a code block.',
name: 'embedTitleInCodeBlocks',
name: 'embedHeadingsInCodeBlock',
type: ParameterType.Boolean,
defaultValue: false,
});

View File

@@ -42,6 +42,13 @@ export function signatureMember(
md.push(tags.join('\n\n'));
}
if (signature.comment?.blockTags.length) {
const tags = signature.comment.blockTags
.filter((tag) => tag.tag === '@returns')
.map((tag) => context.partials.commentParts(tag.content));
md.push(tags.join('\n\n'));
}
if (typeDeclaration?.signatures) {
typeDeclaration.signatures.forEach((signature) => {
md.push(context.partials.signatureMember(signature));

View File

@@ -20,7 +20,7 @@ export function member(
}
if (!reflection.hasOwnDocument) {
if (context.getOption('embedTitleInCodeBlocks')) {
if (context.getOption('embedHeadingsInCodeBlock')) {
md.push(
heading(
headingLevel,

View File

@@ -1,31 +1,32 @@
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';
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';
import { MarkdownThemeRenderContext } from './theme-context';
import { Collapse } from './types';
@@ -83,20 +84,27 @@ 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;
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;
@@ -105,7 +113,10 @@ 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;
@@ -114,8 +125,15 @@ 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;
@@ -169,4 +187,4 @@ export const partials = (context: MarkdownThemeRenderContext): Partials => ({
unionType: bind(unionType, context),
unknownType: bind(unknownType, context),
typeParameters: bind(typeParameters, context),
});
});

View File

@@ -5,7 +5,7 @@ export interface TypedocPluginMarkdownOptions extends TypeDocOptionMap {
hideInPageTOC: boolean;
hidePageTitle: boolean;
hideHorizontalDivider: boolean;
embedTitleInCodeBlocks: boolean;
embedHeadingsInCodeBlock: boolean;
entryDocument: string;
indexTitle: string;
namedAnchors: boolean;