Doclink is a JavaScript module provides to link doc comment to AST node as the link targets.
This module works on Node.js and a browser supported JavaScript 1.6 or later.
Online demo is available. Try it!
Install doclink and esprima (or other AST parser).
npm install doclink esprima
And simple example is:
var ast = require('esprima').parse(code, { comment: true, range: true });
var doclinker = require('doclink').analyze(ast);
console.log(doclinker.links);
Analyze the specified AST to make doc links. NOTE: Given AST should have comments and range.
The AST node as the root.
Options. Set opt.fileDoc
if the code has a file doc comment. You can change doc comment spec by set your test function as opt.isDocComment
. In default, a doc comment is a Block comment and has /**
on the head.
The doc linker has results. You can get doc links by DocLinker#links
.
A class for doc linkers. The doc linker has doc links and attaching/detaching method.
The doc link array.
Attaches all doc link to each link target. You can access the doc link from AST node via '__$doclink$__'
.
Detaches all doc links from link targets.
Makes doc link by the specified comment and AST node as the target.
The comment to be linked.
The link target.
The parent node of the target.
A class for doc links.
A comment was linked to the symbol.
A symbol as the link target.
A symbol as the context (equals as the parent node) of the link target.
Property name of the doc link in the link target when DocLink#attach
was called. In default: '__$doclink$__'
Doclink licensed under MIT.