docs: function buildMarkdown(doc) {
      var heading = "#",
        namespace = doc.name.toLowerCase(),
        md = "";
  
      md += heading + ' ' + doc.name;
      md += '\n\n';
      md += doc.description;
      md += '\n\n';
  
      md += '<!-- HEADER END -->\n\n';
      md += '<!-- NAV START -->\n\n';
  
      md += "* [Use](#use)";
      md += '\n';
  
      if (doc.options && doc.options.length) {
        md += "* [Options](#options)";
        md += '\n';
      }
      if (doc.events && doc.events.length) {
        md += "* [Events](#events)";
        md += '\n';
      }
      if (doc.methods && doc.methods.length) {
        md += "* [Methods](#methods)";
        md += '\n';
      }
      if (doc.css && doc.css.length) {
        md += "* [CSS](#css)";
        md += '\n';
      }
  
      md += '\n<!-- NAV END -->\n';
      md += '\n<!-- DEMO BUTTON -->\n';
  
      md += '\n';
      md += '<a name="use"></a>\n\n';
      md += heading + '# Using ' + doc.name;
      md += '\n\n';
  
      if (doc.main && doc.main.length) {
        md += '\n';
        md += heading + '### Main';
        md += '\n\n';
        md += '```markup';
        md += '\n';
        for (var i in doc.main) {
          md += doc.main[i];
          md += '\n';
        }
        md += '```';
        md += '\n\n';
      }
  
      if (doc.dependencies && doc.dependencies.length) {
        md += '\n';
        md += heading + '### Dependencies';
        md += '\n\n';
        md += '```markup';
        md += '\n';
        for (var i in doc.dependencies) {
          md += doc.dependencies[i];
          md += '\n';
        }
        md += '```';
        md += '\n\n';
      }
  
      if (doc.use) {
        md += doc.use
        md += '\n\n';
      }
  
      if (doc.options && doc.options.length) {
        md += '\n';
        md += '<a name="options"></a>\n\n';
        md += heading + '# Options';
        md += '\n\n';
        if (doc.type === "widget") {
          md += 'Set instance options by passing a valid object at initialization, or to the public `defaults` method. Custom options for a specific instance can also be set by attaching a `data-' + namespace + '-options` attribute to the target elment. This attribute should contain the properly formatted JSON object representing the custom options.';
        }
        if (doc.type === "utility") {
          md += 'Set instance options by passing a valid object at initialization, or to the public `defaults` method.';
        }
        md += '\n\n';
        md += '| Name | Type | Default | Description |';
        md += '\n';
        md += '| --- | --- | --- | --- |';
        md += '\n';
        for (var i in doc.options) {
          var o = doc.options[i];
          md += '| ' + (o.name ? '`'+o.name+'`' : "&nbsp;");
          md += ' | ' + (o.type ? '`'+o.type+'`' : "&nbsp;");
          md += ' | ' + (o.default ? '`'+o.default+'`' : "&nbsp;");
          md += ' | ' + (o.description || "&nbsp;");
          md += ' |\n';
        }
        md += '\n';
      }
  
      if (doc.events && doc.events.length) {
        md += '<hr>\n';
        md += '<a name="events"></a>\n\n';
        md += heading + '# Events';
        md += '\n\n';
        if (doc.type === "widget") {
          md += 'Events are triggered on the target instance\'s element, unless otherwise stated.';
          md += '\n\n';
        }
        if (doc.type === "utility") {
          md += 'Events are triggered on the `window`, unless otherwise stated.';
          md += '\n\n';
        }
        md += '| Event | Description |';
        md += '\n';
        md += '| --- | --- |';
        md += '\n';
        for (var i in doc.events) {
          var e = doc.events[i];
          md += '| ' + (e.name ? '`'+e.name+'`' : "&nbsp;");
          md += ' | ' + (e.description || "&nbsp;");
          md += ' |\n';
        }
        md += '\n';
      }
  
      if (doc.methods && doc.methods.length) {
        md += '<hr>\n';
        md += '<a name="methods"></a>\n\n';
        md += heading + '# Methods';
        md += '\n\n';
        if (doc.type === "widget") {
          md += 'Methods are publicly available to all active instances, unless otherwise stated.';
          md += '\n\n';
        }
        if (doc.type === "utility") {
          md += 'Methods are publicly available, unless otherwise stated.';
          md += '\n\n';
        }
        for (var i in doc.methods) {
          var m = doc.methods[i];
          md += heading + '## ' + m.name;
          md += '\n\n';
          md += m.description;
          md += '\n\n';
          if (m.examples && m.examples.length) {
            for (var j in m.examples) {
              md += '```javascript';
              md += '\n';
              md += m.examples[j];
              md += '\n';
              md += '```';
              md += '\n';
            }
          }
          md += '\n';
          if (m.params && m.params.length) {
            md += heading + '### Parameters';
            md += '\n\n';
            md += '| Name | Type | Default | Description |';
            md += '\n';
            md += '| --- | --- | --- | --- |';
            md += '\n';
            for (var j in m.params) {
              var p = m.params[j];
              md += '| ' + (p.name ? '`'+p.name+'`' : "&nbsp;");
              md += ' | ' + (p.type ? '`'+p.type+'`' : "&nbsp;");
              md += ' | ' + (p.default ? '`'+p.default+'`' : "&nbsp;");
              md += ' | ' + (p.description || "&nbsp;");
              md += ' |\n';
            }
            md += '\n';
          }
        }
      }
  
      if (doc.css && doc.css.length) {
        md += '<hr>\n';
        md += '<a name="css"></a>\n\n';
        md += heading + '# CSS';
        md += '\n\n';
        md += '| Class | Type | Description |';
        md += '\n';
        md += '| --- | --- | --- |';
        md += '\n';
        for (var i in doc.css) {
          var c = doc.css[i];
          md += '| ' + (c.name ? '`'+c.name+'`' : "&nbsp;");
          md += ' | ' + (c.type ? '`'+c.type+'`' : "&nbsp;");
          md += ' | ' + (c.description || "&nbsp;");
          md += ' |\n';
        }
        md += '\n';
      }
  
      return md;
    }