mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
parent
c8ad087308
commit
67f8d9ead9
4
index.js
4
index.js
@ -102,7 +102,7 @@ module.exports = function (indexes, options, callback) {
|
||||
filterAccess(options.access,
|
||||
hierarchy(
|
||||
inputs
|
||||
.filter(filterJS(options.extension))
|
||||
.filter(filterJS(options.extension, options.polyglot))
|
||||
.reduce(function (memo, file) {
|
||||
return memo.concat(parseFn(file));
|
||||
}, [])
|
||||
@ -160,7 +160,7 @@ module.exports.lint = function lint(indexes, options, callback) {
|
||||
callback(null,
|
||||
formatLint(hierarchy(
|
||||
inputs
|
||||
.filter(filterJS(options.extension))
|
||||
.filter(filterJS(options.extension, options.polyglot))
|
||||
.reduce(function (memo, file) {
|
||||
return memo.concat(parseFn(file));
|
||||
}, [])
|
||||
|
||||
@ -9,12 +9,20 @@ var path = require('path');
|
||||
* This creates a filter function for use with Array.prototype.filter, which
|
||||
* expect as argument a file as an objectg with the 'file' property
|
||||
*
|
||||
* @public
|
||||
* @private
|
||||
* @param {String|Array} extensions to be filtered
|
||||
* @param {boolean} allowAll ignore the entire extension check and always
|
||||
* pass through files. This is used by the polglot mode.
|
||||
* @return {Function} a filter function, this function returns true if the input filename extension
|
||||
* is in the extension whitelist
|
||||
*/
|
||||
function filterJS(extensions) {
|
||||
function filterJS(extensions, allowAll) {
|
||||
|
||||
if (allowAll) {
|
||||
return function () {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
extensions = extensions || [];
|
||||
if (typeof extensions === 'string') {
|
||||
|
||||
22
test/bin.js
22
test/bin.js
@ -58,6 +58,28 @@ test('defaults to parsing package.json main', function (t) {
|
||||
});
|
||||
}, options);
|
||||
|
||||
test('polyglot mode', function (t) {
|
||||
documentation(['build fixture/polyglot/blend.cpp --polyglot'],
|
||||
function (err, data) {
|
||||
t.ifError(err);
|
||||
if (process.env.UPDATE) {
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname,
|
||||
'fixture',
|
||||
'polyglot/blend.json'), JSON.stringify(normalize(data), null, 2), 'utf8');
|
||||
}
|
||||
var expected = fs.readFileSync(
|
||||
path.resolve(__dirname,
|
||||
'fixture',
|
||||
'polyglot/blend.json'), 'utf8');
|
||||
t.deepEqual(
|
||||
normalize(data),
|
||||
JSON.parse(expected),
|
||||
'parsed C++ file');
|
||||
t.end();
|
||||
});
|
||||
}, options);
|
||||
|
||||
test('accepts config file', function (t) {
|
||||
documentation(['build fixture/sorting/input.js -c fixture/config.json'],
|
||||
function (err, data) {
|
||||
|
||||
86
test/fixture/polyglot/blend.json
vendored
Normal file
86
test/fixture/polyglot/blend.json
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
[
|
||||
{
|
||||
"description": "This method moves a hex to a color",
|
||||
"tags": [
|
||||
{
|
||||
"title": "name",
|
||||
"description": null,
|
||||
"lineNumber": 2,
|
||||
"name": "hexToUInt32Color"
|
||||
},
|
||||
{
|
||||
"title": "param",
|
||||
"description": null,
|
||||
"lineNumber": 3,
|
||||
"type": {
|
||||
"type": "NameExpression",
|
||||
"name": "string"
|
||||
},
|
||||
"name": "hex"
|
||||
},
|
||||
{
|
||||
"title": "returns",
|
||||
"description": "color",
|
||||
"lineNumber": 4,
|
||||
"type": {
|
||||
"type": "NameExpression",
|
||||
"name": "number"
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 35,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 40,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 35,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 40,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"file": "[path]"
|
||||
},
|
||||
"name": "hexToUInt32Color",
|
||||
"params": [
|
||||
{
|
||||
"title": "param",
|
||||
"description": null,
|
||||
"lineNumber": 3,
|
||||
"type": {
|
||||
"type": "NameExpression",
|
||||
"name": "string"
|
||||
},
|
||||
"name": "hex"
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
{
|
||||
"title": "returns",
|
||||
"description": "color",
|
||||
"lineNumber": 4,
|
||||
"type": {
|
||||
"type": "NameExpression",
|
||||
"name": "number"
|
||||
}
|
||||
}
|
||||
],
|
||||
"members": {
|
||||
"instance": [],
|
||||
"static": []
|
||||
},
|
||||
"path": [
|
||||
"hexToUInt32Color"
|
||||
]
|
||||
}
|
||||
]
|
||||
Loading…
x
Reference in New Issue
Block a user