prevent doclet paths from being shortened twice (#514)

This commit is contained in:
Jeff Williams 2013-11-05 20:52:59 -08:00
parent 5225cb13f5
commit f958ab0fd2
2 changed files with 7 additions and 15 deletions

View File

@ -98,20 +98,14 @@ function shortenPaths(files, commonPrefix) {
return files;
}
function resolveSourcePath(filepath) {
return path.resolve(env.dirname, filepath);
}
function getPathFromDoclet(doclet) {
if (!doclet.meta) {
return;
}
var filepath = doclet.meta.path && doclet.meta.path !== 'null' ?
return doclet.meta.path && doclet.meta.path !== 'null' ?
doclet.meta.path + '/' + doclet.meta.filename :
doclet.meta.filename;
return filepath;
}
function generate(title, docs, filename, resolveLinks) {
@ -136,7 +130,7 @@ function generateSourceFiles(sourceFiles, encoding) {
encoding = encoding || 'utf8';
Object.keys(sourceFiles).forEach(function(file) {
var source;
// links are keyed to the shortened path in each doclet's `meta.filename` property
// links are keyed to the shortened path in each doclet's `meta.shortpath` property
var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
@ -367,15 +361,13 @@ exports.publish = function(taffyData, opts, tutorials) {
// build a list of source files
var sourcePath;
var resolvedSourcePath;
if (doclet.meta) {
sourcePath = getPathFromDoclet(doclet);
resolvedSourcePath = resolveSourcePath(sourcePath);
sourceFiles[sourcePath] = {
resolved: resolvedSourcePath,
resolved: sourcePath,
shortened: null
};
sourceFilePaths.push(resolvedSourcePath);
sourceFilePaths.push(sourcePath);
}
});
@ -424,13 +416,13 @@ exports.publish = function(taffyData, opts, tutorials) {
var url = helper.createLink(doclet);
helper.registerLink(doclet.longname, url);
// replace the filename with a shortened version of the full path
// add a shortened version of the full path
var docletPath;
if (doclet.meta) {
docletPath = getPathFromDoclet(doclet);
docletPath = sourceFiles[docletPath].shortened;
if (docletPath) {
doclet.meta.filename = docletPath;
doclet.meta.shortpath = docletPath;
}
}
});

View File

@ -74,7 +74,7 @@ if (data.defaultvalue && data.defaultvaluetype === 'object') {
<?js if (data.meta) {?>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<?js= self.linkto(meta.filename) ?>, <?js= self.linkto(meta.filename, 'line ' + meta.lineno, null, 'line' + meta.lineno) ?>
<?js= self.linkto(meta.shortpath) ?>, <?js= self.linkto(meta.shortpath, 'line ' + meta.lineno, null, 'line' + meta.lineno) ?>
</li></ul></dd>
<?js } ?>