From 07a30a5c2d8480d8d2b201c5c4bf58cc18e297d6 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Fri, 21 Dec 2012 21:50:48 -0800 Subject: [PATCH] on windows, when the module name isn't documented, generate an appropriate name (#279) also removes 'file:' from the beginning of generated names in overview tags, which seems like an appropriate change. --- rhino_modules/jsdoc/tag/dictionary/definitions.js | 12 ++++++++---- test/specs/tags/overviewtag.js | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/rhino_modules/jsdoc/tag/dictionary/definitions.js b/rhino_modules/jsdoc/tag/dictionary/definitions.js index 2b828d02..f883d6c6 100644 --- a/rhino_modules/jsdoc/tag/dictionary/definitions.js +++ b/rhino_modules/jsdoc/tag/dictionary/definitions.js @@ -34,9 +34,12 @@ function setDocletDescriptionToValue(doclet, tag) { } function setNameToFile(doclet, tag) { + var name = ''; if (doclet.meta.filename) { - var name = doclet.meta.path || ''; - doclet.addTag( 'name', path.join(name, doclet.meta.filename) ); + // TODO: find the shortest path shared by all input files, and remove that from + // doclet.meta.path + name += path.basename(doclet.meta.path) + '/'; + doclet.addTag( 'name', name + doclet.meta.filename ); } } @@ -61,8 +64,9 @@ function applyNamespace(docletOrNs, tag) { } function setDocletNameToFilename(doclet, tag) { - var name = doclet.meta.path || ''; - name = path.join(name, doclet.meta.filename); + // TODO: find the shortest path shared by all input files, and remove that from doclet.meta.path + var name = doclet.meta.path ? path.basename(doclet.meta.path) + '/' : ''; + name += doclet.meta.filename; name = name.replace(/\.js$/i, ''); for (var i = 0, len = env.opts._.length; i < len; i++) { diff --git a/test/specs/tags/overviewtag.js b/test/specs/tags/overviewtag.js index 5104fbf4..06637c6d 100644 --- a/test/specs/tags/overviewtag.js +++ b/test/specs/tags/overviewtag.js @@ -1,3 +1,5 @@ +/*global describe: true, env: true, expect: true, it: true */ + describe("@overview tag", function() { var parser = require('jsdoc/src/parser'), srcParser = new parser.Parser(), @@ -6,8 +8,8 @@ describe("@overview tag", function() { require('jsdoc/src/handlers').attachTo(srcParser); doclets = srcParser.parse(env.dirname + '/test/fixtures/file.js'); - it('When a file overview tag appears in a doclet, the name of the doclet should start with file: and should end with the path to the file.', function() { - expect(doclets[0].name).toMatch(/^.*([\/\\]fixtures[\/\\]file\.js)$/); + it('When a file overview tag appears in a doclet, the name of the doclet should contain the path to the file.', function() { + expect(doclets[0].name).toMatch(/^(fixtures[\/\\]file\.js)$/); }); it("The name and longname should be equal", function() {