A library for parsing JavaScript files and extracting inline documentation. Designed primarily for use with the Dojo Toolkit, but extensible enough to work with any application or documentation format.
New BSD License © 2011–2013 Colin Snover http://zetafleet.com, SitePen Inc. http://www.sitepen.com, and other contributors. Released under Dojo Foundation CLA.
Oh, alright! This documentation parser is designed to allow you, a JavaScript developer, to very easily extend four key areas of operation:
Environments
Your code might run in a variety of environments and exploit natively available functionality of each environment.
If the documentation parser doesn’t know about all those delicious native objects, it can’t help you document
anything you borrow from them. Pluggable environments let you define all the built-ins of the environment your code
runs in so it doesn’t fall over when you try to var slice = [].slice;
.
Call handlers
Chances are good that whatever library you’re using has at least one function that retrieves, decorates, or iterates over objects that you need to document. Adding custom call handlers makes it possible for the documentation parser to understand and evaluate these special calls so that the correct properties exist on the correct objects and that any special magic that these functions might represent can be annotated.
Documentation processors
Some people don’t like the standard jsdoc syntax, and that’s cool. If you’ve extended jsdoc with some new tags, or use some completely different format like dojodocs, Natural Docs, or docco – or, after an evening of heavy drinking, created your own custom documentation format from scratch – writing a new documentation processor will enable you to process any format your heart desires. It will not, however, cure your cirrhosis.
Exporters
Once the code has been parsed and the documentation parsed, you’ll need to output the result to a format that you (or some tool other than you) can actually use! Exporters are completely isolated from the documentation processing workflow, so you can pick and choose one (or lots of) exporters for your final output.
dojo – AMD loader & helper library esprima – ECMAScript parser marked – Markdown parser
git clone --recursive https://github.com/csnover/js-doc-parse.git
config.js
as appropriate for your environment. For parsing Dojo Toolkit source, you should only need
to set basePath
to the path to your Dojo 1.8 checkout../parse.sh config=path/to/your/config.js
to generate documentation for the packages you’ve specified. In
your config. By default, this documentation will be exported to details.xml
; update the exporter configuration if
you want it to go elsewhere.