Tom MacWright

tom@macwright.com

documentation.js 3.0.0

I just tagged the largest change to documentation.js so far. Here’s what’s in it, taken from its changelog:

Dropping streams

Up until this point, documentation.js was built around node.js streams, which are low-level representations of asynchronous series of data. While this abstraction was appropriate for the input and GitHub streams, which are asynchronous, the majority of documentation.js’s internals are simple and synchronous functions for which basic functional composition makes more sense than stream semantics.

Documentation 3.0.0 uses simple functional composition for operations like parmameter inference, rather than streams.

Stronger support for ES6, ES7, and Flow

We’ve switched to Babel as our source code parser, which means that we have much broader support of new JavaScript features, including import/export syntax and new features in ES6.

Babel also parses Flow type annotations, and new inference code means that we can infer parameter names & types and return types, without any explicit JSDoc tags. This means that for many simple functions, we can generate great documentation with less writing.

Stronger module support

Documentation.js now has much better inference for membership and names of symbols exported via exports or module.exports.

Support for nested symbols

The parent/child relationship between symbols is now fully hierarchical, and symbols can be nested to any depth. For instance:

/**
 * A global Parent class.
 */
var Parent = function () {};

/**
 * A Child class.
 */
Parent.Child = function () {};

/**
 * A Grandchild class.
 */
Parent.Child.Grandchild = function () {};

In addition, filtering by access is now applied to the entire hierarchy: if you mark a class as @private, neither it nor its children will be included in the output by default, regardless of the access specifiers of the children.

mdast-based Markdown output

We’ve switched from templating Markdown output with Handlebars.js to generating an abstract syntax tree of desired output and stringifying it with mdast. This lets documentation.js output complex Markdown without having to worry about escaping and properly formatting certain elements.

Test coverage 100%

documentation.js returns to 100% test coverage, so every single line of code is covered by our large library of text fixtures and specific tests.

–lint mode

Specifying the --lint flag makes documentation.js check for non-standard types, like String, or missing namespaces. If the encountered files have any problems, it pretty-prints helpful debug messages and exits with status 1, and otherwise exits with no output and status 0.

Demos

This also means that I’m more comfortable with demos: I just published documentation.js’s documentation of itself, and the same with Markdown. The design went through several iterations, and likely has a few to go, but I’m happy with the improvement, and grateful to the Mapbox design team, especially Tatiana, for constructive criticism of the first draft.

Next up

I’m really happy to get 3.0.0 out the door, because it fixes many commonly-reported issues. For 3.1.0, the focus will be on controlling output order and integrating with narrative documentation, two changes that will greatly improve documentation structure.

Try it out

If you work on JavaScript libraries, please try out documentation.js!! The feedback and contributions of the community will make this project succeed.