Skip to content

Commit

Permalink
Implement API documentation using npm:documantation.
Browse files Browse the repository at this point in the history
Fixes #3138
Replaces and closes #3239

basically working

Suite and utils work

Runner and Suite datatypes work

Hook extends Runnable - at least link in description

hook is child of mocha and has error

first solid pass

Remove attempted module link from Hook to Runnable because of documentationjs/documentation#820

Switch API documenation to html output, link to them, include in site build

Update TOC

Bring lock file in sync with package.json

Linting

Update package-lock.json
  • Loading branch information
dfberry authored and boneskull committed Apr 12, 2018
1 parent 741b0bd commit 63462dd
Show file tree
Hide file tree
Showing 28 changed files with 5,885 additions and 1,645 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ yarn.lock
*_REMOTE_*
docs/_site
docs/_dist
docs/api
.vscode/

3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js](https://n

- [Installation](#installation)
- [Getting Started](#getting-started)
- [Detects Multiple Calls to `done()`](#detects-multiple-calls-to-done)
- [Assertions](#assertions)
- [Asynchronous Code](#asynchronous-code)
- [Synchronous Code](#synchronous-code)
Expand Down Expand Up @@ -1343,4 +1344,4 @@ $ REPORTER=nyan npm test

## More Information

In addition to chatting with us on [Gitter](https://gitter.im/mochajs/mocha), for additional information such as using spies, mocking, and shared behaviours be sure to check out the [Mocha Wiki](https://github.com/mochajs/mocha/wiki) on GitHub. For discussions join the [Google Group](https://groups.google.com/group/mochajs). For a running example of Mocha, view [example/tests.html](example/tests.html). For the JavaScript API, view the [source](https://github.com/mochajs/mocha/blob/master/lib/mocha.js#L51).
In addition to chatting with us on [Gitter](https://gitter.im/mochajs/mocha), for additional information such as using spies, mocking, and shared behaviours be sure to check out the [Mocha Wiki](https://github.com/mochajs/mocha/wiki) on GitHub. For discussions join the [Google Group](https://groups.google.com/group/mochajs). For a running example of Mocha, view [example/tests.html](example/tests.html). For the JavaScript API, view the [API documentation](api/) or the [source](https://github.com/mochajs/mocha/blob/master/lib/mocha.js#L51).
6 changes: 4 additions & 2 deletions lib/context.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

/**
* @module Context
*/
/**
* Expose `Context`.
*/
Expand All @@ -18,7 +20,7 @@ function Context () {}
*
* @api private
* @param {Runnable} runnable
* @return {Context}
* @return {Context} context
*/
Context.prototype.runnable = function (runnable) {
if (!arguments.length) {
Expand Down
13 changes: 11 additions & 2 deletions lib/hook.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

/**
* @module Hook
*
*/
/**
* Module dependencies.
*/
Expand All @@ -14,8 +17,12 @@ var inherits = require('./utils').inherits;
module.exports = Hook;

/**
* Initialize a new `Hook` with the given `title` and callback `fn`.
* Initialize a new `Hook` with the given `title` and callback `fn`. Derived from
* `Runnable`.
*
* @memberof Mocha
* @public
* @class
* @param {String} title
* @param {Function} fn
* @api private
Expand All @@ -33,6 +40,8 @@ inherits(Hook, Runnable);
/**
* Get or set the test `err`.
*
* @memberof Mocha.Hook
* @public
* @param {Error} err
* @return {Error}
* @api public
Expand Down
45 changes: 43 additions & 2 deletions lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/

/**
* @namespace Mocha
* @module Mocha
*/
/**
* Module dependencies.
*/
Expand Down Expand Up @@ -34,11 +37,25 @@ if (!process.browser) {
* Expose internals.
*/

/**
* @public
* @class utils
* @memberof Mocha
*/
exports.utils = utils;
exports.interfaces = require('./interfaces');
/**
*
* @memberof Mocha
* @public
*/
exports.reporters = reporters;
exports.Runnable = require('./runnable');
exports.Context = require('./context');
/**
*
* @memberof Mocha
*/
exports.Runner = require('./runner');
exports.Suite = require('./suite');
exports.Hook = require('./hook');
Expand Down Expand Up @@ -71,6 +88,8 @@ function image (name) {
* - `fullTrace` display the full stack-trace on failing
* - `grep` string or regexp to filter tests with
*
* @public
* @class Mocha
* @param {Object} options
* @api public
*/
Expand Down Expand Up @@ -106,6 +125,7 @@ function Mocha (options) {
/**
* Enable or disable bailing on the first failure.
*
* @public
* @api public
* @param {boolean} [bail]
*/
Expand All @@ -120,6 +140,7 @@ Mocha.prototype.bail = function (bail) {
/**
* Add test `file`.
*
* @public
* @api public
* @param {string} file
*/
Expand All @@ -131,6 +152,7 @@ Mocha.prototype.addFile = function (file) {
/**
* Set reporter to `reporter`, defaults to "spec".
*
* @public
* @param {String|Function} reporter name or constructor
* @param {Object} reporterOptions optional options
* @api public
Expand Down Expand Up @@ -181,7 +203,7 @@ Mocha.prototype.reporter = function (reporter, reporterOptions) {

/**
* Set test UI `name`, defaults to "bdd".
*
* @public
* @api public
* @param {string} bdd
*/
Expand Down Expand Up @@ -260,6 +282,7 @@ Mocha.prototype._growl = function (runner, reporter) {
/**
* Escape string and add it to grep as a regexp.
*
* @public
* @api public
* @param str
* @returns {Mocha}
Expand All @@ -271,6 +294,7 @@ Mocha.prototype.fgrep = function (str) {
/**
* Add regexp to grep, if `re` is a string it is escaped.
*
* @public
* @param {RegExp|String} re
* @return {Mocha}
* @api public
Expand All @@ -290,6 +314,7 @@ Mocha.prototype.grep = function (re) {
/**
* Invert `.grep()` matches.
*
* @public
* @return {Mocha}
* @api public
*/
Expand All @@ -301,6 +326,7 @@ Mocha.prototype.invert = function () {
/**
* Ignore global leaks.
*
* @public
* @param {Boolean} ignore
* @return {Mocha}
* @api public
Expand All @@ -317,6 +343,7 @@ Mocha.prototype.ignoreLeaks = function (ignore) {
*
* @return {Mocha}
* @api public
* @public
*/
Mocha.prototype.checkLeaks = function () {
this.options.ignoreLeaks = false;
Expand All @@ -328,6 +355,7 @@ Mocha.prototype.checkLeaks = function () {
*
* @return {Mocha}
* @api public
* @public
*/
Mocha.prototype.fullTrace = function () {
this.options.fullStackTrace = true;
Expand All @@ -339,6 +367,7 @@ Mocha.prototype.fullTrace = function () {
*
* @return {Mocha}
* @api public
* @public
*/
Mocha.prototype.growl = function () {
this.options.growl = true;
Expand All @@ -351,6 +380,7 @@ Mocha.prototype.growl = function () {
* @param {Array|String} globals
* @return {Mocha}
* @api public
* @public
* @param {Array|string} globals
* @return {Mocha}
*/
Expand All @@ -365,6 +395,7 @@ Mocha.prototype.globals = function (globals) {
* @param {Boolean} colors
* @return {Mocha}
* @api public
* @public
* @param {boolean} colors
* @return {Mocha}
*/
Expand All @@ -381,6 +412,7 @@ Mocha.prototype.useColors = function (colors) {
* @param {Boolean} inlineDiffs
* @return {Mocha}
* @api public
* @public
* @param {boolean} inlineDiffs
* @return {Mocha}
*/
Expand All @@ -395,6 +427,7 @@ Mocha.prototype.useInlineDiffs = function (inlineDiffs) {
* @param {Boolean} hideDiff
* @return {Mocha}
* @api public
* @public
* @param {boolean} hideDiff
* @return {Mocha}
*/
Expand All @@ -409,6 +442,7 @@ Mocha.prototype.hideDiff = function (hideDiff) {
* @param {Number} timeout
* @return {Mocha}
* @api public
* @public
* @param {number} timeout
* @return {Mocha}
*/
Expand All @@ -423,6 +457,7 @@ Mocha.prototype.timeout = function (timeout) {
* @param {Number} retry times
* @return {Mocha}
* @api public
* @public
*/
Mocha.prototype.retries = function (n) {
this.suite.retries(n);
Expand All @@ -435,6 +470,7 @@ Mocha.prototype.retries = function (n) {
* @param {Number} slow
* @return {Mocha}
* @api public
* @public
* @param {number} slow
* @return {Mocha}
*/
Expand All @@ -449,6 +485,7 @@ Mocha.prototype.slow = function (slow) {
* @param {Boolean} enabled
* @return {Mocha}
* @api public
* @public
* @param {boolean} enabled
* @return {Mocha}
*/
Expand All @@ -462,6 +499,7 @@ Mocha.prototype.enableTimeouts = function (enabled) {
*
* @return {Mocha}
* @api public
* @public
*/
Mocha.prototype.asyncOnly = function () {
this.options.asyncOnly = true;
Expand All @@ -472,6 +510,7 @@ Mocha.prototype.asyncOnly = function () {
* Disable syntax highlighting (in browser).
*
* @api public
* @public
*/
Mocha.prototype.noHighlighting = function () {
this.options.noHighlighting = true;
Expand All @@ -483,6 +522,7 @@ Mocha.prototype.noHighlighting = function () {
*
* @return {Mocha}
* @api public
* @public
*/
Mocha.prototype.allowUncaught = function () {
this.options.allowUncaught = true;
Expand Down Expand Up @@ -528,6 +568,7 @@ Mocha.prototype.forbidPending = function () {
* cache first in whichever manner best suits your needs.
*
* @api public
* @public
* @param {Function} fn
* @return {Runner}
*/
Expand Down
6 changes: 5 additions & 1 deletion lib/ms.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

/**
* @module milliseconds
*/
/**
* Helpers.
*/
Expand All @@ -13,6 +15,8 @@ var y = d * 365.25;
/**
* Parse or format the given `val`.
*
* @memberof Mocha
* @public
* @api public
* @param {string|number} val
* @return {string|number}
Expand Down
12 changes: 11 additions & 1 deletion lib/reporters/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

/**
* @module Base
*/
/**
* Module dependencies.
*/
Expand Down Expand Up @@ -185,6 +187,9 @@ var generateDiff = exports.generateDiff = function (actual, expected) {
/**
* Output the given `failures` as a list.
*
* @public
* @memberof Mocha.reporters.Base
* @variation 1
* @param {Array} failures
* @api public
*/
Expand Down Expand Up @@ -261,6 +266,9 @@ exports.list = function (failures) {
* stats such as test duration, number
* of tests passed / failed etc.
*
* @memberof Mocha.reporters
* @public
* @class
* @param {Runner} runner
* @api public
*/
Expand Down Expand Up @@ -328,6 +336,8 @@ function Base (runner) {
* Output common epilogue used by many of
* the bundled reporters.
*
* @memberof Mocha.reporters.Base
* @public
* @api public
*/
Base.prototype.epilogue = function () {
Expand Down
8 changes: 7 additions & 1 deletion lib/reporters/doc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

/**
* @module Doc
*/
/**
* Module dependencies.
*/
Expand All @@ -16,6 +18,10 @@ exports = module.exports = Doc;
/**
* Initialize a new `Doc` reporter.
*
* @class
* @memberof Mocha.reporters
* @extends {Base}
* @public
* @param {Runner} runner
* @api public
*/
Expand Down
8 changes: 7 additions & 1 deletion lib/reporters/dot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

/**
* @module Dot
*/
/**
* Module dependencies.
*/
Expand All @@ -17,6 +19,10 @@ exports = module.exports = Dot;
/**
* Initialize a new `Dot` matrix test reporter.
*
* @class
* @memberof Mocha.reporters
* @extends Mocha.reporters.Base
* @public
* @api public
* @param {Runner} runner
*/
Expand Down
Loading

0 comments on commit 63462dd

Please sign in to comment.