mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
fix the name/scope of properties whose names include single quotes (#386)
This commit is contained in:
parent
a3286e38bc
commit
5b219ababb
@ -157,8 +157,8 @@ exports.shorten = function(longname, forcedMemberof) {
|
||||
// quoted strings in a longname are atomic, convert to tokens
|
||||
var atoms = [], token;
|
||||
|
||||
// handle quoted names like foo["bar"]
|
||||
longname = longname.replace(/(\[?".+?"\]?)/g, function($) {
|
||||
// handle quoted names like foo["bar"] or foo['bar']
|
||||
longname = longname.replace(/(\[?["'].+?["']\]?)/g, function($) {
|
||||
var dot = '';
|
||||
if ( /^\[/.test($) ) {
|
||||
dot = '.';
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/*global describe: true, expect: true, it: true */
|
||||
|
||||
describe("jsdoc/name", function() {
|
||||
var jsdoc = {name: require('jsdoc/name'), doclet: require('jsdoc/doclet') };
|
||||
|
||||
@ -91,6 +93,15 @@ describe("jsdoc/name", function() {
|
||||
expect(parts.scope).toEqual('.');
|
||||
});
|
||||
|
||||
it('should work on bracketed stringy names with single quotes', function() {
|
||||
var startName = "channels['#ops']",
|
||||
parts = jsdoc.name.shorten(startName);
|
||||
|
||||
expect(parts.name).toBe("'#ops'");
|
||||
expect(parts.memberof).toBe('channels');
|
||||
expect(parts.scope).toBe('.');
|
||||
});
|
||||
|
||||
it('should work on fully stringy names, like "foo.bar"', function() {
|
||||
var startName = '"foo.bar"',
|
||||
parts = jsdoc.name.shorten(startName);
|
||||
@ -105,6 +116,16 @@ describe("jsdoc/name", function() {
|
||||
expect(parts.scope).toEqual('');
|
||||
});
|
||||
|
||||
it('should work on fully stringy names in single quotes, like \'foo.bar\'', function() {
|
||||
var startName = "'foo.bar'",
|
||||
parts = jsdoc.name.shorten(startName);
|
||||
|
||||
expect(parts.name).toBe("'foo.bar'");
|
||||
expect(parts.longname).toBe("'foo.bar'");
|
||||
expect(parts.memberof).toBe('');
|
||||
expect(parts.scope).toBe('');
|
||||
});
|
||||
|
||||
it('should find the variation', function() {
|
||||
var startName = 'anim.fadein(2)',
|
||||
parts = jsdoc.name.shorten(startName);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user