diff --git a/lib/jsdoc/tag/dictionary/definitions.js b/lib/jsdoc/tag/dictionary/definitions.js index b2679ed3..a9d56435 100644 --- a/lib/jsdoc/tag/dictionary/definitions.js +++ b/lib/jsdoc/tag/dictionary/definitions.js @@ -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); } }, diff --git a/test/fixtures/exportstag8.js b/test/fixtures/exportstag8.js new file mode 100644 index 00000000..87b52aa6 --- /dev/null +++ b/test/fixtures/exportstag8.js @@ -0,0 +1,4 @@ +'use strict'; + +/** @exports module:my/shirt */ +var myShirt = exports; diff --git a/test/fixtures/moduletag5.js b/test/fixtures/moduletag5.js new file mode 100644 index 00000000..ff5b957c --- /dev/null +++ b/test/fixtures/moduletag5.js @@ -0,0 +1,3 @@ +/** + * @module module:bookshelf + */ diff --git a/test/specs/tags/exportstag.js b/test/specs/tags/exportstag.js index a895aad4..00feb54c 100644 --- a/test/specs/tags/exportstag.js +++ b/test/specs/tags/exportstag.js @@ -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'); + }); + }); }); diff --git a/test/specs/tags/moduletag.js b/test/specs/tags/moduletag.js index 91232a85..08075f37 100644 --- a/test/specs/tags/moduletag.js +++ b/test/specs/tags/moduletag.js @@ -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'); + }); + }); });