Function jsdocTransformer
- jsdocTransformer(
handler: (
data: {
comments: string[];
context: TransformationContext;
lastComment: string;
lastParsed: Block;
node: Node;
parsed: Block[];
sourceFile: SourceFile;
},
) => any,
postHandler?: (sourceFile: SourceFile) => SourceFile,
nodeTest?: (data: { node?: Node; sourceFile?: SourceFile }) => boolean,
): TransformerFactory<SourceFile | Bundle>Parameters
- handler: (
data: {
comments: string[];
context: TransformationContext;
lastComment: string;
lastParsed: Block;
node: Node;
parsed: Block[];
sourceFile: SourceFile;
},
) => anyA function to process AST nodes with JSDoc comments.
OptionalpostHandler: (sourceFile: SourceFile) => SourceFileA function to postprocess the source file after all nodes visited. Return an updated SourceFile node.
OptionalnodeTest: (data: { node?: Node; sourceFile?: SourceFile }) => booleanTest the node type before parsing comments. Both Node and SourceFile are available for testing. When defined return a
trueto parse the node JSDoc comments.
Returns TransformerFactory<SourceFile | Bundle>
JSDoc custom "meta-transformer".
- handler: (
Provides a convenient "meta-transformer" that invokes a handler function for each Node reducing the boilerplate required w/ the parsed leading comment data for the Node. Only leading block comments are parsed. The
parsedarray is in the data format provided by thecomment-parserpackage. For convenience there arelastCommentandlastParsedfields that return the last comment block respectively before the node. Typically, the last comment is the active JSDoc block for a Node.Note: In the
handlerreturn null to remove the Node. ThepostHandlerallows final modification of the SourceFile after all nodes are visited; return a new SourceFile to update it.