[wip] Test support for namepaths containing special characters

This commit is contained in:
Tom MacWright 2016-06-16 13:58:11 -04:00
parent c33fe6b904
commit a4889c97ec
3 changed files with 44 additions and 23 deletions

View File

@ -27,9 +27,14 @@ module.exports = function () {
}
function inferName(path, node) {
if (node && node.name) {
comment.name = node.name;
return true;
if (node) {
if (node.name) {
comment.name = node.name;
return true;
} else if (node.type === 'StringLiteral') {
comment.name = node.value;
return true;
}
}
}
@ -45,6 +50,7 @@ module.exports = function () {
// infer the named based on the `property` of the MemberExpression (`bar`)
// rather than the `object` (`foo`).
comment.context.ast.traverse({
/**
* Attempt to extract the name from an Identifier node.
* If the name can be resolved, it will stop traversing.
@ -57,6 +63,7 @@ module.exports = function () {
path.stop();
}
},
/**
* Attempt to extract the name from an Identifier node.
* If the name can be resolved, it will stop traversing.

View File

@ -22,7 +22,7 @@
"concat-stream": "^1.5.0",
"debounce": "^1.0.0",
"disparity": "^2.0.0",
"doctrine": "^1.1.0",
"doctrine": "^1.2.0",
"events": "^1.1.0",
"extend": "^3.0.0",
"get-comments": "^1.0.1",

View File

@ -1,23 +1,37 @@
/**
* This is my class, a demo thing.
* @class MyClass
* @property {number} howMany how many things it contains
*/
function MyClass() {
this.howMany = 2;
}
// /**
// * This is my class, a demo thing.
// * @class MyClass
// * @property {number} howMany how many things it contains
// */
// function MyClass() {
// this.howMany = 2;
// }
//
// /**
// * Get the number 42
// * @param {boolean} getIt whether to get the number
// * @returns {number} forty-two
// */
// MyClass.prototype.getFoo = function (getIt) {
// return getIt ? 42 : 0;
// };
//
// /**
// * Get undefined
// * @returns {undefined} does not return anything.
// */
// MyClass.prototype.getUndefined = function () { };
//
// /**
// * A colon-separated name
// * @returns {undefined} does not return anything.
// */
// MyClass.prototype['colon:name'] = function () { };
/**
* Get the number 42
* @param {boolean} getIt whether to get the number
* @returns {number} forty-two
*/
MyClass.prototype.getFoo = function (getIt) {
return getIt ? 42 : 0;
};
/**
* Get undefined
* A colon-separated name specified manually
*
* @name "colon:foo"
* @returns {undefined} does not return anything.
*/
MyClass.prototype.getUndefined = function () { };
MyClass.prototype['colon:foo'] = function () { };