Class: Parser

jsdoc/src/parser.Parser

new Parser()

Mixes In:
  • module:events.EventEmitter
Source:
Example

Create a new parser.

var jsdocParser = new (require('jsdoc/src/parser').Parser)();

Methods

_getDocletByLongname(longname) → (nullable) {module:jsdoc/doclet.Doclet}

Retrieve the most recently seen doclet that has the given longname.
Parameters:
Name Type Description
longname string The longname to search for.
Source:
Returns:
The most recent doclet for the longname.
Type
module:jsdoc/doclet.Doclet

_getParentClass(node) → (nullable) {module:jsdoc/doclet.Doclet}

Get the doclet for the lowest-level class, if any, that is in the scope chain for a given node.
Parameters:
Name Type Description
node Object The node whose scope chain will be searched.
Source:
Returns:
The doclet for the lowest-level class in the node's scope chain.
Type
module:jsdoc/doclet.Doclet

addResult(o)

Parameters:
Name Type Description
o Object The parse result to add to the result buffer.
Source:

astnodeToMemberof(node) → {string}

Given a node, determine what the node is a member of.
Parameters:
Name Type Description
node node
Source:
Returns:
The long name of the node that this is a member of.
Type
string

getBasename(name) → {string}

Parameters:
Name Type Description
name string The symbol's longname.
Source:
Returns:
The symbol's basename.
Type
string

parse(sourceFiles, encodingopt)

Parse the given source files for JSDoc comments.
Parameters:
Name Type Attributes Default Description
sourceFiles Array.<string> An array of filepaths to the JavaScript sources.
encoding string <optional>
utf8
Source:
Fires:
  • module:jsdoc/src/parser.Parser.event:parseBegin
  • module:jsdoc/src/parser.Parser.event:fileBegin
  • module:jsdoc/src/parser.Parser.event:jsdocCommentFound
  • module:jsdoc/src/parser.Parser.event:symbolFound
  • module:jsdoc/src/parser.Parser.event:newDoclet
  • module:jsdoc/src/parser.Parser.event:fileComplete
  • module:jsdoc/src/parser.Parser.event:parseComplete
Example

Parse two source files.

var myFiles = ['file1.js', 'file2.js'];
var docs = jsdocParser.parse(myFiles);

resolvePropertyParents(node) → {Array.<module:jsdoc/doclet.Doclet>}

Given an AST node representing an object property, find the doclets for the parent object or objects. If the object is part of a simple assignment (for example, `var foo = { x: 1 }`), this method returns a single doclet (in this case, the doclet for `foo`). If the object is part of a chained assignment (for example, `var foo = exports.FOO = { x: 1 }`, this method returns multiple doclets (in this case, the doclets for `foo` and `exports.FOO`).
Parameters:
Name Type Description
node Object An AST node representing an object property.
Source:
Returns:
An array of doclets for the parent object or objects, or an empty array if no doclets are found.
Type
Array.<module:jsdoc/doclet.Doclet>

resolveThis(node) → {string}

Resolve what "this" refers to relative to a node.
Parameters:
Name Type Description
node node The "this" node
Source:
Returns:
The longname of the enclosing node.
Type
string

resolveVar(node, basename)

Resolve what function a var is limited to.
Parameters:
Name Type Description
node astnode
basename string The leftmost name in the long name: in foo.bar.zip the basename is foo.
Source:

Events

jsdocCommentFound

Fired once for each JSDoc comment in the current source code.
Type:
  • Object
Properties:
Name Type Description
comment string The text content of the JSDoc comment
lineno number The line number associated with the found comment.
filename string The file name associated with the found comment.
Source: