Skip to content

Commit 38852b6

Browse files
tgirardibsvensson
authored andcommitted
Prevent doclet paths from being shortened twice
Prevent doclet paths from being shortened twice. Solve: issue davidshimjs#23 (equivalent to jsdoc/jsdoc#514) Based on: jsdoc/jsdoc@f958ab0
1 parent f3b5b64 commit 38852b6

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

publish.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,14 @@ function shortenPaths(files, commonPrefix) {
9999
return files;
100100
}
101101

102-
function resolveSourcePath(filepath) {
103-
return path.resolve(process.cwd(), filepath);
104-
}
105-
106102
function getPathFromDoclet(doclet) {
107103
if (!doclet.meta) {
108104
return;
109105
}
110106

111-
var filepath = doclet.meta.path && doclet.meta.path !== 'null' ?
107+
return doclet.meta.path && doclet.meta.path !== 'null' ?
112108
doclet.meta.path + '/' + doclet.meta.filename :
113109
doclet.meta.filename;
114-
115-
return filepath;
116110
}
117111

118112
function generate(title, docs, filename, resolveLinks) {
@@ -140,7 +134,7 @@ function generate(title, docs, filename, resolveLinks) {
140134
function generateSourceFiles(sourceFiles) {
141135
Object.keys(sourceFiles).forEach(function(file) {
142136
var source;
143-
// links are keyed to the shortened path in each doclet's `meta.filename` property
137+
// links are keyed to the shortened path in each doclet's `meta.shortpath.` property
144138
var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
145139
helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
146140

@@ -318,15 +312,13 @@ exports.publish = function(taffyData, opts, tutorials) {
318312

319313
// build a list of source files
320314
var sourcePath;
321-
var resolvedSourcePath;
322315
if (doclet.meta) {
323316
sourcePath = getPathFromDoclet(doclet);
324-
resolvedSourcePath = resolveSourcePath(sourcePath);
325317
sourceFiles[sourcePath] = {
326-
resolved: resolvedSourcePath,
318+
resolved: sourcePath,
327319
shortened: null
328320
};
329-
sourceFilePaths.push(resolvedSourcePath);
321+
sourceFilePaths.push(sourcePath);
330322
}
331323
});
332324

@@ -376,13 +368,13 @@ exports.publish = function(taffyData, opts, tutorials) {
376368
var url = helper.createLink(doclet);
377369
helper.registerLink(doclet.longname, url);
378370

379-
// replace the filename with a shortened version of the full path
371+
// add a shortened version of the full path
380372
var docletPath;
381373
if (doclet.meta) {
382374
docletPath = getPathFromDoclet(doclet);
383375
docletPath = sourceFiles[docletPath].shortened;
384376
if (docletPath) {
385-
doclet.meta.filename = docletPath;
377+
doclet.meta.shortpath = docletPath;
386378
}
387379
}
388380
});

tmpl/method.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var self = this;
1313

1414
<?js if (data.meta) {?>
1515
<div class="tag-source">
16-
<?js= self.linkto(meta.filename) ?>, <?js= self.linkto(meta.filename, 'line ' + meta.lineno, null, 'line' + meta.lineno) ?>
16+
<?js= self.linkto(meta.shortpath) ?>, <?js= self.linkto(meta.shortpath, 'line ' + meta.lineno, null, 'line' + meta.lineno) ?>
1717
</div>
1818
<?js } ?>
1919
</div>

0 commit comments

Comments
 (0)