A flexible documentation generator and source code parser.
Note: Mia is still in alpha status, right now it only comes with a few basic modules for parsing standard, prototypical code and it's own doc format.
It tries to be open minded about the source code it is parsing and not make any particular assumptions about structure or style.
Mia works in 3 steps:
- It calls the user specificed parsers to detect exports, source structures and annotations
- It merges the generated data and returns a JSON structure with all the information
First Mia needs to parse the code in question, this is done by calling
mia.parse() and specifying the parsers to be run over the source.
var mia = require'mia'fs = require'fs';var source = fsreadFileSync'source.js'toString;var module = miaparse'Module' // Name of the modulesourcemodule: 'iife' // Detect standard anonymous function wrapperssource: 'prototypical' // Detect standrad prototypical classesannotation: 'mia' // Use mia annotations;
module will be a serializable JSON structure which contains all information
returned by the different parsers. An example can be found in this gist.
While the structure already contains all the required information to build documentation from it, the data is still not combined in a template friendly way.
mia.generate() with the module and the matching generator a nicer
structure can be generated which is easy to work with using standard template engines.
var template = miageneratemodule 'mia';
Below is a list of the parsers Mia currently ships with.:
- Detects classes, factories, members, static members and functions as well as prototypical inheritance and super calls to methods and constructors
- Detects exports from immediately invoked function expression / anonymous wrapper
- Detects exports from asynchronous module definitions
- Detects standard Node.js exports
- Parses Mia's own - lightweight - doc format.
It is easy to extend as you can just pass your custom functions to Mia instead of a parser name.
The following generators are currently included:
- Works perfectly with results from the built-in parsers, but should also work fine with most custom parsers.
Mia is licenses under MIT.