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 = ;const json = ;
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
Contribute
This is an open source project and will ever be! You are more that welcomed to contribute to his development and make it more awesome every day. To do so, you have several possibilities:
Who are Coffeekraken
We try to be some cool guys that build some cool tools to make our (and yours hopefully) every day life better.
More on who we are
License
The code is available under the MIT license. This mean that you can use, modify, or do whatever you want with it. This mean also that it is shipped to you for free, so don't be a hater and if you find some issues, etc... feel free to contribute instead of sharing your frustrations on social networks like an asshole...