mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
undo some unnecessary (and possibly harmful) changes to method signatures
This commit is contained in:
parent
dbfdf946c1
commit
9433b863b0
@ -18,6 +18,10 @@ var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
exports.Parser = function() {
|
||||
this._currentSourceName = '';
|
||||
this._resultBuffer = [];
|
||||
this._comments = {
|
||||
original: [],
|
||||
modified: []
|
||||
};
|
||||
//Initialize a global ref to store global members
|
||||
this.refs = {
|
||||
__global__: {
|
||||
@ -113,6 +117,10 @@ exports.Parser.prototype.addResult = function(o) {
|
||||
exports.Parser.prototype.clear = function() {
|
||||
this._currentSourceName = '';
|
||||
this._resultBuffer = [];
|
||||
this._comments = {
|
||||
original: [],
|
||||
modified: []
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@ -347,7 +355,7 @@ function getRange(node) {
|
||||
/** @private
|
||||
* @memberof module:src/parser.Parser
|
||||
*/
|
||||
exports.Parser.prototype._makeEvent = function(node, comments, extras) {
|
||||
exports.Parser.prototype._makeEvent = function(node, extras) {
|
||||
extras = extras || {};
|
||||
|
||||
// fill in default values as needed. if we're overriding a property, don't execute the default
|
||||
@ -365,9 +373,9 @@ exports.Parser.prototype._makeEvent = function(node, comments, extras) {
|
||||
};
|
||||
|
||||
// use the modified version of the comment
|
||||
var idx = comments.original.indexOf(result.comment);
|
||||
var idx = this._comments.original.indexOf(result.comment);
|
||||
if (idx !== -1) {
|
||||
result.comment = comments.modified[idx];
|
||||
result.comment = this._comments.modified[idx];
|
||||
}
|
||||
|
||||
// make sure the result includes extras that don't have default values
|
||||
@ -401,13 +409,13 @@ exports.Parser.prototype._trackVars = function(node, e) {
|
||||
};
|
||||
|
||||
/** @private */
|
||||
exports.Parser.prototype._visitComment = function(comments, comment) {
|
||||
exports.Parser.prototype._visitComment = function(comment) {
|
||||
var e;
|
||||
var original = String( comment.toSource() );
|
||||
var modified;
|
||||
|
||||
if ( original && isValidJsdoc(original) ) {
|
||||
comments.original.push(original);
|
||||
this._comments.original.push(original);
|
||||
|
||||
e = {
|
||||
comment: original,
|
||||
@ -422,14 +430,14 @@ exports.Parser.prototype._visitComment = function(comments, comment) {
|
||||
modified = e.comment;
|
||||
}
|
||||
|
||||
comments.modified.push(modified || original);
|
||||
this._comments.modified.push(modified || original);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/** @private */
|
||||
exports.Parser.prototype._visitNode = function(comments, node) {
|
||||
exports.Parser.prototype._visitNode = function(node) {
|
||||
var e,
|
||||
extras,
|
||||
basename,
|
||||
@ -439,7 +447,7 @@ exports.Parser.prototype._visitNode = function(comments, node) {
|
||||
l;
|
||||
|
||||
if (node.type === Token.ASSIGN) {
|
||||
e = this._makeEvent(node, comments);
|
||||
e = this._makeEvent(node);
|
||||
|
||||
basename = getBasename(e.code.name);
|
||||
|
||||
@ -452,13 +460,13 @@ exports.Parser.prototype._visitNode = function(comments, node) {
|
||||
comment: String(node.left.getJsDoc() || '@undocumented'),
|
||||
finishers: [this.addDocletRef, this.resolveEnum]
|
||||
};
|
||||
e = this._makeEvent(node, comments, extras);
|
||||
e = this._makeEvent(node, extras);
|
||||
}
|
||||
else if (node.type === Token.GET || node.type === Token.SET) { // assignment within an object literal
|
||||
extras = {
|
||||
comment: String(node.left.getJsDoc() || '@undocumented')
|
||||
};
|
||||
e = this._makeEvent(node, comments, extras);
|
||||
e = this._makeEvent(node, extras);
|
||||
}
|
||||
else if (node.type === Token.GETPROP) { // like 'obj.prop' in '/** @typedef {string} */ obj.prop;'
|
||||
// this COULD be a Closure Compiler-style typedef, but it's probably not; to avoid filling
|
||||
@ -467,7 +475,7 @@ exports.Parser.prototype._visitNode = function(comments, node) {
|
||||
lineno: node.getLineno()
|
||||
};
|
||||
if ( node.getJsDoc() ) {
|
||||
e = this._makeEvent(node, comments, extras);
|
||||
e = this._makeEvent(node, extras);
|
||||
}
|
||||
}
|
||||
else if (node.type == Token.VAR || node.type == Token.LET || node.type == Token.CONST) {
|
||||
@ -484,7 +492,7 @@ exports.Parser.prototype._visitNode = function(comments, node) {
|
||||
extras = {
|
||||
lineno: node.getLineno()
|
||||
};
|
||||
e = this._makeEvent(node, comments, extras);
|
||||
e = this._makeEvent(node, extras);
|
||||
|
||||
this._trackVars(node, e);
|
||||
}
|
||||
@ -492,7 +500,7 @@ exports.Parser.prototype._visitNode = function(comments, node) {
|
||||
extras = {
|
||||
lineno: node.getLineno()
|
||||
};
|
||||
e = this._makeEvent(node, comments, extras);
|
||||
e = this._makeEvent(node, extras);
|
||||
|
||||
e.code.name = (node.type == tkn.NAMEDFUNCTIONSTATEMENT)? '' : String(node.name) || '';
|
||||
|
||||
@ -529,10 +537,6 @@ exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
|
||||
var NodeVisitor = Packages.org.mozilla.javascript.ast.NodeVisitor;
|
||||
|
||||
var ast;
|
||||
var comments = {
|
||||
original: [],
|
||||
modified: []
|
||||
};
|
||||
var e = {
|
||||
filename: sourceName
|
||||
};
|
||||
@ -554,13 +558,13 @@ exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
|
||||
|
||||
ast.visitComments(
|
||||
new NodeVisitor({
|
||||
visit: this._visitComment.bind(this, comments)
|
||||
visit: this._visitComment.bind(this)
|
||||
})
|
||||
);
|
||||
|
||||
ast.visit(
|
||||
new NodeVisitor({
|
||||
visit: this._visitNode.bind(this, comments)
|
||||
visit: this._visitNode.bind(this)
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user