Leafdoc generated API reference

Leafdoc

Represents the Leafdoc parser

Usage example

Output Leafdoc's own documentation to the console with:

var LeafDoc = require('./src/leafdoc.js');
var doc = new LeafDoc();
    doc.addDir('src');
console.log( doc.outputStr() );

Creation

Instantiation Description
new Leafdoc(<Leafdoc options> options) Constructor for a new Leafdoc parser

Options

Option Type Default Description
templateDir String 'templates/basic' Defines which subdirectory (relative to the directory the curent JS script is running) holds the handlebars template files for building up the HTML.
showInheritancesWhenEmpty Boolean false When true, child classes/namespaces will display documentables from ancestors, even if the child class doesn't have any of such documentables. e.g. display inherited events even if the child doesn't define any new events.
leadingCharacter String '🍂' Overrides the Leaf symbol as the leading character for documentation lines. See also setLeadingCharacter.
customDocumentables Map {} A key-value map. Each pair will be passed to registerDocumentable.

Methods

Method Returns Description
registerDocumentable(<String> name, <String> label?) this Registers a new documentable type, beyond the preset ones (function, property, etc). New documentable should also not be an already used keyword (class, namespace, inherits, etc). When registering new documentables, make sure that there is an appropiate template file for it. Set label to the text for the sections in the generated docs.
setLeadingCharacter(<String> char) this In the rare case you don't want to use 🍂 as the leading character for leaf directives, run this function with the desired character, e.g. setLeadingCharacter('@'); The new leading character will apply only to files/dirs/strings parsed from that moment on, so it's a good idea to call this before anything else.
addDir(<String> dirname, <String[]> extensions?) this Recursively scans a directory, and parses any files that match the given extensions (by default .js and .leafdoc, mind the dots). Files with a .leafdoc extension will be treated as leafdoc-only instead of source.
addFile(<String> filename, <Boolean> isSource?) this Parses the given file using addBuffer.
addBuffer(<Buffer> buf, <Boolean> isSource?) this Parses the given buffer using addStr underneath.
addStr(<String> str, <Boolean> isSource?, <bar"> foo) this Parses the given string for Leafdoc comments. The string is assumed to be source code with comments, unless isSource is explicitly set to false. directive.
outputStr() String Outputs the documentation to a string. Use only after all the needed files have been parsed.