Permalink
Browse files

Fixes for the documentation generation

  • Loading branch information...
1 parent b6b80a8 commit fdda08ededf92472c68f2b60f9c02a4aa7e93bef @christkv christkv committed Feb 8, 2012
Showing with 56 additions and 61 deletions.
  1. +41 −41 dev/tools/build-docs.js
  2. +14 −16 dev/tools/doc-templates/class.ejs
  3. +0 −3 dev/tools/doc-templates/index.ejs
  4. +1 −1 docs/sphinx-docs/source/index.rst
View
@@ -62,60 +62,60 @@ var outputDirectory = "./docs/sphinx-docs/source/api-generated"
exec('rm -rf ' + outputDirectory, function (error, stdout, stderr) {});
exec('mkdir ' + outputDirectory, function (error, stdout, stderr) {});
-// // ----------------------------------------------------------------------------
-// // PROCESS Driver API
-// // ----------------------------------------------------------------------------
-// // Extract meta data from source files
-// var dataObjects = docs.extractLibraryMetaData(apiClasses);
-// // Filter out and prepare the test Objects hash
-// var testObjects = docs.buildTestHash(docs.extractLibraryMetaData(testClasses));
+// ----------------------------------------------------------------------------
+// PROCESS Driver API
+// ----------------------------------------------------------------------------
+// Extract meta data from source files
+var dataObjects = docs.extractLibraryMetaData(apiClasses);
+// Filter out and prepare the test Objects hash
+var testObjects = docs.buildTestHash(docs.extractLibraryMetaData(testClasses));
// Read all the templates
var templates = docs.readAllTemplates(templates);
-// // Render all the classes that are decorated
-// docs.renderAllTemplates(outputDirectory, templates, dataObjects, testObjects, {index_title:'Driver API'});
-//
-// // ----------------------------------------------------------------------------
-// // PROCESS BSON API
-// // ----------------------------------------------------------------------------
+// Render all the classes that are decorated
+docs.renderAllTemplates(outputDirectory, templates, dataObjects, testObjects, {index_title:'Driver API'});
+
+// ----------------------------------------------------------------------------
+// PROCESS BSON API
+// ----------------------------------------------------------------------------
// Output directory
var outputDirectory2 = "./docs/sphinx-docs/source/api-bson-generated"
// Force create the directory for the generated docs
exec('rm -rf ' + outputDirectory2, function (error, stdout, stderr) {});
exec('mkdir ' + outputDirectory2, function (error, stdout, stderr) {});
-// var apiClasses2 = [
-// // {tag:"objectid", path:"./lib/mongodb/bson/objectid.js"},
-// // {tag:"binary", path:"./lib/mongodb/bson/binary.js"},
-// // {tag:"code", path:"./lib/mongodb/bson/code.js"},
-// // {tag:"code", path:"./lib/mongodb/bson/db_ref.js"},
-// // {tag:"double", path:"./lib/mongodb/bson/double.js"},
-// // {tag:"maxkey", path:"./lib/mongodb/bson/max_key.js"},
-// // {tag:"symbol", path:"./lib/mongodb/bson/symbol.js"},
-// // {tag:"timestamp", path:"./lib/mongodb/bson/timestamp.js"},
-// // {tag:"long", path:"./lib/mongodb/bson/long.js"},
-// {tag:"bson", path:"./lib/mongodb/bson/bson.js"}
-// ];
-//
-// // Read all the templates
-// var templates2 = [
-// {tag:'index', path:'./dev/tools/doc-templates/index.ejs'},
-// {tag:'class', path:'./dev/tools/doc-templates/class.ejs'},
-// {tag:'function', path:'./dev/tools/doc-templates/function.ejs'}
-// ]
-//
-// // Extract meta data from source files
-// var dataObjects2 = docs.extractLibraryMetaData(apiClasses2);
-// // Filter out and prepare the test Objects hash
-// var testObjects2 = docs.buildTestHash(docs.extractLibraryMetaData(testClasses));
-// // Render all the classes that are decorated
-// docs.renderAllTemplates(outputDirectory2, templates, dataObjects2, testObjects2, {index_title:'Binary JSON API'});
+var apiClasses2 = [
+ // {tag:"objectid", path:"./lib/mongodb/bson/objectid.js"},
+ // {tag:"binary", path:"./lib/mongodb/bson/binary.js"},
+ // {tag:"code", path:"./lib/mongodb/bson/code.js"},
+ // {tag:"code", path:"./lib/mongodb/bson/db_ref.js"},
+ // {tag:"double", path:"./lib/mongodb/bson/double.js"},
+ // {tag:"maxkey", path:"./lib/mongodb/bson/max_key.js"},
+ // {tag:"symbol", path:"./lib/mongodb/bson/symbol.js"},
+ // {tag:"timestamp", path:"./lib/mongodb/bson/timestamp.js"},
+ // {tag:"long", path:"./lib/mongodb/bson/long.js"},
+ {tag:"bson", path:"./lib/mongodb/bson/bson.js"}
+ ];
+
+// Read all the templates
+var templates2 = [
+ {tag:'index', path:'./dev/tools/doc-templates/index.ejs'},
+ {tag:'class', path:'./dev/tools/doc-templates/class.ejs'},
+ {tag:'function', path:'./dev/tools/doc-templates/function.ejs'}
+]
+
+// Extract meta data from source files
+var dataObjects2 = docs.extractLibraryMetaData(apiClasses2);
+// Filter out and prepare the test Objects hash
+var testObjects2 = docs.buildTestHash(docs.extractLibraryMetaData(testClasses));
+// Render all the classes that are decorated
+docs.renderAllTemplates(outputDirectory2, templates, dataObjects2, testObjects2, {index_title:'Binary JSON API'});
// ----------------------------------------------------------------------------
// PROCESS MARKDOWN DOCUMENTS TO STRUCTURED TEXT
// ----------------------------------------------------------------------------
var articles = [
- {name:"NodeKOArticle1", output:"NodeKOArticle1.rst", path:"./docs/articles/NodeKOArticle1.md"}
- // {name:"NodeKOArticle2", output:"NodeKOArticle2.rs", path:"./docs/articles/NodeKOArticle2.md"}
+ {name:"NodeKOArticle1", output:"NodeKOArticle1.rst", path:"./docs/articles/NodeKOArticle1.md"},
+ {name:"NodeKOArticle2", output:"NodeKOArticle2.rst", path:"./docs/articles/NodeKOArticle2.md"}
];
// Output directory
@@ -5,15 +5,20 @@ for(var i = 0; i < entries.length; i++) {
}
}
+var addLine = function(char, length) {
+ var chars = [];
+ for(var i = 0; i < length; i++) chars[i] = char;
+ return chars.join('');
+}
+
// Contains the current class name
var className = null;
for(var i = 0; i < entries.length; i++) {
if(isClass(entries[i].tags)) {
- // console.log("-------------------------------------------------------------------------")
- // console.dir(entries[i])
-
- %><%= format("==================\n%s\n==================\n", entries[i].ctx.string) %><%
+ var _name = entries[i].ctx.string.trim();
+
+ %><%= format("%s\n%s\n%s\n", addLine("=", _name.length), _name, addLine("=", _name.length)) %><%
className = entries[i].ctx.string.replace("()", "");
%><%= format("\n\n------------------\nConstructor\n------------------\n") %><%
@@ -29,7 +34,6 @@ for(var i = 0; i < entries.length; i++) {
.replace(/\<em\>|\<\/em\>/g, "*")
.replace(/\<br[ ]*\>|\<\/br[ ]*\>|\<br[ ]*\/\>/g, "\n");
%><%- format("%s\n\n", fullDescription) %><%
-
%><%= format("\n .. js:class:: %s\n\n", entries[i].ctx.string) %><%
for(var ti = 0; ti < entries[i].tags.length; ti++) {
@@ -193,9 +197,6 @@ for(var i = 0; i < entries.length; i++) {
}
for(var i = 0; i < entries.length; i++) {
- // console.log("----------------------------------------------------------------")
- // console.dir(entries[i])
-
// If it's a function parse it
if(isFunction(entries[i])) {
var paramsStrings = [];
@@ -243,23 +244,20 @@ for(var i = 0; i < entries.length; i++) {
// Write header depending on if it's class or instance level
if(entries[i].ctx.receiver != null) {
// Change examples Name to include class name
- var examplesName = format("%s.%s", className, entries[i].ctx.name);
-
- %><%= format("\n------------------\n%s.%s\n------------------\n", className, entries[i].ctx.name) %><%
+ var examplesName = format("%s.%s", className, entries[i].ctx.name);
+ var _length = format("%s.%s", className, entries[i].ctx.name).length;
+ %><%= format("\n%s\n%s.%s\n%s\n", addLine("-", _length), className, entries[i].ctx.name, addLine("-", _length)) %><%
%><%- format("%s\n\n", fullDescription) %><%
%><%= format(".. js:function:: %s.%s(%s)\n\n", className, entries[i].ctx.name, paramsString) %><%
} else {
- %><%= format("\n------------------\n%s\n------------------\n", entries[i].ctx.name) %><%
+ var _length = entries[i].ctx.name.length;
+ %><%= format("\n%s\n%s\n%s\n", addLine("-", _length), entries[i].ctx.name, addLine("-", _length)) %><%
%><%- format("%s\n\n", fullDescription) %><%
%><%= format(".. js:function:: %s(%s)\n\n", entries[i].ctx.name, paramsString) %><%
}
%><%= Array.isArray(paramsStrings) ? paramsStrings.join("") : paramsStrings %><%
- // console.dir("===========================================================")
- // console.dir(examplesName)
- // console.dir(Object.keys(examples))
-
// If we have examples render them
if(examples != null && examples[examplesName]) {
%><%= format("**Examples**\n\n") %><%
@@ -2,9 +2,6 @@
<%- title %>
==================
-API Documentation
------------------
-
.. toctree::
:maxdepth: 2
@@ -22,7 +22,7 @@ API Documentation
-----------------
.. toctree::
- :maxdepth: 3
+ :maxdepth: 2
api-generated/index
api-bson-generated/index

0 comments on commit fdda08e

Please sign in to comment.