Skip to content

Commit

Permalink
Initial merge of sphinx 10gen doc framework
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Jan 18, 2012
1 parent afcdf8e commit 403fc4e
Show file tree
Hide file tree
Showing 23 changed files with 1,310 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.settings
data
node_modules
output
output
build
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

NODE = node
NODEUNIT = deps/nodeunit/bin/nodeunit
DOX = node_modules/dox/bin/dox
name = all

total: build_native
Expand Down Expand Up @@ -59,4 +59,8 @@ clean:
rm ./external-libs/bson/bson.node
rm -r ./external-libs/bson/build

generate_docs:
$(DOX) < lib/mongodb/admin.js > build/admin.json
$(NODE) tools/debug-doc.js

.PHONY: total
139 changes: 136 additions & 3 deletions lib/mongodb/admin.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
/*!
* Module dependencies.
*/
var Collection = require('./collection').Collection,
Cursor = require('./cursor').Cursor,
DbCommand = require('./commands/db_command').DbCommand,
debug = require('util').debug,
inspect = require('util').inspect;
DbCommand = require('./commands/db_command').DbCommand;

/**
* Allows the user to access the admin functionality of MongoDB
*
* @class Represents the Admin methods of MongoDB.
* @param db Current db instance we wish to perform Admin operations on.
* @return {Function} Constructor for Admin type.
*/
var Admin = exports.Admin = function(db) {
this.db = 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.serverInfo = function(callback) {
var self = this;
var command = {buildinfo:1};
Expand All @@ -17,6 +37,17 @@ Admin.prototype.serverInfo = function(callback) {
});
}

/**
* Retrieve the current profiling Level for MongoDB
*
* Examples:
*
* db.admin().profilingLevel(function(err, profilingLevel) {})
*
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.profilingLevel = function(callback) {
var self = this;
var command = {profile:-1};
Expand All @@ -41,6 +72,20 @@ Admin.prototype.profilingLevel = function(callback) {
});
};

/**
* Ping the MongoDB server and retrieve results
*
* Options:
*
* Examples:
*
* db.admin().ping([options], function(err, profilingLevel) {})
*
* @param {Object} [options] Optional parameters to the command.
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.ping = function(options, callback) {
// Unpack calls
var args = Array.prototype.slice.call(arguments, 0);
Expand All @@ -56,6 +101,19 @@ Admin.prototype.ping = function(options, callback) {
})
}

/**
* Authenticate against MongoDB
*
* Examples:
*
* db.admin().authenticate(username, password, function(err, authenticated) {})
*
* @param {String} username The user name for the authentication.
* @param {String} password The password for the authentication.
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.authenticate = function(username, password, callback) {
var self = this;
var databaseName = this.db.databaseName;
Expand All @@ -66,6 +124,18 @@ Admin.prototype.authenticate = function(username, password, callback) {
})
}

/**
* Logout current authenticated user
*
* Examples:
*
* db.admin().logout([options], function(err, result) {})
*
* @param {Object} [options] Optional parameters to the command.
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.logout = function(options, callback) {
var self = this;
var databaseName = this.db.databaseName;
Expand All @@ -77,6 +147,20 @@ Admin.prototype.logout = function(options, callback) {
self.db.databaseName = databaseName;
}

/**
* Add a user to the MongoDB server, if the user exists it will
* overwrite the current password
*
* Examples:
*
* db.admin().addUser(username, password, function(err, result) {})
*
* @param {String} username The user name for the authentication.
* @param {String} password The password for the authentication.
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.addUser = function(username, password, callback) {
var self = this;
var databaseName = this.db.databaseName;
Expand All @@ -87,6 +171,18 @@ Admin.prototype.addUser = function(username, password, callback) {
})
}

/**
* Set the current profiling level of MongoDB
*
* Examples:
*
* db.admin().setProfilingLevel(level, function(err, result) {})
*
* @param {String} level The new profiling level (off, slow_only, all)
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.setProfilingLevel = function(level, callback) {
var self = this;
var command = {};
Expand Down Expand Up @@ -116,6 +212,17 @@ Admin.prototype.setProfilingLevel = function(level, callback) {
});
};

/**
* Retrive the current profiling information for MongoDB
*
* Examples:
*
* db.admin().profilingInfo(function(err, result) {})
*
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.profilingInfo = function(callback) {
var self = this;
var databaseName = this.db.databaseName;
Expand All @@ -132,6 +239,19 @@ Admin.prototype.profilingInfo = function(callback) {
self.db.databaseName = databaseName;
};

/**
* Execute a db command against the Admin database
*
* Examples:
*
* db.admin().command(command, [options], function(err, result) {})
*
* @param {Object} command A command object `{ping:1}`.
* @param {Object} [options] Optional parameters to the command.
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.command = function(command, options, callback) {
var self = this;
var args = Array.prototype.slice.call(arguments, 1);
Expand All @@ -145,6 +265,19 @@ Admin.prototype.command = function(command, options, callback) {
});
}

/**
* Validate an existing collection
*
* Examples:
*
* db.admin().validateCollection(collectionName, [options], function(err, result) {})
*
* @param {String} collectionName The name of the collection to validate.
* @param {Object} [options] Optional parameters to the command.
* @param {Function} callback Callback function of format `function(err, result) {}`.
* @return {null} Returns no result
* @api public
*/
Admin.prototype.validateCollection = function(collectionName, options, callback) {
var args = Array.prototype.slice.call(arguments, 1);
callback = args.pop();
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
, "os" : [ "linux"
, "darwin"
, "freebsd" ]
, "devDependencies": {
"dox": "0.1.3"
}
, "config": { "native" : false }
, "main": "./lib/mongodb/index"
, "directories" : { "lib" : "./lib/mongodb" }
Expand Down
1 change: 1 addition & 0 deletions sphinx-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
130 changes: 130 additions & 0 deletions sphinx-docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS = -c ./
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
-rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/MongoDB.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/MongoDB.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/MongoDB"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MongoDB"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
Loading

0 comments on commit 403fc4e

Please sign in to comment.