README
Coffeekraken docblock parser
Simple, powerfull and extensible docblock parser that return a JSON representation to work with
Table of content
Install
npm install @coffeekraken/docblock-parser --save-dev
Get Started
First, require the package in your javascript node file like so:
const docblockParser = require("@offeekraken/docblock-parser");
const json = docblockParser(config).parse(myStringToParse);
Documentation
This package mainly expose a parse
function that take a String and return a JSON object representing the docblocks found. Around that main function, you will find some functions and configurations that you can hook to extend or modify the parsing process.
API doc
Here's some API references:
- Config : Configuration file reference
parse
function : Main package function that parse a String and convert it to JSON- Next line analyzer : Each function that analyze the line just after each docblocks
- Tags : Each tags function that sets the data accordingly
Supported tags
Here's the list of supported docblock tags out of the box. You can register new tags as well.
abstract
: If is an abstract class, etc...attribute
: Specify if is an HTMLElement attribute that we documentauthor
: Specify the authorbody
: Specify the body content of the docblock. It's usually taken automatically from the first non tagged contentcategory
: Specify a categoryclass
: Specify if is a class that we documentconstructor
: Specify if is a constructor that we documentconst
: Specify if is a constantcopyright
: Specify a copyrightdefault
: Specify the default value for a property.deprecated
: Specify if is deprecatedevent
: Specify if the docblock document an event or not- Usage :
@name my-cool-event
@event
etc...
example
: Specify an example.- Usage :
@example {language}
your code here...
extends
: Specify the parent classfinal
: Specify if is final implementationglobal
: Specify if is a global variable, etc...implements
: Specify some interfaces that the class implementinterface
: Specify if is an interfacename
: Specify the name of the item.override
: Specify if is an overridepackage
: Specify a packageparam
: Specify the parameters for the function- Usage :
@param {String} myCoolParam A cool param
@param {Integer} [otherParam=2] Another optional param
private
: Specify if the function/variable is privateproperty
: Specify some properties- Usage :
@property {String} myCoolProperty A cool property
@property {Integer} [otherProperty=2] Another cool property
protected
: Specify if the function/variable is protectedpublic
: Specify if the function/variable is publicreturn
: Specify the returned value- Usage :
@return {String} The cool returned value
see
: Specify a url for more info- Usage :
@see http://google.com {optionalLabel}
static
: Specify if the documented property/function is a static one.todo
: Specify some things to dotype
: Specify the type(s) of the documented variable.- Usage :
@type {String|Boolean}
values
: Specify the possible values for the documented element- Usage :
@values Hello|World
Coffeekraken
We are a young collective of front-end creative developers with one goal in mind. Build tools to make every team working day life better. This is our first and only concern. All our tools are build around that purpose. All what we provide are some cool tools that you can use the way you want. These tools features cover a large scope of the front-end workflow (styleguide generation, colors/fonts management, etc...). You can use only the parts that you need and let the rest aside...