Giter VIP home page Giter VIP logo

doclink's Introduction

Doclink Build Status NPM version

Abstract

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!

How-to

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);

Spec

Exported methods

analyze(root, opt)

Analyze the specified AST to make doc links. NOTE: Given AST should have comments and range.

Parameters
root: AstNode

The AST node as the root.

opt: Object|null|undefined

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.

Return
DocLinker

The doc linker has results. You can get doc links by DocLinker#links.


DocLinker

A class for doc linkers. The doc linker has doc links and attaching/detaching method.

DocLinker#links: Array.<DocLink>

The doc link array.

DocLinker#attach()

Attaches all doc link to each link target. You can access the doc link from AST node via '__$doclink$__'.

DocLinker#detach()

Detaches all doc links from link targets.

DocLinker#link(comment, target, context)

Makes doc link by the specified comment and AST node as the target.

Parameters

comment: AstComment

The comment to be linked.

target: AstNode

The link target.

context: AstNode|null

The parent node of the target.


DocLink

A class for doc links.

DocLink#comment: AstComment

A comment was linked to the symbol.

DocLink#target: AstNode

A symbol as the link target.

DocLink#context: AstNode

A symbol as the context (equals as the parent node) of the link target.

DocLink.propName: string

Property name of the doc link in the link target when DocLink#attach was called. In default: '__$doclink$__'


License

Doclink licensed under MIT.

doclink's People

Contributors

kuniwak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.