Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Added option for blob name
Browse files Browse the repository at this point in the history
  • Loading branch information
soney committed Dec 28, 2013
1 parent 76f82d3 commit 5b55c68
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 9 additions & 10 deletions resources/api_doc_generator/lib/dox-foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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: "",
Expand Down
5 changes: 2 additions & 3 deletions resources/api_doc_generator/tasks/dox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ 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);

// 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);

Expand Down
3 changes: 1 addition & 2 deletions resources/api_doc_generator/views/template.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 5b55c68

Please sign in to comment.