documentation (master) doxdox documentation

a documentation generator

# builder(yargs)

private method

Add yargs parsing for the build command

Parameters

Name Types Description
yargs Object module instance

# handler(argv)

private method

Wrap around the documentation.lint method and add the additional behavior of printing to stdout and setting an exit status.

Parameters

Name Types Description
argv Object cli arguments

# builder(yargs)

private method

Add yargs parsing for the readme command

Parameters

Name Types Description
yargs Object module instance

# handler(argv)

private method

Insert API documentation into a Markdown readme

Parameters

Name Types Description
argv Object args from the CLI option parser

# sharedInputOptions()

Adds shared options to any command that runs documentation

# sharedOutputOptions()

Adds shared options to any command that runs documentation

# _addBaselineStyles()

_addBaselineStyles Adds baseline styles to the page, used by all AnchorJS links irregardless of configuration.

# _applyRemainingDefaultOptions(opts)

Assigns options to the internal options object, and provides defaults.

Parameters

Name Types Description
opts Object - Options object

# _getElements(input)

Turns a selector, nodeList, or array of elements into an array of elements (so we can use array methods). It also throws errors on any other inputs. Used to handle inputs to .add and .remove.

Parameters

Name Types Description
input String Array

# this.add(selector)

Add anchor links to page elements.

Parameters

Name Types Description
selector String Array

# this.hasAnchorJSLink(el)

Determines if this element already has an AnchorJS link on it. Uses this technique: http://stackoverflow.com/a/5898748/1154642

Parameters

Name Types Description
el HTMLElemnt - a DOM node

# this.isTouchDevice()

Checks to see if this device supports touch. Uses criteria pulled from Modernizr: https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40

# this.remove(selector)

Removes all anchorjs-links from elements targed by the selector.

Parameters

Name Types Description
selector String Array

# this.removeAll()

Removes all anchorjs links. Mostly used for tests.

# this.urlify(text)

Urlify - Refine text so it makes a good ID. To do this, we remove apostrophes, replace nonsafe characters with hyphens, remove extra hyphens, truncate, trim hyphens, and make lowercase.

Parameters

Name Types Description
text String - Any text. Usually pulled from the webpage element we are linking to.

# enter(path)

private method

Process a parse in an abstract syntax tree

Parameters

Name Types Description
path Object ast path

# parseComment(comment)

Parse a comment with doctrine and decorate the result with file position and code context.

Parameters

Name Types Description
comment Object the current state of the parsed JSDoc comment

# walkComments(type, includeContext, ast, data, addComment)

private method

Iterate through the abstract syntax tree, finding a different kind of comment each time, and optionally including context. This is how we find JSDoc annotations that will become part of documentation

Parameters

Name Types Description
type comment type to find
includeContext to include context in the nodes
ast the babel-parsed syntax tree
data the filename and the source of the file the comment is in
addComment a method that creates a new comment if necessary

# walkExported(config, config.extensions, ast, data, addComment)

private method

Iterate through the abstract syntax tree, finding ES6-style exports, and inserting blank comments into documentation.js's processing stream. Through inference steps, these comments gain more information and are automatically documented as well as we can.

Parameters

Name Types Description
config Object
config.extensions Object extensions to try when resolving
ast Object the babel-parsed syntax tree
data Object the name of the file
addComment Function a method that creates a new comment if necessary

# filterAccess(levels, comments)

Exclude given access levels from the generated documentation: this allows users to write documentation for non-public members by using the @private tag.

Parameters

Name Types Description
levels Array<string> included access levels.
comments Array<Object> parsed comments (can be nested)

# flowDoctrine(type)

private method

Babel parses Flow annotations in JavaScript into AST nodes. documentation.js uses Babel to parse JavaScript. This method restructures those Babel-generated objects into objects that fit the output of Doctrine, the module we use to parse JSDoc annotations. This lets us use Flow annotations as JSDoc annotations.

Parameters

Name Types Description
type Object babel-parsed flow type

# findGit(filename)

Given a full path to a single file, iterate upwards through the filesystem to find a directory with a .git file indicating that it is a git repository

Parameters

Name Types Description
filename any file within a repository

# getGithubURLPrefix(root)

Given a a root directory, find its git configuration and figure out the HTTPS URL at the base of that GitHub repository.

Parameters

Name Types Description
root string path at the base of this local repo

# parsePackedRefs(packedRefs, branchName)

private method

Sometimes git will pack refs in order to save space on disk and duck under limits of numbers of files in folders. CircleCI in particular does this by default. This method parses that packed-refs file

Parameters

Name Types Description
packedRefs string string contents of the packed refs file
branchName string the branch name to resolve to

# function(comment)

Attempts to link code to its place on GitHub.

Parameters

Name Types Description
comment Object parsed comment

# function(comments)

Parameters

Name Types Description
comments Array<Object> an array of parsed comments

# getMembers()

private method

We need to have members of all valid JSDoc scopes.

# isEvent(member)

Check if a given member object is of kind event.

Parameters

Name Types Description
member Object - The member to check.

# pick(comment)

private method

Pick only relevant properties from a comment to store them in an inheritance chain

Parameters

Name Types Description
comment a parsed comment

# build(indexes, args, args.external, args.shallow, args.order, args.access, args.hljs, args.hljs.highlightAuto, args.hljs.languages, args.inferPrivate, args.extension)

Generate JavaScript documentation as a list of parsed JSDoc comments, given a root file as a path.

Parameters

Name Types Description
indexes Array<string> string
args Object args
args.external Array<string> a string regex / glob match pattern that defines what external modules will be whitelisted and included in the generated documentation.
args.shallow boolean whether to avoid dependency parsing even in JavaScript code.
args.order Array<string Object>
args.access Array<string> an array of access levels to output in documentation
args.hljs Object hljs optional args
args.hljs.highlightAuto boolean hljs automatically detect language
args.hljs.languages Array languages for hljs to choose from
args.inferPrivate string a valid regular expression string to infer whether a code element should be private, given its naming structure. For instance, you can specify inferPrivate: '^_' to automatically treat methods named like _myMethod as private.
args.extension string Array<string>

# expandInputs(indexes, config)

Given an array of indexes and options for whether to resolve shallow or deep dependencies, resolve dependencies.

Parameters

Name Types Description
indexes Array<string> string
config Object options

# formats()

Documentation's formats are modular methods that take comments and config as input and return Promises with results, like stringified JSON, markdown strings, or Vinyl objects for HTML output.

# lint(indexes, args, args.external, args.shallow, args.inferPrivate, args.extension)

Lint files for non-standard or incorrect documentation information, returning a potentially-empty string of lint information intended for human-readable output.

Parameters

Name Types Description
indexes Array<string> string
args Object args
args.external Array<string> a string regex / glob match pattern that defines what external modules will be whitelisted and included in the generated documentation.
args.shallow boolean whether to avoid dependency parsing even in JavaScript code.
args.inferPrivate string a valid regular expression string to infer whether a code element should be private, given its naming structure. For instance, you can specify inferPrivate: '^_' to automatically treat methods named like _myMethod as private.
args.extension string Array<string>

# pipeline(fns)

private method

Build a pipeline of comment handlers.

Parameters

Name Types Description
fns Array<Function> - Pipeline elements. Each is a function that accepts a comment and can return a comment or undefined (to drop that comment).

# inferAccess(comment)

Infers access from TypeScript annotations, and from the name (only private atm).

Parameters

Name Types Description
comment Object parsed comment

# inferAccessWithPattern(pattern)

private method

Given a string with a pattern that might infer access level, like ^_, create an inference method.

Parameters

Name Types Description
pattern string regexp-compatible pattern

# inferAugments(comment)

Infers an augments tag from an ES6 class declaration

Parameters

Name Types Description
comment Object parsed comment

# findTarget(path)

private method

Try to find the part of JavaScript a comment is referring to, by looking at the syntax tree closest to that comment.

Parameters

Name Types Description
path Object abstract syntax tree path

# inferImplements(comment)

Infers an augments tag from an ES6 class declaration

Parameters

Name Types Description
comment Object parsed comment

# inferKind(comment)

Infers a kind tag from the context.

Parameters

Name Types Description
comment Object parsed comment

# countModuleIdentifiers(comment, identifiers)

private method

Count leading identifiers that refer to a module export (exports or module.exports).

Parameters

Name Types Description
comment Object parsed comment
identifiers Array<string> array of identifier names

# extractIdentifiers(path)

private method

Extract and return the chain of identifiers from the left hand side of expressions of the forms Foo = ..., Foo.bar = ..., Foo.bar.baz = ..., etc.

Parameters

Name Types Description
path NodePath AssignmentExpression, MemberExpression, or Identifier

# extractThis(path, comment)

private method

Extract and return the identifiers for expressions of type this.foo

Parameters

Name Types Description
path NodePath AssignmentExpression, MemberExpression, or Identifier
comment Comment

# findLendsIdentifiers(path)

private method

Given an AST node, try to find a comment in front of it that has a lends tag, and if it has that, return the tag, split by .s.

Parameters

Name Types Description
path Object AST node

# function()

private method

Uses code structure to infer memberof, instance, and static tags from the placement of JSDoc annotations within a file

# Identifier(path)

private method

Add an identifier in a path to the identifiers array

Parameters

Name Types Description
path Object ast path

# inferClassMembership(path)

private method

Given an AST node, try to find a comment before the class declaration that has a memberof tag, and if it has that, return the tag, split by .s with the name of the class.

Parameters

Name Types Description
path Object AST node

# inferMembershipFromIdentifiers(comment, identifiers, explicitScope)

private method

Set memberof and instance/static tags on comment based on the array of identifiers. If the last element of the identifiers is "prototype", it is assumed to be an instance member; otherwise static. If the identifiers start with exports or module.exports, assign membership based on the last seen @module tag or name of the current file.

Parameters

Name Types Description
comment Object comment for which to infer memberships
identifiers Array<string> array of identifier names
explicitScope string if derived from an es6 class, whether or not this method had the static keyword

# normalizeMemberof(comment)

Returns the comment object after normalizing Foo.prototype and Foo# expressions

Parameters

Name Types Description
comment parsed comment

# ThisExpression(path)

private method

Add the resolved identifier of this in a path to the identifiers array

Parameters

Name Types Description
path Object ast path

# Identifier(path)

private method

Attempt to extract the name from an Identifier node. If the name can be resolved, it will stop traversing.

Parameters

Name Types Description
path Object ast path

# inferName(comment)

Infers a name tag from the context.

Parameters

Name Types Description
comment Object parsed comment

# MemberExpression(path)

private method

Attempt to extract the name from an Identifier node. If the name can be resolved, it will stop traversing.

Parameters

Name Types Description
path Object ast path

# StringLiteral(path)

private method

Attempt to extract the name from a string literal that is the key part of an ObjectProperty node. If the name can be resolved, it will stop traversing.

Parameters

Name Types Description
path Object ast path

# inferParams(comment)

Infers param tags by reading function parameter names

Parameters

Name Types Description
comment Object parsed comment

# mapTags()

Index tags by their name property into an ES6 map.

# paramToDoc(param, i, prefix)

private method

Babel parses JavaScript source code and produces an abstract syntax tree that includes methods and their arguments. This function takes that AST and uses it to infer details that would otherwise need explicit documentation, like the names of comments and their default values. It is especially careful to allow the user and the machine to collaborate: documentation.js should not overwrite any details that the user explicitly sets.

Parameters

Name Types Description
param Object the abstract syntax tree of the parameter in JavaScript
i number the number of this parameter, in argument order
prefix string of the comment, if it is nested, like in the case of destructuring

# renameTree()

Recurse through a potentially nested parameter tag, replacing the auto-generated name, like $0, with an explicit name provided from a JSDoc comment. For instance, if you have a code block like function f({ x }); It would by default be documented with a first param $0, with a member $0.x If you specify the name of the param, then it could be documented with, say, options and options.x. So we need to recursively rename not just $0 but also $0.x and maybe $0.x.y.z all to options.x and options.x.y.z

# inferProperties(comment)

Infers properties of TypeAlias objects (Flow or TypeScript type definitions)

Parameters

Name Types Description
comment Object parsed comment

# inferReturn(comment)

Infers returns tags by using Flow return type annotations

Parameters

Name Types Description
comment Object parsed comment

# inferType(comment)

Infers type tags by using Flow/TypeScript type annotations

Parameters

Name Types Description
comment Object parsed comment

# dependencyStream(indexes, config)

Returns a array of dependencies, given an array of entry points and an object of options to provide to module-deps. This stream requires filesystem access, and thus isn't suitable for a browser environment.

Parameters

Name Types Description
indexes paths to entry files as strings
config optional options passed

# filter(id)

Determine whether a module should be included in documentation

Parameters

Name Types Description
id string path to a module

# ync(indexes, config)

A readable source for content that doesn't do dependency resolution, but simply reads files and pushes them onto a stream. If an array of strings is provided as input to this method, then they will be treated as filenames and read into the stream. If an array of objects is provided, then we assume that they are valid objects with source and file properties, and don't use the filesystem at all. This is one way of getting documentation.js to run in a browser or without fs access.

Parameters

Name Types Description
indexes entry points
config parsing options

# addFile(filename)

Executes the linter on a file defined by the filename. Skips unsupported file extensions and any files that are already linted.

Parameters

Name Types Description
filename string The file to be processed

# convertPathToPosix(filepath)

Replace Windows with posix style paths

Parameters

Name Types Description
filepath string Path to convert

# function(pathname)

private method

A function that converts a directory name to a glob pattern

Parameters

Name Types Description
pathname string The directory path to be modified

# listFilesToProcess(globPatterns)

Build a list of absolute filenames on which ESLint will act. Ignored files are excluded from the results, as are duplicates.

Parameters

Name Types Description
globPatterns Glob patterns.

# processPath(extensions)

Checks if a provided path is a directory and returns a glob string matching all files under that directory if so, the path itself otherwise. Reason for this is that glob needs /** to collect all the files under a directory where as our previous implementation without glob simply walked a directory that is passed. So this is to maintain backwards compatibility. Also makes sure all path separators are POSIX style for glob compatibility.

Parameters

Name Types Description
extensions string[] An array of accepted extensions

# resolveFileGlobPatterns(patterns, extensions)

Resolves any directory patterns into glob-based patterns for easier handling.

Parameters

Name Types Description
patterns string[] File patterns (such as passed on the command line).
extensions Array<string> A list of file extensions

# isJSDocComment(comment)

Detect whether a comment is a JSDoc comment: it must be a block comment which starts with two asterisks, not any other number of asterisks. The code parser automatically strips out the first asterisk that's required for the comment to be a comment at all, so we count the remaining comments.

Parameters

Name Types Description
comment Object an ast path of the comment

# formatLint(comments)

private method

Parameters

Name Types Description
comments Array<Object> a list of comments

# lintComments(comment)

Passively lints and checks documentation data.

Parameters

Name Types Description
comment Object parsed comment

# readConfigFile(config)

Merge a configuration file into program config, assuming that the location of the configuration file is given as one of those config.

Parameters

Name Types Description
config String the user-provided config path, usually via argv

# readPackage(noPackage)

Use the nearest package.json file for the default values of name and version config.

Parameters

Name Types Description
noPackage boolean options which prevent ge info about project from package.json

# internalModuleRegexp.test()

Module filters

# nest(comment)

Nests parameters with properties. A parameter employee.name will be attached to the parent parameter employee in a properties array. This assumes that incoming comments have been flattened.

Parameters

Name Types Description
comment Object input comment

# nestTag(tags)

private method

Nest nestable tags, like param and property, into nested arrays that are suitable for output. Okay, so we're building a tree of comments, with the tag.name being the indexer. We sort by depth, so that we add each level of the tree incrementally, and throw if we run against a node that doesn't have a parent. foo.abe foo.bar.baz foo.bar.a foo.bar[].bax foo -> .abe -> .bar -> .baz -> .a -> [].baz

Parameters

Name Types Description
tags Array<CommentTag> a list of tags

# visitor(node)

private method

Adapted from remark-highlight.js https://github.com/ben-eb/remark-highlight.js

Parameters

Name Types Description
node Object AST node

# html(comments, config, config.theme)

Formats documentation as HTML.

Parameters

Name Types Description
comments Array<Comment> parsed comments
config Object Options that can customize the output
config.theme string Name of a module used for an HTML theme.

# json(comments)

Formats documentation as a JSON string.

Parameters

Name Types Description
comments Array<Comment> parsed comments

# markdown(comments, args)

Formats documentation as Markdown.

Parameters

Name Types Description
comments Array<Object> parsed comments
args Object Options that can customize the output

# generate(depth, comment)

Generate an AST chunk for a comment at a given depth: this is split from the main function to handle hierarchically nested comments

Parameters

Name Types Description
depth number nesting of the comment, starting at 1
comment Object a single comment

# markdownAST(comments, args, args.markdownToc, args.hljs)

Given a hierarchy-nested set of comments, generate an remark-compatible Abstract Syntax Tree usable for generating Markdown output

Parameters

Name Types Description
comments nested comment
args Object currently none accepted
args.markdownToc boolean whether to include a table of contents in markdown output.
args.hljs Object config to be passed to highlightjs for code highlighting: consult hljs.configure for the full list.

# commaList(getHref, items, start, end, sep)

Given a list of types, a method to get a link location, and start, end, and separator strings, format a list of potential types. This is used for optional arrays, like where either a string or number is accepted as an input.

Parameters

Name Types Description
getHref Function a method that resolves a namepath to a path
items Array<Object> a list of doctrine-formatted type objects
start string string to prefix the output
end string string to suffix the output
sep string string between items

# decorate(formatted, str, prefix)

Add a string after and potentially before a formatted type definition

Parameters

Name Types Description
formatted Array<Object> remark AST of a type definition
str string postfix
prefix boolean string to put after the type comment

# formatType(getHref, node)

Helper used to format JSDoc-style type definitions into HTML or Markdown.

Parameters

Name Types Description
getHref function - a function that tries to find a URL to point a named link to
node Object - type object in doctrine style

# link(text, getHref, description)

Helper used to automatically link items to global JS documentation or to internal documentation.

Parameters

Name Types Description
text string - text to potentially link
getHref function - a function that tries to find a URL to point a named link to
description string text that will be shown to the user, if this is a two-part link with both target and text

# t(text)

Shortcut to create a new text node

Parameters

Name Types Description
text string contents

# formatters.autolink(text)

Link text to this page or to a central resource.

Parameters

Name Types Description
text string inner text of the link

# formatters.markdown(ast)

Convert a remark AST to a string of HTML, rerouting links as necessary

Parameters

Name Types Description
ast Object remark-compatible AST

# formatters.parameter(param, short)

Format a parameter name. This is used in formatParameters and just needs to be careful about differentiating optional parameters

Parameters

Name Types Description
param Object a param as a type spec
short boolean whether to cut the details and make it skimmable

# formatters.parameters(section, short)

Format the parameters of a function into a quickly-readable summary that resembles how you would call the function initially.

Parameters

Name Types Description
section Object comment node from documentation
short boolean whether to cut the details and make it skimmable

# formatters.type(type)

Format a type and convert it to HTML

Parameters

Name Types Description
type Object doctrine-format type

# function(getHref)

Create a formatter group, given a linker method that resolves namespaces to URLs

Parameters

Name Types Description
getHref linker method

# _link(namepath)

private method

Now that you've configured the LinkerStack with namespaceResolver and a configuration, run it against a namepath. Might return a URL if it can resolve a target, otherwise returns undefined.

Parameters

Name Types Description
namepath string the namepath of a comment

# firstPass(fns, input)

Given an array of functions, call each of them with input and return the output of the first one that returns a truthy value.

Parameters

Name Types Description
fns Array<Function> array of methods
input * any input

# LinkerStack(config)

Create a linking method that takes a namepath and returns a URI or a falsy value

Parameters

Name Types Description
config Object - configuration value

# namespaceResolver(comments, resolver)

private method

Given that the linker stack is a stack of functions, each of which might be able to resolve the URL target of a given namespace, namespaceResolver adds a function to the stack. You give it a list of comments and it adds a function that, if it matches a namespace to a comment, runs resolver on that comment's namespace in order to get a URL. This makes it possible for themes to put each function on a separate page, or at different anchors on the same page, and the resolver does stuff like adding '#' in front of the namespace or turning the namespace into a URL path.

Parameters

Name Types Description
comments Array<Object> a list of comments
resolver Function a method that turns a namespace into a URL

# pathsLinker(paths)

Generate a linker method that links given hardcoded namepaths to URLs

Parameters

Name Types Description
paths Object an object specified in documentation.yml of hard paths

# rerouteLinks(getHref, ast)

private method

Reroute inline jsdoc links in documentation

Parameters

Name Types Description
getHref a method that resolves namespaces
ast remark AST

# access(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# augments(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# callback(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# event(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# example(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# external(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# file(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# flattenBoolean(result, tag, key)

private method

Treat the existence of a tag as a sign to mark key as true in the result

Parameters

Name Types Description
result Object the documentation object
tag Object the tag object, with a name property
key string destination on the result

# flattenDescription(result, tag, key)

private method

Flatten a usable-once description tag into a key

Parameters

Name Types Description
result Object the documentation object
tag Object the tag object, with a description property
key string destination on the result

# flatteners()

private method

Flatteners: these methods simplify the structure of JSDoc comments into a flat object structure, parsing markdown and extracting information where appropriate.

# flattenKindShorthand(result, tag, key)

private method

Parse kind shorthand into both name and type tags, like @class [<type> <name>]

Parameters

Name Types Description
result Object comment
tag Object parsed tag
key string tag

# flattenMarkdownDescription(result, tag, key)

private method

Flatten a usable-once description tag into a key and parse it as Markdown

Parameters

Name Types Description
result Object the documentation object
tag Object the tag object, with a description property
key string destination on the result

# flattenName(result, tag, key)

private method

Flatten a usable-once name tag into a key

Parameters

Name Types Description
result Object the documentation object
tag Object the tag object, with a name property
key string destination on the result

# global(result)

private method

Parse tag

Parameters

Name Types Description
result Object target comment

# inner(result)

private method

Parse tag

Parameters

Name Types Description
result Object target comment

# instance(result)

private method

Parse tag

Parameters

Name Types Description
result Object target comment

# interface(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# kind(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# param(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# parseJSDoc(comment, loc, context)

Parse a comment with doctrine, decorate the result with file position and code context, handle parsing errors, and fix up various infelicities in the structure outputted by doctrine. The following tags are treated as synonyms for a canonical tag: * @virtual@abstract * @extends@augments * @constructor@class * @const@constant * @defaultvalue@default * @desc@description * @host@external * @fileoverview, @overview@file * @emits@fires * @func, @method@function * @var@member * @arg, @argument@param * @prop@property * @return@returns * @exception@throws * @linkcode, @linkplain@link The following tags are assumed to be singletons, and are flattened to a top-level property on the result whose value is extracted from the tag: * @name * @memberof * @classdesc * @kind * @class * @constant * @event * @external * @file * @function * @member * @mixin * @module * @namespace * @typedef * @access * @lends * @description * @summary * @copyright * @deprecated The following tags are flattened to a top-level array-valued property: * @param (to params property) * @property (to properties property) * @returns (to returns property) * @augments (to augments property) * @example (to examples property) * @throws (to throws property) * @see (to sees property) * @todo (to todos property) The @global, @static, @instance, and @inner tags are flattened to a scope property whose value is "global", "static", "instance", or "inner". The @access, @public, @protected, and @private tags are flattened to an access property whose value is "protected" or "private". The assumed default value is "public", so @access public or @public tags result in no access property.

Parameters

Name Types Description
comment string input to be parsed
loc Object location of the input
context Object code context of the input

# private(result)

private method

Parse tag

Parameters

Name Types Description
result Object target comment

# property(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# protected(result)

private method

Parse tag

Parameters

Name Types Description
result Object target comment

# public(result)

private method

Parse tag

Parameters

Name Types Description
result Object target comment

# returns(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# see(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# static(result)

private method

Parse tag

Parameters

Name Types Description
result Object target comment

# synonym(key)

private method

Generate a function that curries a destination key for a flattener

Parameters

Name Types Description
key string the eventual destination key

# throws(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# todo(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# todo()

A no-op function for unsupported tags

# variation(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# yields(result, tag)

private method

Parse tag

Parameters

Name Types Description
result Object target comment
tag Object the tag

# parseJavaScript(data, config)

Receives a module-dep item, reads the file, parses the JavaScript, and parses the JSDoc.

Parameters

Name Types Description
data Object a chunk of data provided by module-deps
config Object config

# commentToFlow(source)

Convert flow comment types into flow annotations so that they end up in the final AST. If the source does not contain a flow pragma, the code is returned verbatim.

Parameters

Name Types Description
source * code with flow type comments

# function()

A remark plugin that installs for JSDoc inline {@link} and {@tutorial} tags. This does not handle the [text]({@link url}) and [text]({@tutorial url}) forms of these tags. That's a JSDoc misfeature; just use regular markdown syntax instead: [text](url).

# remark(string)

private method

Parse a string of Markdown into a Remark abstract syntax tree.

Parameters

Name Types Description
string string markdown text

# function(comments, options)

private method

Sort two documentation objects, given an optional order object. Returns a numeric sorting value that is compatible with stream-sort.

Parameters

Name Types Description
comments Array<Object> all comments
options Object options from documentation.yml

# tsDoctrine(type)

private method

Babel parses TypeScript annotations in JavaScript into AST nodes. documentation.js uses Babel to parse TypeScript. This method restructures those Babel-generated objects into objects that fit the output of Doctrine, the module we use to parse JSDoc annotations. This lets us use TypeScript annotations as JSDoc annotations.

Parameters

Name Types Description
type Object babel-parsed typescript type

# walk(comments, fn, options)

Apply a function to all comments within a hierarchy: this iterates through children in the 'members' property.

Parameters

Name Types Description
comments Array<Object> an array of nested comments
fn Function a walker function
options Object options passed through to walker function