Skip to content

Commit

Permalink
Finished up admin class documentation as it stands now
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Jan 20, 2012
1 parent 4b9c7bf commit 01620e3
Show file tree
Hide file tree
Showing 5 changed files with 514 additions and 85 deletions.
2 changes: 1 addition & 1 deletion dev/tools/build-docs.js
Expand Up @@ -144,7 +144,7 @@ var renderAllTemplates = function(outputDirectory, templates, dataObjects, testO
}

var isFunction = function(entry) {
return entry.ctx.type == 'method';
return entry.ctx.type == 'method' && entry.isPrivate == false;
}

// Iterate over all classes
Expand Down
34 changes: 24 additions & 10 deletions dev/tools/doc-templates/class.ejs
Expand Up @@ -35,6 +35,9 @@ for(var i = 0; i < entries.length; i++) {
}
for(var i = 0; i < entries.length; i++) {
console.log("---------------------------------------------------------------")
console.dir(entries[i])
if(isFunction(entries[i])) {
var paramsStrings = [];
var paramNames = [];
Expand Down Expand Up @@ -70,7 +73,8 @@ for(var i = 0; i < entries.length; i++) {
fullDescription = fullDescription.replace(/\<pre\>\<code\>/g, ".. code-block:: javascript\n\n ")
.replace(/\<\/code\>\<\/pre\>/g, "")
.replace(/\<h2\>|\<\/h2\>/g, "**")
.replace(/\<p\>|\<\/p\>/g, "");
.replace(/\<p\>|\<\/p\>/g, "")
.replace(/\<br\>|\<\/br\>/g, "\n");
%><%= format("------------------\n%s\n------------------\n", entries[i].ctx.name) %><%
%><%- format("%s\n\n", fullDescription) %><%
Expand All @@ -84,8 +88,8 @@ for(var i = 0; i < entries.length; i++) {
if(examples[entries[i].ctx.name]) {
%><%= format("**Examples**\n\n") %><%
var examplesArray = examples[entries[i].ctx.name];
console.log("------------------------------------------------------- EXAMPLES ARRAY")
console.dir(examplesArray)
// console.log("------------------------------------------------------- EXAMPLES ARRAY")
// console.dir(examplesArray)
// Iterate over all the examples
for(var ei = 0; ei < examplesArray.length; ei++) {
// Fetch an example
Expand All @@ -95,7 +99,9 @@ for(var i = 0; i < entries.length; i++) {
.replace("native_parser: native_parser", "native_parser: false")
.replace(/test\.ok/g, "assert.ok")
.replace(/test\.equal/g, "assert.equal")
.replace(/test\.deepEqual/g, "assert.deepEqual");
.replace(/test\.deepEqual/g, "assert.deepEqual")
.replace(/\n[ |\t]*test\.done\(\)\;/, "");
// Split and adjust code
var codeLines = code.split(/\n/);
for(var ci = 0; ci < codeLines.length; ci++) {
Expand All @@ -106,21 +112,29 @@ for(var i = 0; i < entries.length; i++) {
fullDescription = fullDescription.replace(/\<pre\>\<code\>/g, ".. code-block:: javascript\n\n ")
.replace(/\<\/code\>\<\/pre\>/g, "")
.replace(/\<h2\>|\<\/h2\>/g, "**")
.replace(/\<p\>|\<\/p\>/g, "");
.replace(/\<p\>|\<\/p\>/g, "")
.replace(/\<br[ ]*\>|\<\/br[ ]*\>|\<br[ ]*\/\>/g, "\n");
// Split up and move
var fullDescriptionLines = fullDescription.split(/\n/);
for(var ci = 0; ci < fullDescriptionLines.length; ci++) {
fullDescriptionLines[ci] = " " + fullDescriptionLines[ci];
}
// Starting template Lines
var startingTemplateLines = [
" var Db = require('mongodb').Db,",
" Server = require('mongodb').Server,",
" assert = require('assert');\n\n"
];
console.log("------------------------------------------------------- EXAMPLE")
console.dir(example)
// console.log("------------------------------------------------------- EXAMPLE")
// console.dir(example)
// Let's render it
%><%= format("%s\n\n", fullDescriptionLines.join("\n")) %><%
%><%= format(" .. code-block:: javascript\n\n%s\n", codeLines.join("\n")) %><%
%><%- format("%s\n\n", fullDescriptionLines.join("\n")) %><%
%><%- format(" .. code-block:: javascript\n\n%s%s\n\n", startingTemplateLines.join("\n"), codeLines.join("\n")) %><%
}
}
}
}
%>
%>
34 changes: 30 additions & 4 deletions lib/mongodb/admin.js
Expand Up @@ -20,14 +20,22 @@ function Admin(db) {
* Retrieve the server information for the current
* instance of the db client
*
* Examples:
*
* db.admin().serverInfo(function(err, serverInfo) {})
*
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.buildInfo = function(callback) {
this.serverInfo(callback);
}

/**
* Retrieve the server information for the current
* instance of the db client
*
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api private
*/
Admin.prototype.serverInfo = function(callback) {
var self = this;
var command = {buildinfo:1};
Expand Down Expand Up @@ -149,6 +157,24 @@ Admin.prototype.addUser = function(username, password, callback) {
})
}

/**
* Remove a user from the MongoDB server
*
* @param {String} username The user name for the authentication.
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.removeUser = function(username, callback) {
var self = this;
var databaseName = this.db.databaseName;
this.db.databaseName = 'admin';
this.db.removeUser(username, function(err, result) {
self.db.databaseName = databaseName;
return callback(err, result);
})
}

/**
* Set the current profiling level of MongoDB
*
Expand Down

0 comments on commit 01620e3

Please sign in to comment.