mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
allow symbol names that contain whitespace to be borrowed (#818)
This commit is contained in:
parent
be77aa4344
commit
7ca432d587
@ -167,7 +167,7 @@ function parseTypeText(text) {
|
||||
}
|
||||
|
||||
function parseBorrows(doclet, tag) {
|
||||
var m = /^(\S+)(?:\s+as\s+(\S+))?$/.exec(tag.text);
|
||||
var m = /^([\s\S]+?)(?:\s+as\s+([\s\S]+))?$/.exec(tag.text);
|
||||
if (m) {
|
||||
if (m[1] && m[2]) {
|
||||
return { target: m[1], source: m[2] };
|
||||
|
||||
22
test/fixtures/borrowstag3.js
vendored
Normal file
22
test/fixtures/borrowstag3.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Remove whitespace from around a string.
|
||||
* @param {string} str
|
||||
*/
|
||||
function trstr(str) {}
|
||||
|
||||
var _util = {
|
||||
/** Hidden utility function. */
|
||||
'hidden util': function() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
* @borrows trstr as trim string
|
||||
* @borrows util.hidden util as hidden
|
||||
*/
|
||||
var util = {
|
||||
hidden: _util['trim string'],
|
||||
'trim string': trstr
|
||||
};
|
||||
@ -1,11 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
function filterUndocumented($) {
|
||||
return !($.undocumented);
|
||||
}
|
||||
|
||||
describe('@borrows tag', function() {
|
||||
it('When a symbol has a @borrows-as tag, that is added to the symbol\'s "borrowed" property.', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/borrowstag.js');
|
||||
var util = docSet.getByLongname('util').filter(function($) {
|
||||
return !($.undocumented);
|
||||
})[0];
|
||||
var util = docSet.getByLongname('util').filter(filterUndocumented)[0];
|
||||
|
||||
expect(util.borrowed.length).toBe(1);
|
||||
expect(util.borrowed[0].from).toBe('trstr');
|
||||
@ -24,4 +26,15 @@ describe('@borrows tag', function() {
|
||||
|
||||
expect(typeof strRtrim).toBe('object');
|
||||
});
|
||||
|
||||
it('When a symbol has a `@borrows X as Y` tag, X and Y may contain whitespace.', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/borrowstag3.js');
|
||||
var util = docSet.getByLongname('util').filter(filterUndocumented)[0];
|
||||
|
||||
expect(util.borrowed.length).toBe(2);
|
||||
expect(util.borrowed[0].from).toBe('trstr');
|
||||
expect(util.borrowed[0].as).toBe('trim string');
|
||||
expect(util.borrowed[1].from).toBe('util.hidden util');
|
||||
expect(util.borrowed[1].as).toBe('hidden');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user