Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps and lint #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
"doc"
],
"dependencies": {
"bluebird": "^3.5.3",
"fs-extra": "^7.0.1",
"glob": "^7.1.3",
"jsdoc": "^3.5.5",
"bluebird": "^3.7.0",
"fs-extra": "^8.1.0",
"glob": "^7.1.4",
"jsdoc": "^3.6.3",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.11",
"tmp": "0.0.33"
"lodash": "^4.17.15",
"tmp": "0.1.0"
},
"devDependencies": {
"eslint": "^5.9.0",
"eslint-config-xo": "^0.25.0",
"jasmine": "^3.3.0",
"eslint": "^6.5.1",
"eslint-config-xo": "^0.27.1",
"jasmine": "^3.5.0",
"jasmine-console-reporter": "^3.1.0",
"jsdoc-strip-async-await": "^0.1.0"
}
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function buildArgs(options) {
if (_.isString(opts.package)) {
args.push('-P', opts.package);
}

if (opts.recurse) args.push('-r');
if (opts.pedantic) args.push('--pedantic');
if (opts.query) args.push('-q', opts.query);
Expand Down Expand Up @@ -125,6 +126,7 @@ function normalizeAccess(access) {
if (!_.isString(access) && !_.isArray(access)) {
return ['public', 'protected'];
}

return helper.ensureArray(access);
}

Expand Down Expand Up @@ -177,6 +179,7 @@ function hierarchy(docs, sortType) {
// reverse bec. we used eachRight
parent.$members.reverse();
}

docs.splice(index, 1);
}
}
Expand Down Expand Up @@ -269,6 +272,7 @@ jsdocx.filter = (docs, options, predicate) => {
memo.push(symbol); // original symbol pushed
}
}

return memo;
}, []);

Expand All @@ -277,6 +281,7 @@ jsdocx.filter = (docs, options, predicate) => {
} else if (options.sort) {
sortDocs(docs, options.sort);
}

return docs;
};

Expand Down Expand Up @@ -317,6 +322,7 @@ jsdocx.parse = (options, callback) => {
return opts;
});
}

if (hasSource) {
return helper.createTempFile(opts.source)
.then(file => {
Expand All @@ -339,6 +345,7 @@ jsdocx.parse = (options, callback) => {
if (options.output) {
return helper.writeJSON(options.output, docs);
}

return docs;
})
.catch(err => {
Expand All @@ -350,6 +357,7 @@ jsdocx.parse = (options, callback) => {
err.message = err.message + ' \nExecuted JSDoc Command: ' + cmd + '\n'
+ 'with JSON configuration: ' + JSON.stringify(conf || {});
}

throw err;
})
.nodeify(callback);
Expand Down
1 change: 1 addition & 0 deletions src/lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const helper = {
try {
out = JSON.parse(string);
} catch (e) {}

return out;
},

Expand Down
8 changes: 8 additions & 0 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function bracket(prop) {
const re = /^[a-z$_][a-z\d$_]*$/i; // non-bracket notation
return re.test(prop) ? '.' + prop : '["' + prop + '"]';
}

// fixes a jsdoc bug
// e.g. MyClass.Enum."STATE"] —» MyClass.Enum.STATE
function fixBracket(notation) {
Expand Down Expand Up @@ -40,6 +41,7 @@ function notate(obj, notation) {
props.shift();
return notate(o, props);
}

return o;
}

Expand Down Expand Up @@ -105,6 +107,7 @@ const utils = {
const codeName = getMetaCodeName(symbol);
if (codeName) return codeName.replace(/.*?[#.~:](\w+)$/i, '$1');
}

return symbol.name;
},

Expand Down Expand Up @@ -194,10 +197,12 @@ const utils = {
&& /^".*"$/.test(symbol.memberof) === false) {
return cleanName(symbol.memberof);
}

longname = cleanName(symbol.$longname);
} else {
longname = cleanName(symbol);
}

// colon (:) is not a level separator. JSDoc uses colon in cases like:
// `obj~event:ready` or `module:someModule`
if (!longname || !(/[.#~]/g).test(longname)) return '';
Expand Down Expand Up @@ -243,11 +248,13 @@ const utils = {
|| utils.getCodeName(symbol) === name) {
return symbol;
}

if (symbol.$members) {
const sym = utils.getSymbolByName(symbol.$members, name);
if (sym) return sym;
}
}

return null;
},

Expand Down Expand Up @@ -727,6 +734,7 @@ const utils = {
// console.log('comparing:', A, '<<—>>', B, '==>', result);
};
}

// grouped sort (by scope). also moving inner symbols to end.
return (a, b) => {
const A = prop ? a[prop] : a;
Expand Down
1 change: 1 addition & 0 deletions test/conf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ describe('JSDoc configuration options', () => {
function throwTest() {
jsdocx.parse({ files: '' });
}

expect(throwTest).toThrow();
});

Expand Down
1 change: 1 addition & 0 deletions test/parse.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Test: Parser', () => {
function throwTest() {
jsdocx.parse(undefined);
}

expect(throwTest).toThrow();
});

Expand Down
7 changes: 7 additions & 0 deletions test/sort.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ function logSortedDocs(docs, nPrefix = '') {
console.log(` ${pad(i++, 4)} > prop: ${prop.name}`);
});
}

if (Array.isArray(symbol.$members)) {
logSortedDocs(symbol.$members, i + '.');
}

i++;
});
}
Expand Down Expand Up @@ -62,6 +64,7 @@ describe('Test: Sorter', () => {
'aGlobalObject2',
'Code', // class
'Code', // constructor
'Code', // ?
'Code#bProtectedInstanceProp',
'Code.bStaticMethod',
'Code#config',
Expand Down Expand Up @@ -118,6 +121,7 @@ describe('Test: Sorter', () => {
'aGlobalObject2', // global
'Code', // global
'Code', // global
'Code', // global
'fGlobalObjExt', // global
'gGlobalArray', // global
'gGlobalArray2', // global
Expand Down Expand Up @@ -175,6 +179,7 @@ describe('Test: Sorter', () => {
'aGlobalObject2', // public
'Code', // public
'Code', // public
'Code', // public
'Code.bStaticMethod', // public
'Code#config', // public
'Code#config._opt', // public
Expand Down Expand Up @@ -234,6 +239,7 @@ describe('Test: Sorter', () => {
'kGlobalObjExt', // constant
'Code', // constructor
'Code', // class
'Code', // ?
'Code.bStaticMethod', // method
'Code#instanceMethod', // method
'Code.staticMethod', // method
Expand Down Expand Up @@ -302,6 +308,7 @@ describe('Test: Sorter', () => {
'aGlobalObject2', // global public property
'Code', // global public constructor
'Code', // global public class
'Code', // global public class
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dublicate rule

'fGlobalObjExt', // global public property
'gGlobalArray', // global public property
'gGlobalArray2', // global public property
Expand Down