@knodes/typedoc-pluginutils
Version:
A set of utilities for TypeDoc plugins
53 lines • 2.42 kB
TypeScript
import { Comment, CommentDisplayPart, CommentTag, Context, InlineTagDisplayPart, Reflection } from 'typedoc';
import { ABasePlugin, IPluginComponent, PluginAccessor } from '../../base-plugin';
import { Tag } from '../types';
export declare class ReflectionCommentReplacer implements IPluginComponent {
readonly plugin: ABasePlugin;
constructor(pluginAccessor: PluginAccessor);
/**
* Register an inline tag (`{@tag ...}`) and execute an optional function on found instances.
*
* @param tagName - The name of the tag to match.
* @param callback - An optional callback to execute on found tags.
* @param priority - The priority to run the callback if provided.
*/
registerInlineTag(tagName: Tag, callback?: ReflectionCommentReplacer.ReplaceCallback<ReflectionCommentReplacer.MatchBlockComment | ReflectionCommentReplacer.MatchSummary>, priority?: number): void;
/**
* Register a block tag (`\n@tag ...\n`) and execute an optional function on found instances.
*
* @param tagName - The name of the tag to match.
* @param callback - An optional callback to execute on found tags.
* @param priority - The priority to run the callback if provided.
*/
registerBlockTag(tagName: Tag, callback?: ReflectionCommentReplacer.ReplaceCallback<ReflectionCommentReplacer.MatchBlock>, priority?: number): void;
}
export declare namespace ReflectionCommentReplacer {
export type SourceHint = () => string;
export type TagKind = 'summary' | 'block' | 'blockComment';
export interface MatchBase {
comment: Comment;
kind: TagKind;
reflection: Reflection;
context: Context;
}
interface MatchInlineTag extends MatchBase {
tag: InlineTagDisplayPart;
replace: (newVal: CommentDisplayPart) => void;
}
export interface MatchBlockComment extends MatchInlineTag {
kind: 'blockComment';
block: CommentTag;
}
export interface MatchBlock extends MatchBase {
kind: 'block';
block: CommentTag;
replace: (newVal: CommentTag) => void;
}
export interface MatchSummary extends MatchInlineTag {
kind: 'summary';
}
export type Match = MatchBlockComment | MatchBlock | MatchSummary;
export type ReplaceCallback<T extends Match> = (match: T) => void;
export {};
}
//# sourceMappingURL=reflection-comment-replacer.d.ts.map