Skip to content

Commit 43244d6

Browse files
committed
update es5 fallback
1 parent 8b68d80 commit 43244d6

4 files changed

Lines changed: 43 additions & 12 deletions

File tree

es5/cli-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports.definitions = [{
2222
name: 'conf',
2323
type: String,
2424
typeLabel: '[underline]{file}',
25-
description: 'Jsdoc config file.'
25+
description: 'Path to a jsdoc configuration file, passed directly to `jsdoc -c`.'
2626
}, {
2727
name: 'sort-by',
2828
type: String,

es5/jsdoc-parse.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ var util = require('util');
88
var a = require('array-tools');
99
var o = require('object-tools');
1010
var fs = require('fs');
11-
var mfs = require('more-fs');
1211
var fileSet = require('file-set');
1312
var Transform = require('stream').Transform;
1413
var cliOptions = require('./cli-options');
1514
var os = require('os');
15+
var tempPath = require('temp-path');
1616

1717
module.exports = jsdocParse;
1818
jsdocParse.cliOptions = cliOptions.definitions;
@@ -62,7 +62,7 @@ function jsdocParse(options) {
6262
return output;
6363
} else {
6464
var inputStream = new Transform();
65-
var inputFilePath = mfs.getTempFilePath() + '.js';
65+
var inputFilePath = tempPath();
6666

6767
var buf = new Buffer(0);
6868
inputStream._transform = function (chunk, enc, done) {
@@ -85,7 +85,7 @@ function jsdocParse(options) {
8585
done(err);
8686
}
8787
}
88-
mfs.deleteFile(inputFilePath);
88+
fs.unlinkSync(inputFilePath);
8989
});
9090
};
9191
return inputStream;
@@ -113,7 +113,7 @@ function OutputTransform(options) {
113113
util.inherits(OutputTransform, Transform);
114114

115115
function getJsdocOutput(src, options, done) {
116-
var jsdocTemplatePath = path.resolve(__dirname, '..', 'lib');
116+
var jsdocTemplatePath = __dirname;
117117
var jsdocPath = path.resolve(__dirname, '../node_modules/.bin/jsdoc');
118118

119119
if (!fs.existsSync(jsdocPath)) {
@@ -127,9 +127,9 @@ function getJsdocOutput(src, options, done) {
127127
}
128128
args = args.concat(src);
129129

130-
var outputFilePath = os.tmpdir() + '/jsdoc-stdout.json';
130+
var outputFilePath = tempPath();
131131
var outputFile = fs.openSync(outputFilePath, 'w');
132-
var outputStderrPath = os.tmpdir() + '/jsdoc-stderr.json';
132+
var outputStderrPath = tempPath();
133133
var outputStderr = fs.openSync(outputStderrPath, 'w');
134134
var handle = cp.spawn('node', args, { stdio: [process.stdin, outputFile, outputStderr] });
135135
handle.on('error', done);

es5/publish.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ var transform = require('./transform');
66

77
exports.publish = function (data) {
88
var query = { '!undocumented': true, '!kind': /package|file/ };
9-
var json = a.where(data().get(), query);
9+
var json = data().get().filter(function (i) {
10+
if (i.kind === 'class') {
11+
return true;
12+
} else {
13+
return !i.undocumented && !/package|file/.test(i.kind);
14+
}
15+
});
1016

1117
json = json.map(transform.setIsExportedFlag);
1218
json = json.map(transform.setCodename);

es5/transform.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ function setID(identifier) {
3737
identifier.id = identifier.longname;
3838
}
3939
if (identifier.kind === 'constructor') {
40-
identifier.id = identifier.longname + '()';
40+
if (identifier.scope === 'static') {
41+
identifier.id = identifier.longname;
42+
delete identifier.scope;
43+
} else {
44+
identifier.id = identifier.longname + '()';
45+
}
4146
}
4247
if (identifier.isExported) {
4348
identifier.id = identifier.longname + '--' + identifier.codeName;
@@ -88,10 +93,26 @@ function createConstructor(class_) {
8893

8994
function insertConstructors(data) {
9095
var replacements = [];
96+
var toDelete = [];
9197

9298
data.forEach(function (identifier, index) {
93-
if (identifier.kind === 'class') {
94-
replacements.push({ index: index, items: createConstructor(identifier) });
99+
if (identifier.kind === 'class' && identifier.scope !== 'static') {
100+
var es6constructor = a.findWhere(data, { kind: 'class', scope: 'static', memberof: identifier.longname });
101+
if (es6constructor) {
102+
if (!(es6constructor.description || es6constructor.params && es6constructor.params.length)) {
103+
toDelete.push(es6constructor);
104+
}
105+
es6constructor.kind = 'constructor';
106+
var constructorChildren = a.where(data, { memberof: es6constructor.longname });
107+
constructorChildren.forEach(function (i) {
108+
i.memberof = identifier.longname;
109+
});
110+
identifier.description = identifier.classdesc;
111+
delete identifier.classdesc;
112+
delete identifier.params;
113+
} else {
114+
replacements.push({ index: index, items: createConstructor(identifier) });
115+
}
95116
}
96117
});
97118

@@ -100,6 +121,10 @@ function insertConstructors(data) {
100121
data.splice.apply(data, spliceArgs);
101122
});
102123

124+
toDelete.forEach(function (d) {
125+
data.splice(data.indexOf(d), 1);
126+
});
127+
103128
return data;
104129
}
105130

@@ -238,7 +263,7 @@ function sort(object, sortFunction) {
238263
}
239264

240265
function sortIdentifier(identifier) {
241-
var fieldOrder = ['id', 'longname', 'name', 'scope', 'kind', 'isExported', 'classdesc', 'augments', 'inherits', 'inherited', 'overrides', 'mixes', 'description', 'memberof', 'alias', 'params', 'fires', 'examples', 'returns', 'type', 'defaultvalue', 'readonly', 'thisvalue', 'isEnum', 'properties', 'optional', 'nullable', 'variable', 'author', 'deprecated', 'ignore', 'access', 'requires', 'version', 'since', 'licenses', 'license', 'typicalname', 'category', 'see', 'exceptions', 'codeName', 'todoList', 'customTags', 'chainable', 'order'];
266+
var fieldOrder = ['id', 'longname', 'name', 'scope', 'kind', 'isExported', 'classdesc', 'augments', 'inherits', 'inherited', 'implements', 'overrides', 'mixes', 'description', 'memberof', 'alias', 'params', 'fires', 'examples', 'returns', 'type', 'defaultvalue', 'readonly', 'thisvalue', 'isEnum', 'properties', 'optional', 'nullable', 'variable', 'author', 'deprecated', 'ignore', 'access', 'requires', 'version', 'since', 'licenses', 'license', 'typicalname', 'category', 'see', 'exceptions', 'codeName', 'todoList', 'customTags', 'chainable', 'meta', 'order'];
242267
return sort(identifier, function (a, b) {
243268
if (fieldOrder.indexOf(a) === -1 && fieldOrder.indexOf(b) > -1) {
244269
return 1;

0 commit comments

Comments
 (0)