mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
strip module namespace from module and exports tag values (#786)
This change makes `/** @exports module:foo */` a synonym for `/** @exports foo */`.
This commit is contained in:
parent
5512af9677
commit
58839223a9
@ -176,6 +176,10 @@ function parseBorrows(doclet, tag) {
|
||||
}
|
||||
}
|
||||
|
||||
function stripModuleNamespace(name) {
|
||||
return name.replace(/^module\:/, '');
|
||||
}
|
||||
|
||||
function firstWordOf(string) {
|
||||
var m = /^(\S+)/.exec(string);
|
||||
if (m) { return m[1]; }
|
||||
@ -382,7 +386,8 @@ var baseTags = exports.baseTags = {
|
||||
onTagged: function(doclet, tag) {
|
||||
var modName = firstWordOf(tag.value);
|
||||
|
||||
doclet.addTag('alias', modName);
|
||||
// in case the user wrote something like `/** @exports module:foo */`:
|
||||
doclet.addTag( 'alias', stripModuleNamespace(modName) );
|
||||
doclet.addTag('kind', 'module');
|
||||
}
|
||||
},
|
||||
@ -534,6 +539,9 @@ var baseTags = exports.baseTags = {
|
||||
if (!doclet.name) {
|
||||
setDocletNameToFilename(doclet, tag);
|
||||
}
|
||||
// in case the user wrote something like `/** @module module:foo */`:
|
||||
doclet.name = stripModuleNamespace(doclet.name);
|
||||
|
||||
setDocletTypeToValueType(doclet, tag);
|
||||
}
|
||||
},
|
||||
|
||||
4
test/fixtures/exportstag8.js
vendored
Normal file
4
test/fixtures/exportstag8.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
/** @exports module:my/shirt */
|
||||
var myShirt = exports;
|
||||
3
test/fixtures/moduletag5.js
vendored
Normal file
3
test/fixtures/moduletag5.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/**
|
||||
* @module module:bookshelf
|
||||
*/
|
||||
@ -202,4 +202,14 @@ describe('@exports tag', function() {
|
||||
expect(iron.scope).toBe('instance');
|
||||
});
|
||||
});
|
||||
|
||||
describe('"module:" namespace included in the name', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag8.js');
|
||||
var shirt = docSet.getByLongname('module:my/shirt')[0];
|
||||
|
||||
it('When the name for an @exports tag begins with the "module:" namespace, we remove the namespace', function() {
|
||||
expect(typeof shirt).toBe('object');
|
||||
expect(shirt.name).toBe('my/shirt');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -77,4 +77,14 @@ describe('@module tag', function() {
|
||||
expect(virtFunc2.memberof).toBe('module:M1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('"module:" namespace included in the name', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag5.js');
|
||||
var bookshelf = docSet.getByLongname('module:bookshelf')[0];
|
||||
|
||||
it('When the name for a @module tag begins with the "module:" namespace, we remove the namespace', function() {
|
||||
expect(typeof bookshelf).toBe('object');
|
||||
expect(bookshelf.name).toBe('bookshelf');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user