load(file[, opts][, cb])Load and parse file contents.
When a callback function is given it is added as a listener for the error and end events on the source file stream.
Returns the parser stream.
fileString path.optsObject processing options.cbFunction callback function.
parse(buffer[, opts][, cb])Parse a string or buffer.
When a callback function is given it is added as a listener for the error and finish events on the parser stream.
Returns the parser stream.
bufferString|Buffer input data.optsObject processing options.cbFunction callback function.
Collator([opts])Collate comments and source content into a stream.
Allows for writing files that contains only content, only comments or both content and comments. By default this stream will pass through comments and content.
To disable content from the stream (comments only) use:
{content: false}To disable comments from the stream (source content only) use:
{comment: false}When the buffer option is set all output is buffered into
the buffer property as a string, listen for the finish event before
attempting to access the buffer contents.
optsObject stream options.
contentBoolean push content chunks to the stream.commentBoolean push comment chunks to the stream.bufferBoolean buffer output.stringifyBoolean convert output to JSON strings.indentNumber number of spaces to indent JSON.
Comment([opts])Parse comments from an array of lines.
When a comment is parsed an object is pushed to the stream
with an array of lines, the rule for the comment and the
start and end line numbers.
When a content block is encountered a string is pushed for inline content (between comments on a single-line or trailing content), otherwise an array of lines is pushed.
optsObject stream options.
rulesArray|Function defines the comment rules.optionsObject to pass to therulesfunction.
Parser([opts])Comment and tag parser, parses comment description and tags.
optsObject stream options.
tagObject defines the tag patterns, see tagdottedBoolean parse dotted names in tags.
commentwhen a comment has been parsed.contentwhen a content chunk is received.
Parser.prototype.stringify(indent, comment)Creates a stream that transforms to newline-delimited JSON, the created stream is piped from this parser.
Returns the stringify stream.
indentNumber the number of spaces to indent the JSON.commentBoolean only include comment output.
A language rule is an object containing the open, close and strip
functions.
The open and close functions are passed the current line and should
return the exec match for the pattern.
The strip function is passed an array of lines for the entire comment and should remove comment meta characters from all lines.
defaults([opts])Creates the default language rules for the C family of languages.
By default recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
To include /* comments as well set the greedy option:
{multi: {greedy: true}Returns list of language rules.
optsObject processing options.
multiObject multi-line rule configuration.singleObject single-line rule configuration.
static multi([opts])Creates a multi-line rule, when no options are given creates the default C family multi-line rule.
Returns multi-line language rule.
optsObject processing options.
greedyBoolean include/*comments.startRegExp comment start pattern.endRegExp comment end pattern.leadRegExp remove leading meta characters that match.trailRegExp remove trailing meta characters that match.openFunction override default open function.closeFunction override default close function.stripFunction override default strip function.
static single([opts])Creates a single-line rule, when no options are given creates the default C family single-line rule.
Returns single-line language rule.
optsObject processing options.
markRegExp sub pattern.startRegExp comment start pattern.endRegExp comment end pattern.leadRegExp remove leading meta characters that match.trailRegExp remove trailing meta characters that match.openFunction override default open function.closeFunction override default close function.stripFunction override default strip function.
Defines the patterns and functions that perform the tag parsing.
Create a custom tag definition if you wanted to use an alternative
syntax or prefer something other than @ as the tag identifier.
The generic syntax for tags is: @id {type[=value]} name description;
everything but the tag id is considered optional.
Which when given: @property {String=mkdoc} [nickname] user will expand
to a tag object such as:
{
id: 'property',
type: 'String',
value: 'mkdoc',
name: 'nickname',
description: 'user',
optional: true
}See the tag parser.
RegExp rulePattern that collects tag lines.
Object unescapePattern that unescapes tag sequences after parsing.
RegExp patternPattern that collects tag component parts.
RegExp optionalPattern that determines optionality.
RegExp whitespacePattern that determines how to strip leading whitespace from lines.
By default will match one or two spaces, depending upon your comment style you should adjust this so that whitespace is preserved as intended.
parse(line, tag)Parses the component parts of a tag definition.
This will add the id, type, name and description
fields to the input tag argument.
lineString current line being parsed.tagObject target for parsed data.
Contains utilities for testing whether a language id is valid, loading language packs and finding language identifiers by file extension.
find(ext)Find a language pack identifier by file extension.
File extensions must not include the leading period.
Returns language pack identifier if found.
extString file extension.
exists(id)Test whether a language exists by identifier.
Returns whether the language pack exists.
idString language pack identifier.
load(id)Load a language pack by identifier.
idString language pack identifier.
Errorif the language pack does not exist.
actionscript([opts])Creates an array of language rules for actionscript files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
c([opts])Creates an array of language rules for C files.
Recognises terminated multi-line comments starting with /*.
See the default settings.
Returns list of language rules.
optsObject processing options.
greedyBoolean=true disable to use `` comments only.
coffeescript([opts])Creates an array of language rules for coffeescript files.
Recognises continuous blocks of lines beginning with # and multi-line
comments delimited with ###.
Returns list of language rules.
optsObject processing options.
conf([opts])Creates an array of language rules for conf files.
Recognises continuous blocks of lines beginning with #.
See the shell language.
Returns list of language rules.
optsObject processing options.
cpp([opts])Creates an array of language rules for C++ files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
greedyBoolean include/*comments.
css([opts])Creates an array of language rules for css files.
Recognises terminated multi-line comments starting with /*.
See the c language.
Returns list of language rules.
optsObject processing options.
erlang([opts])Creates an array of language rules for erlang files.
Recognises continuous blocks of lines beginning with %.
Returns list of language rules.
optsObject processing options.
go([opts])Creates an array of language rules for go files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
groovy([opts])Creates an array of language rules for groovy files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
html([opts])Creates an array of language rules for HTML files.
Recognises multi-line comments started with <!-- and terminated
with -->.
Returns list of language rules.
optsObject processing options.
ini([opts])Creates an array of language rules for ini files.
Recognises continuous blocks of lines beginning with ;.
Returns list of language rules.
optsObject processing options.
markRegExp sub pattern.trailRegExp pattern to strip trailing meta characters.
jade([opts])Creates an array of language rules for jade files.
Recognises continuous blocks starting with //- or //.
Returns list of language rules.
optsObject processing options.
java([opts])Creates an array of language rules for java files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
javascript([opts])Creates an array of language rules for javascript files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
less([opts])Creates an array of language rules for less files.
Recognises terminated multi-line comments starting with /* and
continuous blocks of single-line comments beginning with //.
See the css language.
Returns list of language rules.
optsObject processing options.
markdown([opts])Creates an array of language rules for markdown files.
Recognises multi-line comments started with <!-- and terminated
with -->.
See the html language.
Returns list of language rules.
optsObject processing options.
Collection of language packs.
Default language pack used is the cpp language.
pandoc([opts])Creates an array of language rules for pandoc files.
Recognises multi-line comments starting with <!-- or <!--- and
terminated with -->, extends the html language.
See the pandoc website.
Returns list of language rules.
optsObject processing options.
php([opts])Creates an array of language rules for php files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
pi([opts])Creates an array of language rules for SGML/XML processing instructions.
Recognises multi-line comments started with <? and terminated
with ?>.
Returns list of language rules.
optsObject processing options.
processing([opts])Creates an array of language rules for processing files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
properties([opts])Creates an array of language rules for Java properties files.
Recognises continuous blocks of lines beginning with #.
See the shell language.
Returns list of language rules.
optsObject processing options.
python([opts])Creates an array of language rules for python files.
Recognises continuous blocks of lines beginning with # and multi-line
comments delimited with """.
Returns list of language rules.
optsObject processing options.
ruby([opts])Creates an array of language rules for ruby files.
Recognises continuous blocks of lines beginning with #
and =begin, =end multi-line comments.
Returns list of language rules.
optsObject processing options.
multiObject multi-line rule configuration.singleObject single-line rule configuration.
sass([opts])Creates an array of language rules for sass files.
Recognises terminated multi-line comments starting with /* and
continuous blocks of single-line comments beginning with //.
See the css language.
Returns list of language rules.
optsObject processing options.
scala([opts])Creates an array of language rules for scala files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
shell([opts])Creates an array of language rules for shell files.
Recognises continuous blocks of lines beginning with #.
Returns list of language rules.
optsObject processing options.
markRegExp sub pattern.trailRegExp pattern to strip trailing meta characters.
sql([opts])Creates an array of language rules for SQL statements.
Recognises terminated multi-line comments started with /* and
continuous lines beginning with --.
If the mysql option is given continuous lines beginning with # are
also recognised.
Returns list of language rules.
optsObject processing options.
includeBoolean mysql specific comment rule.
stylus([opts])Creates an array of language rules for stylus files.
Recognises terminated multi-line comments starting with /* and
buffered multi-line blocks starting with /*! as well as
continuous blocks of single-line comments beginning with //.
See the css language.
Returns list of language rules.
optsObject processing options.
singleObject|Boolean=true single-line comment options.multiObject|Boolean=true multi-line comment options.bufferObject|Boolean=true buffer comment options.
toml([opts])Creates an array of language rules for TOML files.
Recognises continuous blocks of lines beginning with #.
See the shell language.
Returns list of language rules.
optsObject processing options.
typescript([opts])Creates an array of language rules for typescript files.
Recognises continuous lines with // comments and terminated
multi-line comments starting with ``.
See the default settings.
Returns list of language rules.
optsObject processing options.
vim([opts])Creates an array of language rules for vim files.
Recognises continuous blocks of lines beginning with ".
Returns list of language rules.
optsObject processing options.
markRegExp sub pattern.trailRegExp pattern to strip trailing meta characters.
xml([opts])Creates an array of language rules for XML files.
Recognises multi-line comments started with <!-- and terminated
with -->.
See the html language.
Returns list of language rules.
optsObject processing options.
yaml([opts])Creates an array of language rules for YAML files.
Recognises continuous blocks of lines beginning with #.
See the shell language.
Returns list of language rules.
optsObject processing options.
Created by mkdoc on January 3, 2017