Skip to content

Commit 1e1434b

Browse files
committed
Merge pull request #90 from jbalsas/jbalsas/fix_79
Add resolvePath support for @link tags
2 parents 3f6c8bc + b5b52bc commit 1e1434b

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

lib/Documenter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
process.exit(1);
4343
}
4444

45-
workspace.load(source, includes, excludes).then(function (fileset) {
45+
workspace.load(source, includes, excludes, output).then(function (fileset) {
4646
workspace.createOutputSkeleton(output, fileset, assets).then(function (fileset) {
4747

4848
var indexGenerator = require("./language/js/IndexGenerator"),
@@ -64,9 +64,9 @@
6464
searchGenerator.generate(fileset.files, output);
6565

6666
var moduleTemplates = templateUtils.loadTemplates(templates.module);
67-
67+
6868
fileset.files.forEach(function (file) {
69-
parser.parse(file).then(function (module) {
69+
parser.parse(file, fileset.resolvePath).then(function (module) {
7070
moduleGenerator.generate(moduleTemplates, module, fileset, output, title);
7171

7272
if (file === fileset.files[fileset.files.length - 1]) {

lib/language/js/ModuleParser.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* @param {string} url Path of the module to analyze
5656
* @return {Promise} A promise to be resolved with the parsed module
5757
*/
58-
ModuleParser.prototype.parse = function (file) {
58+
ModuleParser.prototype.parse = function (file, resolvePath) {
5959
var instance = this,
6060
def = deferred();
6161

@@ -83,7 +83,15 @@
8383
var parsedData = [];
8484

8585
try {
86-
parsedData = dox.parseComments(data, {raw: true});
86+
parsedData = dox.parseComments(
87+
data,
88+
{
89+
raw: true,
90+
resolveClassPath: function(clazz, rest, url) {
91+
return resolvePath(clazz, rest, url);
92+
}
93+
}
94+
);
8795
} catch (error) {
8896
console.error(error);
8997
}
@@ -108,7 +116,7 @@
108116
scope;
109117

110118
if (context) {
111-
scope = context.scope || {}
119+
scope = context.scope || {};
112120

113121
if (context.type === "declaration") {
114122
module.variables.push(comment);

lib/utils/Workspace.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
* @param {array.<RegExp>} excludes Rule set for excluding files
3434
* @return fileset The set of files to be documented
3535
*/
36-
var load = function (src, includes, excludes) {
36+
var load = function (src, includes, excludes, output) {
3737
var groups, files,
38+
packages = {},
3839
def = deferred();
3940

4041
// TODO, use includes array of regexps to add
@@ -77,11 +78,42 @@
7778
};
7879
});
7980

81+
_.each(groups, function(group) {
82+
_.each(group.files, function(file) {
83+
var moduleFolder = path.join(output, "modules", file.docPath),
84+
level = pathUtils.normalize(path.relative(moduleFolder, output));
85+
86+
packages[file.name] = level + "/modules/" + file.docPath;
87+
});
88+
});
89+
8090
// Resolve the promise returning a 'fileset' object
8191
def.resolve({
8292
files: files,
8393
groups: groups,
84-
length: files.length
94+
length: files.length,
95+
resolvePath: function(clazz, rest, url) {
96+
var mod, clazzParts;
97+
98+
if (clazz.indexOf('::') !== -1) {
99+
clazzParts = clazz.split('::');
100+
101+
clazz = clazzParts[1];
102+
mod = clazzParts[0];
103+
}
104+
105+
var path = packages[clazz] || packages[mod] || "";
106+
107+
if (path) {
108+
path += (mod ? mod : clazz) + ".html";
109+
}
110+
111+
if (rest) {
112+
path += "#" + clazz+ "-" + rest;
113+
}
114+
115+
return path;
116+
}
85117
});
86118
});
87119

0 commit comments

Comments
 (0)