Fork me on GitHub

Doctor, MD to HTML documentation generator for nodejs

Doctor is MD (er. markdown) to HTML doc generator for node. The viewer is powered by Bootstrap and MooTools. Generation happens entirely client-side and can work offline or through remote URLs of markdown documents.

Using as a CLI tool

You can just clone the repo and run it.

$ git clone
$ npm install .
$ ./doctor.js -i # agaist a local file
$ ./doctor.js -i -o ../www/webclient/src/docs/ # run against a remote file
$ ./doctor.js -i -o ../built/ -t "My documentation" --logo # custom title and build loc

Using under nodejs

You can also use it as an npm module from within nodejs scripts.

#!/usr/bin/env node
'use strict';

var doc = require('doctor-md');
    source: '',
    output: '../docs/',
    title: 'My title',
    twitter: 'D_mitar',
    pageTemplate: 'tpl/mydocs.hbs', // handlebars,
    analytics: 'UA-1199722-4', // id here
    github: '',
    disqus: 'doctor-md',
    // travis: '',
    logo: 'images/logo.png',
    less: 'less/bootstrap.less',
    less: '../bootstrap/less/bootstrap.less' // custom less file

Just add it to your package.json, npm install or npm link and start requiring it. See lib/builder.js to get an idea of the methods you can call and use.

Events under nodejs

The builder supports the following events

The builder instance is available on the doctor instance as this.builder.

Here is an example use under nodejs:

var doc = require('doctor-md');

doc.builder.on('error', function(msg){
    console.log('error', msg);

doc.builder.on('html', function(){
    console.log('html ready!');

doc.builder.on('pre', function(){
    console.log(this.html); // can mod this.html before it's written

// when all tasks are done
doc.on('done', function(){

// when tasks dont work
doc.on('error', function(msg){

    source: ''

Using global CLI

You can install doctor as a global binary available within your npm env:

$ npm install -g doctor-md
$   .         .
  ,-| ,-. ,-. |- ,-. ,-.
  | | | | |   |  | | |
  `-^ `-' `-' `' `-' ' 0.1.10

    --help, -h      : Help using doctor
    --input, -i     : Input file or URI -i path/to/ or -i
    --output, -o    : Output folder -o ./build, defaults to ./build
    --title, -t     : Set page title -t "My title here", defaults to "Built by doctors"
    --twitter, -@   : Add twitter follow button -@ D_mitar
    --github, -g    : Add github repo link, issues and fork ribbon -g
    --analytics, -a : Add google analytics tracking id -a UA-1199722-3
    --disqus, -d    : Add disqus comments, pass disqus forum name -d doctor-md
    --ci, -c        : Add TravisCI build status badge -c
    --template      : Use a custom handlebars template file --template ./tpl/docs.hbs
    --js            : Use a custom js/ folder to deploy to dist/js --js ./lib/js
    --images        : Use a custom images/ folder to deploy to dist/images --images ./lib/images
    --less, -l      : Use a custom less/bootstrap.less dir to compile css --l ./less/custom.less
    --logo          : Use a custom logo in header --logo

$ doctor -i -@ D_mitar -g -t 'Epitome MVC Framework' -c --logo images/logo.png -a UA-1199722-4

Using under Grunt

You can now use it as a grunt plugin -, it has support for post processing via assemble and grunt-contrib-copy, see the supplied Gruntfile.js as an example of the config object.


You can change the page.hbs handlebars template and edit the .less files, which are compiled in the build. If you edit builder.js and add properties to the template engine - it will accept github and travis already.

Runnable code

Doctor now supports runable code blocks via ACE and an iframe hack. In order to create a block of code that runs with syntax highlighting, you need to tag it as ace, so start via ```ace. Here is an example that will produce an alert below:

alert('this code just run');

You should move any files you want to have available into the deployable js folder. RequireJS is loaded automatically via blank.html from the js folder from the repo, the rest is up to you.

Partials support

You can nest different MD files so they are also included into your build like so:


The actual output of this will be seemless:


The todo section above was read from, it's not real See the on github.


You can use in projects to create gh-pages on the fly. If your git implementation supports git subtreee, you can:

$ git subtree push --prefix build origin gh-pages

The above will take the contents of the build folder or wherever your output is and push it into the gh-pages branch.