From 4dab786a394da2fc3ea2d59e9f796a6bee2b97dc Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 20 May 2016 16:49:16 -0400 Subject: [PATCH] Use explicit --access=public. Fixes #213 --- index.js | 5 +- lib/commands/build.js | 2 +- package.json | 2 +- test/fixture/inline-link.input.js | 4 +- test/fixture/inline-link.output.json | 109 ++++++++++++++++++++---- test/fixture/inline-link.output.md | 4 +- test/fixture/inline-link.output.md.json | 87 +++++++++++++++++-- 7 files changed, 182 insertions(+), 31 deletions(-) diff --git a/index.js b/index.js index 54a2b70..1bc7ea8 100644 --- a/index.js +++ b/index.js @@ -57,7 +57,6 @@ function expandInputs(indexes, options, callback) { * Generate JavaScript documentation as a list of parsed JSDoc * comments, given a root file as a path. * - * @alias documentation * @param {Array|string} indexes files to process * @param {Object} options options * @param {Array} options.external a string regex / glob match pattern @@ -78,8 +77,9 @@ function expandInputs(indexes, options, callback) { * @param {Function} callback to be called when the documentation generation * is complete, with (err, result) argumentsj * @returns {undefined} calls callback + * @public */ -module.exports = function (indexes, options, callback) { +module.exports.build = function (indexes, options, callback) { options = options || {}; options.hljs = options.hljs || {}; @@ -143,6 +143,7 @@ module.exports = function (indexes, options, callback) { * @param {Function} callback to be called when the documentation generation * is complete, with (err, result) argumentsj * @returns {undefined} calls callback + * @public */ module.exports.lint = function lint(indexes, options, callback) { options = options || {}; diff --git a/lib/commands/build.js b/lib/commands/build.js index f51308b..6733767 100644 --- a/lib/commands/build.js +++ b/lib/commands/build.js @@ -50,7 +50,7 @@ function build(documentation, parsedArgs, callback) { hljs: options.hljs || {} }; - var generator = documentation.bind(null, inputs, options, onDocumented); + var generator = documentation.build.bind(null, inputs, options, onDocumented); function onDocumented(err, comments) { if (err) { diff --git a/package.json b/package.json index 0686d84..83384f1 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ }, "scripts": { "lint": "eslint bin lib index.js test", - "doc": "documentation index.js -f md > docs/NODE_API.md", + "doc": "documentation index.js -f md --access=public > docs/NODE_API.md", "test": "npm run lint && tap -t 120 --coverage test/*.js test/lib test/streams" } } diff --git a/test/fixture/inline-link.input.js b/test/fixture/inline-link.input.js index 5eec0d9..f7632af 100644 --- a/test/fixture/inline-link.input.js +++ b/test/fixture/inline-link.input.js @@ -9,7 +9,9 @@ function addOne(a) { /** * This function returns the number one. Internally, this uses - * {@link addOne} to do the math. + * {@link addOne} to do the math. This demonstrates + * {@link https://en.wikipedia.org/wiki/Addition Addition} + * and {@link https://en.wikipedia.org/wiki/Addition} * @param {number} a the input * @returns {number} numberone */ diff --git a/test/fixture/inline-link.output.json b/test/fixture/inline-link.output.json index 75049cd..e27455a 100644 --- a/test/fixture/inline-link.output.json +++ b/test/fixture/inline-link.output.json @@ -94,7 +94,7 @@ "column": 1 } }, - "code": "/**\n * Adds one to a number\n * @param {number} a the input\n * @returns {number} the output\n */\nfunction addOne(a) {\n return a + 1;\n}\n\n/**\n * This function returns the number one. Internally, this uses\n * {@link addOne} to do the math.\n * @param {number} a the input\n * @returns {number} numberone\n */\nmodule.exports = function (a) {\n return addOne(a);\n};\n" + "code": "/**\n * Adds one to a number\n * @param {number} a the input\n * @returns {number} the output\n */\nfunction addOne(a) {\n return a + 1;\n}\n\n/**\n * This function returns the number one. Internally, this uses\n * {@link addOne} to do the math. This demonstrates\n * {@link https://en.wikipedia.org/wiki/Addition Addition}\n * and {@link https://en.wikipedia.org/wiki/Addition}\n * @param {number} a the input\n * @returns {number} numberone\n */\nmodule.exports = function (a) {\n return addOne(a);\n};\n" }, "errors": [], "params": [ @@ -286,7 +286,7 @@ }, { "type": "text", - "value": " to do the math.", + "value": " to do the math. This demonstrates\n", "position": { "start": { "line": 2, @@ -294,9 +294,80 @@ "offset": 74 }, "end": { - "line": 2, - "column": 31, - "offset": 90 + "line": 3, + "column": 1, + "offset": 109 + }, + "indent": [ + 1 + ] + } + }, + { + "type": "link", + "url": "https://en.wikipedia.org/wiki/Addition", + "title": null, + "jsdoc": true, + "children": [ + { + "type": "text", + "value": "Addition" + } + ], + "position": { + "start": { + "line": 3, + "column": 1, + "offset": 109 + }, + "end": { + "line": 3, + "column": 56, + "offset": 164 + }, + "indent": [] + } + }, + { + "type": "text", + "value": "\nand ", + "position": { + "start": { + "line": 3, + "column": 56, + "offset": 164 + }, + "end": { + "line": 4, + "column": 5, + "offset": 169 + }, + "indent": [ + 1 + ] + } + }, + { + "type": "link", + "url": "https://en.wikipedia.org/wiki/Addition", + "title": null, + "jsdoc": true, + "children": [ + { + "type": "text", + "value": "https://en.wikipedia.org/wiki/Addition" + } + ], + "position": { + "start": { + "line": 4, + "column": 5, + "offset": 169 + }, + "end": { + "line": 4, + "column": 51, + "offset": 215 }, "indent": [] } @@ -309,11 +380,13 @@ "offset": 0 }, "end": { - "line": 2, - "column": 31, - "offset": 90 + "line": 4, + "column": 51, + "offset": 215 }, "indent": [ + 1, + 1, 1 ] } @@ -326,9 +399,9 @@ "offset": 0 }, "end": { - "line": 2, - "column": 31, - "offset": 90 + "line": 4, + "column": 51, + "offset": 215 } } }, @@ -336,7 +409,7 @@ { "title": "param", "description": "the input", - "lineNumber": 3, + "lineNumber": 5, "type": { "type": "NameExpression", "name": "number" @@ -346,7 +419,7 @@ { "title": "returns", "description": "numberone", - "lineNumber": 4, + "lineNumber": 6, "type": { "type": "NameExpression", "name": "number" @@ -359,28 +432,28 @@ "column": 0 }, "end": { - "line": 15, + "line": 17, "column": 3 } }, "context": { "loc": { "start": { - "line": 16, + "line": 18, "column": 0 }, "end": { - "line": 18, + "line": 20, "column": 2 } }, - "code": "/**\n * Adds one to a number\n * @param {number} a the input\n * @returns {number} the output\n */\nfunction addOne(a) {\n return a + 1;\n}\n\n/**\n * This function returns the number one. Internally, this uses\n * {@link addOne} to do the math.\n * @param {number} a the input\n * @returns {number} numberone\n */\nmodule.exports = function (a) {\n return addOne(a);\n};\n" + "code": "/**\n * Adds one to a number\n * @param {number} a the input\n * @returns {number} the output\n */\nfunction addOne(a) {\n return a + 1;\n}\n\n/**\n * This function returns the number one. Internally, this uses\n * {@link addOne} to do the math. This demonstrates\n * {@link https://en.wikipedia.org/wiki/Addition Addition}\n * and {@link https://en.wikipedia.org/wiki/Addition}\n * @param {number} a the input\n * @returns {number} numberone\n */\nmodule.exports = function (a) {\n return addOne(a);\n};\n" }, "errors": [], "params": [ { "name": "a", - "lineNumber": 3, + "lineNumber": 5, "description": { "type": "root", "children": [ diff --git a/test/fixture/inline-link.output.md b/test/fixture/inline-link.output.md index d051d29..e1ebae7 100644 --- a/test/fixture/inline-link.output.md +++ b/test/fixture/inline-link.output.md @@ -11,7 +11,9 @@ Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer # inline-link.input This function returns the number one. Internally, this uses -[addOne](addOne) to do the math. +[addOne](addOne) to do the math. This demonstrates +[Addition](https://en.wikipedia.org/wiki/Addition) +and **Parameters** diff --git a/test/fixture/inline-link.output.md.json b/test/fixture/inline-link.output.md.json index 35cd2e9..594ac1c 100644 --- a/test/fixture/inline-link.output.md.json +++ b/test/fixture/inline-link.output.md.json @@ -257,7 +257,7 @@ }, { "type": "text", - "value": " to do the math.", + "value": " to do the math. This demonstrates\n", "position": { "start": { "line": 2, @@ -265,9 +265,80 @@ "offset": 74 }, "end": { - "line": 2, - "column": 31, - "offset": 90 + "line": 3, + "column": 1, + "offset": 109 + }, + "indent": [ + 1 + ] + } + }, + { + "type": "link", + "url": "https://en.wikipedia.org/wiki/Addition", + "title": null, + "jsdoc": true, + "children": [ + { + "type": "text", + "value": "Addition" + } + ], + "position": { + "start": { + "line": 3, + "column": 1, + "offset": 109 + }, + "end": { + "line": 3, + "column": 56, + "offset": 164 + }, + "indent": [] + } + }, + { + "type": "text", + "value": "\nand ", + "position": { + "start": { + "line": 3, + "column": 56, + "offset": 164 + }, + "end": { + "line": 4, + "column": 5, + "offset": 169 + }, + "indent": [ + 1 + ] + } + }, + { + "type": "link", + "url": "https://en.wikipedia.org/wiki/Addition", + "title": null, + "jsdoc": true, + "children": [ + { + "type": "text", + "value": "https://en.wikipedia.org/wiki/Addition" + } + ], + "position": { + "start": { + "line": 4, + "column": 5, + "offset": 169 + }, + "end": { + "line": 4, + "column": 51, + "offset": 215 }, "indent": [] } @@ -280,11 +351,13 @@ "offset": 0 }, "end": { - "line": 2, - "column": 31, - "offset": 90 + "line": 4, + "column": 51, + "offset": 215 }, "indent": [ + 1, + 1, 1 ] }