davebalmer / joDoc

Simple, open-ended JavaScript source documentation system based on markdown. joDoc rev 1.0.1 is available. Check Wiki page for some examples.
http://joapp.com/jo#joDoc
Other
62 stars 4 forks source link

joDoc

joDoc is a plain text code documentation scheme for JavaScript. It was created out of frustration felt working with various documentation systems available. joDoc does not attempt to perform any special automation other than generating links, table of contents, an index, and of course rendered HTML for your documentation.

Source code formatting

This is a simple example of what you can do in your source documentation. This is all free-form markdown text.

/**
    myClass
    =======

    This is my class. It rocks, and this is its _description_, which also
    rocks.

    Extends
    -------

    - someOtherClass

    Methods
    -------

    - setName(name)

      Where `name` is a `String`.

    Use
    ---
        // here is some sample code which shows how to use this class
        var x = new myClass(name);

    > Note: use of the `name` reserved word is probaly a bad idea.
*/

Comment placement

You can put your comments for your code either:

  1. in your source code (anywhere and in as many pieces as you want) denoted with /** ... */ multiline-comment blocks

  2. separate markdown (*.mdown) files, probably (tho not necessarily) named to match your JavaScript files

Can't get much more flexible than that.

Requirements

  1. perl 5.8 or greater (YMMV with older perl versions)
  2. Markdown.pl (or compatible parser)
  3. SmartyPants.pl (optional)

Windows users should get some suggestions for installing ActiveState or cygwin

Use

jodoc [--output path] [--title string] [--toc file] [--template file] [--markdown file] [-s] [--smartypants file] [filespec]

NOTE: the TOC is not a replacement for the filespec in the command line. You need to make sure to tell joDoc what directorie(s) to parse. The TOC is a semi-automated document which can be useful but is not required.

Examples

Simple case:

jodoc

By default, joDoc will start in the current directory and recursively look for *.mdown, .*.js and *.css files to build documentation. Unless directed otherwise, joDoc will print a unified HTML file on standard out with all the documentation output, and an index of all <h1> tags.

Specifying an output base directory:

jodoc --output /var/www/html/docs

Specifying files to parse:

jodoc ABOUT.mdown *.js *.css

Defining a table of contents structure:

jodoc --toc ~/release.toc

Building joDoc's documentation with joDoc:

jodoc --output html -s --toc samples/TOC_SAMPLE.mdown *.mdown
cp samples/css/* html/
cp samples/index.html html/

Note that the css and index.html step is specific to this documentation set; it is not necessarily required for the docs in your project.