mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
remove variations before generating filenames (#179)
This commit is contained in:
parent
e592427fce
commit
263e3ca2e4
@ -68,8 +68,10 @@ var nsprefix = /^(event|module|external):/;
|
||||
var getUniqueFilename = exports.getUniqueFilename = function(str) {
|
||||
// allow for namespace prefix
|
||||
var basename = str.replace(nsprefix, '$1-')
|
||||
// and use - instead of ~ to denote 'inner'
|
||||
.replace(/~/g, '-');
|
||||
// use - instead of ~ to denote 'inner'
|
||||
.replace(/~/g, '-')
|
||||
// remove the variation, if any
|
||||
.replace(/\([\s\S]*\)$/, '');
|
||||
|
||||
// if the basename includes characters that we can't use in a filepath, remove everything up to
|
||||
// and including the last bad character
|
||||
@ -623,17 +625,14 @@ function getFilename(longname) {
|
||||
/** Turn a doclet into a URL. */
|
||||
exports.createLink = function(doclet) {
|
||||
var url = '';
|
||||
var longname;
|
||||
var longname = doclet.longname;
|
||||
var filename;
|
||||
|
||||
if ( containers.indexOf(doclet.kind) !== -1 || isModuleFunction(doclet) ) {
|
||||
longname = doclet.longname;
|
||||
url = getFilename(longname);
|
||||
}
|
||||
else {
|
||||
longname = doclet.longname;
|
||||
filename = getFilename(doclet.memberof || exports.globalName);
|
||||
|
||||
url = filename + '#' + getNamespace(doclet.kind) + doclet.name;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*global afterEach: true, beforeEach: true, describe: true, expect: true, env: true, it: true,
|
||||
spyOn: true, xdescribe: true */
|
||||
jasmine: true, spyOn: true, xdescribe: true */
|
||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
|
||||
describe("jsdoc/util/templateHelper", function() {
|
||||
@ -202,6 +202,11 @@ describe("jsdoc/util/templateHelper", function() {
|
||||
|
||||
expect( filename1.toLowerCase() ).not.toBe( filename2.toLowerCase() );
|
||||
});
|
||||
|
||||
it('should remove variations from the longname before generating the filename', function() {
|
||||
var filename = helper.getUniqueFilename('MyClass(foo, bar)');
|
||||
expect(filename).toBe('MyClass.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe("longnameToUrl", function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user