diff --git a/Gruntfile.js b/Gruntfile.js index c66a009..dc219e8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -107,7 +107,8 @@ module.exports = function(grunt) { }, dox: { options: { - title: "ConstraintJS Documentation" + title: "ConstraintJS Documentation", + blob_name: "v<%= pkg.version %>" }, files: { src: enclosed_src_files, diff --git a/resources/api_doc_generator/lib/dox-foundation.js b/resources/api_doc_generator/lib/dox-foundation.js index 9360e0c..0f81660 100644 --- a/resources/api_doc_generator/lib/dox-foundation.js +++ b/resources/api_doc_generator/lib/dox-foundation.js @@ -57,14 +57,13 @@ function buildStructureForFile(file) { }; } -var BRANCH = "v091", - BASE_URL = "https://github.com/soney/ConstraintJS/blob/v0.9.1/"; -var get_link = function(fname, line) { - var rv = BASE_URL+fname+"#L"+line; +var BASE_URL = "https://github.com/soney/ConstraintJS/blob/"; +var get_link = function(fname, line, blob_name) { + var rv = BASE_URL+blob_name+'/'+fname+"#L"+line; return rv; }; -var get_doc = function(doc_info) { +var get_doc = function(doc_info, options) { var info = { type: false, info: false, @@ -74,7 +73,7 @@ var get_doc = function(doc_info) { }, fname = doc_info.file, doc = doc_info.doc, - link = get_link(fname, doc.line); + link = get_link(fname, doc.line, options.blob_name); info.link = link; info.fname = fname.replace("../src/", ""); info.line = doc.line; @@ -205,7 +204,7 @@ exports.doxFiles = function(source, target, options, files) { return files; }; -exports.compileDox = function(files) { +exports.compileDox = function(files, options) { var subjects = {}; files.forEach(function(file) { var srcFile = file.sourceFile, @@ -272,7 +271,7 @@ exports.compileDox = function(files) { keys.forEach(function(key) { var objs = key.replace(".prototype", "").split("."), ctree = tree, - info = get_doc_info(subjects[key]); + info = get_doc_info(subjects[key], options); var level = 0; objs.forEach(function(obj, i) { @@ -316,8 +315,8 @@ exports.compileDox = function(files) { return tree; }; -var get_doc_info = function(docs) { - var subinfos = docs.map(function(x) { return get_doc(x); }), +var get_doc_info = function(docs, options) { + var subinfos = docs.map(function(x) { return get_doc(x, options); }), info = { calltypes: [], description: "", diff --git a/resources/api_doc_generator/tasks/dox.js b/resources/api_doc_generator/tasks/dox.js index a856d59..fe5fb4a 100644 --- a/resources/api_doc_generator/tasks/dox.js +++ b/resources/api_doc_generator/tasks/dox.js @@ -20,8 +20,7 @@ module.exports = function(grunt) { dest = this.data.dest, indexPath = path.relative(process.cwd(), dest + path.sep + 'api.html'), ignore = ignoredDirs.trim().replace(' ', '').split(','), - options = { - }; + options = this.options(); // Cleanup any existing docs rimraf.sync(dest); @@ -29,7 +28,7 @@ module.exports = function(grunt) { // Find, cleanup and validate all potential files var files = formatter.collectFiles(src, { ignore: ignore }, files), doxedFiles = formatter.doxFiles(src, dest, { raw: false }, files), - dox = formatter.compileDox(doxedFiles), + dox = formatter.compileDox(doxedFiles, options), output = formatter.render(dox, options), dir = path.dirname(indexPath); diff --git a/resources/api_doc_generator/views/template.jade b/resources/api_doc_generator/views/template.jade index 8e0511d..02b2fa8 100644 --- a/resources/api_doc_generator/views/template.jade +++ b/resources/api_doc_generator/views/template.jade @@ -47,7 +47,7 @@ mixin apidoclist(item) .panel-footer if item.sourceLinks each link in item.sourceLinks - a(target="_blank",href=link.link.replace(/\./g, "_"))=" " + link.text + a(target="_blank",href=link.link)=" " + link.text each child in item.children +apidoclist(child) @@ -70,7 +70,6 @@ html a(href="tutorial.html") Tutorial li a(href="api.html",active) API - .row.alert.alert-warning This API documentation is under construnction and is, at the moment, very rough .row .col-sm-3(role="complimentary").hidden-xs .sidebar.bs-sidebar(data-spy="affix", data-offset-top=0)