Package detail

ndoc

nodeca1kMIT6.0.1

JavaScript API documentor with simple syntax.

api, doc, apidoc, documentation

readme

NDoc - JavaScript documentation generator

CI

NDoc is an inline comment parser and JavaScript documentation generator written in Node.JS. This project was inspired by PDoc. It tries to keep compatibility, but has some differences:

  • NDoc is primarily a CLI tool, so you don't need to code your documentor, although it can be easily used as library.
  • Clarified EBNF syntax. Definitions now MUST be separated with an empty line from the following comments.
  • Added options for deprecated tag: you can set versions, when tag was deprecated and when method/property will be removed.
  • Added new tags: read-only, internal, chainable
  • Events support.

How to Install

We suppose that you already have Node and npm installed. If not - try nvm.

npm install -g ndoc

Usage

usage: ndoc [-h] [-v] [--exclude PATTERN] [-o PATH] [--use PLUGIN]
            [--alias MAPPING] [-r RENDERER] [--link-format FORMAT]
            [-t TEMPLATE] [--show-all] [--package PACKAGE] [--index FILE]
            [--gh-ribbon URL] [--broken-links ACTION] [--noenv]
            PATH[PATH ...]

Positional arguments:
  PATH                            Source files location

Optional arguments:
  -h, --help                      Show this help message and exit.
  -v, --version                   Show program's version number and exit.
  --exclude PATTERN               Glob patterns of filenames to exclude (you
                                  can use wildcards: ?, *, **).
  -o PATH, --output PATH          Resulting file(s) location.
  --use PLUGIN                    Load custom plugin.
  --alias MAPPING                 Registers extensions alias. For example
                                  `cc:js` will register `cc` extension as an
                                  alias of `js`
  -r RENDERER, --render RENDERER  Documentation renderer (html, json). More
                                  can be added by custom plugins.
  --link-format FORMAT            View sources link (no links by default)
                                  format. You can use `{file}` and `{line}`
                                  and any of `{package.*}` variables for
                                  interpolation.
  -t TEMPLATE, --title TEMPLATE   Documentation title template. You can use
                                  any of `{package.*}` variables for
                                  interpolation. DEFAULT: `{package.name}
                                  {package.version} API documentation`
  --show-all                      By default `internal` methods/properties
                                  are not shown. This trigger makes ndoc show
                                  all methods/properties
  --package PACKAGE               Read specified package.json FILE. When not
                                  specified, read ./package.json if such file
                                  exists.
  --index FILE                    Index file (with introduction text), e.g.
                                  README.md file.
  --gh-ribbon URL                 Add "Fork me on GitHub" ribbon with given
                                  URL. You can use any of `{package.*}`
                                  variables for interpolation.
  --broken-links ACTION           What to do if broken link occurred (show,
                                  hide, throw). DEFAULT: `show`.
  --noenv                         Ignore .ndocrc

Syntax

NDoc Syntax. It is similar to PDoc one, with some extensions (see start of this doc for details).

For developers

You can generate prototype documentation for test:

make test

Then open ./tests/prototype-doc/index.html.

Custom parsers and renderers

You can create and use your own parser/renderer via --use option. Get one of the parsers or renderers as a base template, copy it into separate folder. Create package.json and modify it to fit your needs. Then attach it with --use my-module argument.

Using NDoc as module

You can use NDoc as module, for example, to override default options processing.

var NDoc = require('ndoc');


var options = {
  linkFormat  : 'http://example.com/{file}#{line}',
  output:     : 'doc'
};

var ast;

try {
  ast = NDoc.parse(['lib/my-module.js'], options);
} catch (err) {
  console.error(err);
  process.exit(1);
}

try {
  NDoc.render('html', ast, options);
} catch (err) {
  console.error(err);
  process.exit(1);
}

License

This project is distributed under MIT license.

changelog

6.0.0 / 2020-11-19

  • Drop old node.js support (v12+ required).
  • Deps bump.
  • Fix warnings in node.js v14.

5.0.2 / 2020-11-17

  • Pin stylus version to fix icons.

5.0.1 / 2016-09-29

  • Fix broken gh-ribbon link (after migrating jade -> pug).

5.0.0 / 2016-09-09

  • Replace jade with pug.
  • npm3 compatibility in template's include directives.

4.0.1 / 2016-04-02

  • Fix: allow specify direct file paths in params (regression in 4.0.0).

4.0.0 / 2016-02-28

  • Maintenance release.
  • Refreshed dependencies, dropped outdated libs.
  • Migrated to markdown-it.
  • Minor styles tune.
  • CS update + migrate to eslint.

3.1.0 / 2013-06-24

  • Removed all async code, API is also sync now
  • Improved error reporting for invalid syntax (#72)
  • Different syntax fixes
  • Removed mincer, files are rendered directly

3.0.1 / 2013-06-19

  • Fixed signatures values (#70)
  • Changed generated reference links names to full format
  • Updated dependencies

3.0.0 / 2013-06-18

  • Completely rewritten syntax parser (jison -> pegjs)
  • Improved error reporting
  • Multiple fixes

2.0.5 / 2013-02-16

  • Fixed bug, that caused problems with new argparse
  • Updated dependencies
  • Updated linting rules

2.0.4 / 2012-08-09

  • Fixed main index file path (when ndoc used as library)
  • Updated dependencies versions

2.0.3 / 2012-07-29

  • Fixed name/prefix for nested event items. Thanks to @Sannis.

2.0.2 / 2012-07-19

  • Add --alias <from>:<to> option. Closes #58.
  • [API] cli.findFiles now support functions.

2.0.1 / 2012-07-08

  • Enhance .ndocrc reader to support comments.

2.0.0 / 2012-07-02

  • Internal methods are now skipped by default.
  • Stop on collisions, instead of warning
  • Bundled mode (all doc in single file), layout/styles cleanup.
  • Highlight on build time (no more hangs on big docs load)
  • Ability to add github ribbon.
  • Multiple folders/files support.
  • Parcers/Generators can be attached as external modules
  • Reorganized options (see new help).
  • Options can be loaded from file now.
  • Grand refactoring.
  • Multiple bugfixes (see ussue tracker).

1.0.7 / 2012-02-09

  • Improve error reporting.
  • Partial code cleanup.

1.0.6 / 2012-02-05

  • Fixed links to sources for windows (forced '\' to '/'). Closes #37. Thanks to Sascha Drews (perfusorius).

1.0.5 / 2012-01-04

  • Updated Marked version. Now supports ``` blocks. Thanks to Christopher Jeffrey (chjj).

1.0.4 / 2011-12-15

  • Styled new tags (read-only, internal, chainable). Closes #11.
  • Fixed signatures with complex params. Closes #30.

1.0.3 / 2011-12-14

  • Added events support,
  • Added nested arguments support in signatures (for callbacks & iterators)
  • Added back icons for global methods/properties

1.0.2 / 2011-12-13

  • Fixed highlight of last menu item after scroll, closes #17
  • Fixed boilerplate layout
  • Fixed missed slash in links to source code, closes #19

1.0.1 / 2011-12-07

  • Fixed default "view source" link for github

1.0.0 / 2011-12-07

  • Total refactoring + feature-complete now
  • Skin rewrite
  • Prototype as test

0.1.0 / 2011-11-24

  • First public release