Skip to content

Commit

Permalink
0.1.7 Add @apiIgnore. Update grunt Modules. Minor css change and code
Browse files Browse the repository at this point in the history
formatting.
  • Loading branch information
rottmann committed Apr 23, 2013
1 parent 54da7c3 commit a4477b2
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function(grunt)
passfail: false,
node: true
}
}, // jshint
}, // js-hint

simplemocha: {
options: {
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Creates from input files a documentation in path `doc/`.

## Changelog

* `0.1.7` Add @apiIgnore. Update grunt Modules.
* `0.1.6` Fix OSX executable
* `0.1.5` Official release

## License
Expand Down
24 changes: 12 additions & 12 deletions lib/apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var Parser = require("./parser");
var Worker = require("./worker");
var Filter = require("./filter");
var markdown = require("node-markdown").Markdown;
var colors = require("colors");

// Options
var _defaultOptions = {
Expand All @@ -20,7 +21,7 @@ var _defaultOptions = {
debug: false,
log: true,
simulate: false,

template: path.join(__dirname, "../template/"),

filters: {},
Expand Down Expand Up @@ -129,7 +130,7 @@ function getPackageData()
packageInfos.version = json.version;
packageInfos.description = json.description;
packageInfos.apidoc = json.apidoc || "";

if(json.apidocFilename)
{
var filename = path.join(options.src, json.apidocFilename);
Expand Down Expand Up @@ -223,23 +224,23 @@ function createOutputFiles(parsedFiles, parsedFilenames, packageInfos)

app.debug("create dir: " + options.dest);
if( ! options.simulate) wrench.mkdirSyncRecursive(options.dest);

app.debug("copy template " + options.template + " to: " + options.dest);
if( ! options.simulate) wrench.copyDirSyncRecursive(options.template, options.dest);

// api_data
var json = JSON.stringify(blocks, null, 2);
app.debug("write json file: " + options.dest + "api_data.json");
if( ! options.simulate) fs.writeFile(options.dest + "./api_data.json", json);

app.debug("write js file: " + options.dest + "api_data.js");
if( ! options.simulate) fs.writeFile(options.dest + "./api_data.js", "define({ api: " + json + " });");

// api_project
var json = JSON.stringify(packageInfos, null, 2);
app.debug("write json file: " + options.dest + "api_project.json");
if( ! options.simulate) fs.writeFile(options.dest + "./api_project.json", json);

app.debug("write js file: " + options.dest + "api_project.js");
if( ! options.simulate) fs.writeFile(options.dest + "./api_project.js", "define(" + json + ");");
} // createOutputFiles
Expand All @@ -264,7 +265,7 @@ function main(defaults)
_.defaults(options.filters, app.filters);
_.defaults(options.parsers, app.parsers);
_.defaults(options.workers, app.workers);

var files = findFiles(options);
var parser = new Parser(app);
var parsedFiles = [];
Expand All @@ -287,17 +288,16 @@ function main(defaults)
parsedFilenames.push(filename);
}
} // for

// Worker / Filter
if(parsedFiles.length > 0)
{
worker.process(parsedFiles, parsedFilenames);
filter.process(parsedFiles, parsedFilenames);

var packageInfos = getPackageData();

createOutputFiles(parsedFiles, parsedFilenames, packageInfos);

return parsedFiles.length;
}
else
Expand Down
16 changes: 10 additions & 6 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ Parser.prototype.parseFile = function(filename)

// Zeilenumbrüche vereinheitlichen
self.src = self.src.replace(/\r\n/g, "\n");

self.blocks = [];
self.elements = [];
self.indexApiBlocks = [];

// Blöcke ermitteln
self.blocks = self._findBlocks();
if(self.blocks.length === 0) return;
Expand Down Expand Up @@ -128,7 +128,7 @@ Parser.prototype._parseBlockElements = function(indexApiBlocks, detectedElements
"\" block number " + (blockIndex + 1) + "."
);
}

if(self.parsers[element.name].preventGlobal && self.parsers[element.name].preventGlobal === true)
{
preventGlobal = true;
Expand All @@ -153,7 +153,7 @@ Parser.prototype._parseBlockElements = function(indexApiBlocks, detectedElements
"\" block number " + (blockIndex + 1) + ", only one define per block allowed."
);
}

if(preventGlobal === true)
{
throw new Error("Can't set \"@" + element.sourceName + "\" in file \"" + self.filename +
Expand All @@ -178,7 +178,7 @@ Parser.prototype._parseBlockElements = function(indexApiBlocks, detectedElements
{
blockDataPath.push(result);
}

// Zusätzlich in Root einfügen
if(self.parsers[element.name].extendRoot === true)
{
Expand Down Expand Up @@ -251,7 +251,7 @@ Parser.prototype._findBlocks = function()
var self = this;
var blocks = [];
var src = self.src;

// Zeilenumbrüche durch Unicode ersetzen
src = src.replace(/\n/g, "\uffff");

Expand Down Expand Up @@ -293,6 +293,10 @@ Parser.prototype._findBlockWithApiGetIndex = function(elements)
if(elements[i][j].name.substr(0, 3) === "api")
{
foundIndex = j;
}
if(elements[i][j].name.substr(0, 9) === "apiignore")
{
foundIndex = -1;
break;
}
} // for
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/parser_api_param.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function parse(content)

// Replace Linebreak with Unicode
content = content.replace(/\n/g, "\uffff");

// Search: type, field, defaultValue, optional, description
// Example: {Boolean} [user.name="Default Value"] Users lastname.
// RegExp:
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/worker_permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function _preProcess(parsedFiles, filenames, useName, defineName)
{
version = block.version;
}

if( ! result[name]) result[name] = {};
result[name][version] = block["global"][defineName];
}
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/worker_structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ function _preProcess(parsedFiles, filenames, structureName, defineStructureName)
{
var name = block["global"][defineStructureName];
var version = "0.0.0";

if(block.version)
{
version = block.version;
}

if( ! result[name]) result[name] = {};
result[name][version] = block.local;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Worker.prototype.process = function(parsedFiles, parsedFilenames)
_.extend(preProcessResults, result);
}
} // for

// Workers postProcess
for(var i = 0; i < self.workers.length; i += 1)
{
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apidoc",
"version": "0.1.6",
"version": "0.1.7",
"description": "RESTful web API Documentation Generator",
"author": "Peter Rottmann <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -31,10 +31,10 @@
"colors": "~0.6.0-1"
},
"devDependencies": {
"grunt": "~0.4.0rc7",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-jshint": "~0.1.1rc6",
"grunt-simple-mocha": "~0.3.2",
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.4.1",
"grunt-contrib-jshint": "~0.4.3",
"grunt-simple-mocha": "~0.4.0",
"should": "~1.2.2"
}
}
2 changes: 1 addition & 1 deletion template/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pre.language-json .pun {
}

.sidenav > li.nav-header > a {
padding: 7px 15px;
padding: 5px 15px;
border: 1px solid #e5e5e5;
width: 190px;
font-family: "Source Sans Pro", sans-serif;
Expand Down
2 changes: 1 addition & 1 deletion template_basic/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pre .pun {
}

.sidenav > li.nav-header > a {
padding: 7px 15px;
padding: 5px 15px;
border: 1px solid #e5e5e5;
width: 190px;
font-family: "Source Sans Pro", sans-serif;
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/api_project.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define({
"name": "apidoc",
"version": "0.1.5",
"version": "0.1.7",
"description": "RESTful web API Documentation Generator",
"apidoc": "",
"generator": {
"version": "0.1.5",
"version": "0.1.7",
"time": "2013-04-12T16:50:18.630Z"
}
});
4 changes: 2 additions & 2 deletions test/fixtures/api_project.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "apidoc",
"version": "0.1.5",
"version": "0.1.7",
"description": "RESTful web API Documentation Generator",
"apidoc": "",
"generator": {
"version": "0.1.5",
"version": "0.1.7",
"time": "2013-04-12T16:50:18.630Z"
}
}
7 changes: 6 additions & 1 deletion test/fixtures/example/example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/**
* @test Ignore this block.
* @test Ignore this block. No apiDoc.
*/

/**
* @apiIgnore Ignore this block, apiIgnore is set.
* @api {get} /ignore/me
*/

/**
Expand Down

0 comments on commit a4477b2

Please sign in to comment.