Reference Source Test
import CommentParser from 'esdoc2/out/src/Parser/CommentParser.js'
public class | source

CommentParser

Doc Comment Parser class.

Example:

for (let comment of node.leadingComments) {
  let tags = CommentParser.parse(comment);
  console.log(tags);
}

Test:

Static Method Summary

Static Public Methods
public static

buildComment(tags: Tag[]): string

build comment from tags

public static

isESDoc(commentNode: ASTNode): boolean

judge doc comment or not.

public static

parse(commentNode: ASTNode): Tag[]

parse comment to tags.

public static

parseFromNode(node: ASTNode): {tags: Tag[], commentNode: CommentNode}

parse node to tags.

Static Public Methods

public static buildComment(tags: Tag[]): string source

build comment from tags

Params:

NameTypeAttributeDescription
tags Tag[]

Return:

string

block comment value.

public static isESDoc(commentNode: ASTNode): boolean source

judge doc comment or not.

Params:

NameTypeAttributeDescription
commentNode ASTNode

comment node.

Return:

boolean

if true, this comment node is doc comment.

Test:

public static parse(commentNode: ASTNode): Tag[] source

parse comment to tags.

Params:

NameTypeAttributeDescription
commentNode ASTNode

comment node.

commentNode.value string

comment body.

commentNode.type string

CommentBlock or CommentLine.

Return:

Tag[]

parsed comment.

Test:

public static parseFromNode(node: ASTNode): {tags: Tag[], commentNode: CommentNode} source

parse node to tags.

Params:

NameTypeAttributeDescription
node ASTNode

node.

Return:

{tags: Tag[], commentNode: CommentNode}

parsed comment.