Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Documenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
process.exit(1);
}

workspace.load(source, includes, excludes).then(function (fileset) {
workspace.load(source, includes, excludes, output).then(function (fileset) {
workspace.createOutputSkeleton(output, fileset, assets).then(function (fileset) {

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

var moduleTemplates = templateUtils.loadTemplates(templates.module);

fileset.files.forEach(function (file) {
parser.parse(file).then(function (module) {
parser.parse(file, fileset.resolvePath).then(function (module) {
moduleGenerator.generate(moduleTemplates, module, fileset, output, title);

if (file === fileset.files[fileset.files.length - 1]) {
Expand Down
14 changes: 11 additions & 3 deletions lib/language/js/ModuleParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* @param {string} url Path of the module to analyze
* @return {Promise} A promise to be resolved with the parsed module
*/
ModuleParser.prototype.parse = function (file) {
ModuleParser.prototype.parse = function (file, resolvePath) {
var instance = this,
def = deferred();

Expand Down Expand Up @@ -83,7 +83,15 @@
var parsedData = [];

try {
parsedData = dox.parseComments(data, {raw: true});
parsedData = dox.parseComments(
data,
{
raw: true,
resolveClassPath: function(clazz, rest, url) {
return resolvePath(clazz, rest, url);
}
}
);
} catch (error) {
console.error(error);
}
Expand All @@ -108,7 +116,7 @@
scope;

if (context) {
scope = context.scope || {}
scope = context.scope || {};

if (context.type === "declaration") {
module.variables.push(comment);
Expand Down
36 changes: 34 additions & 2 deletions lib/utils/Workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
* @param {array.<RegExp>} excludes Rule set for excluding files
* @return fileset The set of files to be documented
*/
var load = function (src, includes, excludes) {
var load = function (src, includes, excludes, output) {
var groups, files,
packages = {},
def = deferred();

// TODO, use includes array of regexps to add
Expand Down Expand Up @@ -77,11 +78,42 @@
};
});

_.each(groups, function(group) {
_.each(group.files, function(file) {
var moduleFolder = path.join(output, "modules", file.docPath),
level = pathUtils.normalize(path.relative(moduleFolder, output));

packages[file.name] = level + "/modules/" + file.docPath;
});
});

// Resolve the promise returning a 'fileset' object
def.resolve({
files: files,
groups: groups,
length: files.length
length: files.length,
resolvePath: function(clazz, rest, url) {
var mod, clazzParts;

if (clazz.indexOf('::') !== -1) {
clazzParts = clazz.split('::');

clazz = clazzParts[1];
mod = clazzParts[0];
}

var path = packages[clazz] || packages[mod] || "";

if (path) {
path += (mod ? mod : clazz) + ".html";
}

if (rest) {
path += "#" + clazz+ "-" + rest;
}

return path;
}
});
});

Expand Down