dochub links

This commit is contained in:
Mike Dirolf 2010-02-05 14:24:26 -05:00
parent b09a95ccc1
commit ea2a2b6abd
8 changed files with 42 additions and 1 deletions

View File

@ -82,7 +82,6 @@ def process_mongodoc_nodes(app, doctree, fromdocname):
new_para = nodes.paragraph()
new_para += link
node.replace(para, new_para)
break
def setup(app):

View File

@ -16,6 +16,8 @@
The :mod:`gridfs` package is an implementation of GridFS on top of
:mod:`pymongo`, exposing a file-like interface.
.. mongodoc:: gridfs
"""
from gridfs.grid_file import GridFile
@ -32,6 +34,8 @@ class GridFS(object):
:Parameters:
- `database`: database to use
.. mongodoc:: gridfs
"""
if not isinstance(database, Database):
raise TypeError("database must be an instance of Database")

View File

@ -49,6 +49,8 @@ class Collection(object):
- `options`: dictionary of collection options. see
:meth:`~pymongo.database.Database.create_collection` for
details.
.. mongodoc:: collections
"""
if not isinstance(name, basestring):
raise TypeError("name must be an instance of basestring")
@ -169,6 +171,8 @@ class Collection(object):
- `to_save`: the SON object to be saved
- `manipulate` (optional): manipulate the SON object before saving it
- `safe` (optional): check that the save succeeded?
.. mongodoc:: insert
"""
if not isinstance(to_save, dict):
raise TypeError("cannot save object of type %s" % type(to_save))
@ -201,6 +205,8 @@ class Collection(object):
.. versionchanged:: 1.1
Bulk insert works with any iterable
.. mongodoc:: insert
"""
docs = doc_or_docs
if isinstance(docs, dict):
@ -275,6 +281,8 @@ class Collection(object):
.. _update modifiers: http://www.mongodb.org/display/DOCS/Updating
.. _upsert: http://www.mongodb.org/display/DOCS/Updating#Updating-Upserts
.. mongodoc:: update
"""
if not isinstance(spec, dict):
raise TypeError("spec must be an instance of dict")
@ -328,6 +336,8 @@ class Collection(object):
removed.
.. versionadded:: 1.1
The `safe` parameter.
.. mongodoc:: remove
"""
spec = spec_or_object_id
if spec is None:
@ -511,6 +521,8 @@ class Collection(object):
.. seealso:: :meth:`ensure_index`
.. _compound index: http://www.mongodb.org/display/DOCS/Indexes#Indexes-CompoundKeysIndexes
.. mongodoc:: indexes
"""
if not isinstance(key_or_list, (str, unicode, list)):
raise TypeError("key_or_list must either be a single key "
@ -774,6 +786,8 @@ class Collection(object):
.. versionadded:: 1.2
.. _map reduce command: http://www.mongodb.org/display/DOCS/MapReduce
.. mongodoc:: mapreduce
"""
command = SON([("mapreduce", self.__name),
("map", map), ("reduce", reduce)])

View File

@ -132,6 +132,8 @@ class Connection(object): # TODO support auth for pooling
parameters.
.. versionadded:: 1.1
The `network_timeout` parameter.
.. mongodoc:: connections
"""
if host is None:
host = self.HOST

View File

@ -42,6 +42,8 @@ class Cursor(object):
"""Create a new cursor.
Should not be called directly by application developers.
.. mongodoc:: cursors
"""
self.__collection = collection
self.__spec = spec
@ -166,6 +168,8 @@ class Cursor(object):
:Parameters:
- `limit`: the number of results to return
.. mongodoc:: limit
"""
if not isinstance(limit, int):
raise TypeError("limit must be an int")
@ -340,6 +344,8 @@ class Cursor(object):
def explain(self):
"""Returns an explain plan record for this cursor.
.. mongodoc:: explain
"""
c = self.clone()
c.__explain = True

View File

@ -50,6 +50,8 @@ class Database(object):
- `connection`: a :class:`~pymongo.connection.Connection`
instance
- `name`: database name
.. mongodoc:: databases
"""
if not isinstance(name, basestring):
raise TypeError("name must be an instance of basestring")
@ -234,6 +236,8 @@ class Database(object):
.. versionchanged:: 1.4+
`command` can be a string in addition to a full document.
.. versionadded:: 1.4
.. mongodoc:: commands
"""
if isinstance(command, str):
@ -308,6 +312,8 @@ class Database(object):
Returns one of (:data:`~pymongo.OFF`,
:data:`~pymongo.SLOW_ONLY`, :data:`~pymongo.ALL`).
.. mongodoc:: profiling
"""
result = self.command({"profile": -1})
@ -323,6 +329,8 @@ class Database(object):
:Parameters:
- `level`: the profiling level to use
.. mongodoc:: profiling
"""
if not isinstance(level, int) or level < 0 or level > 2:
raise ValueError("level must be one of (OFF, SLOW_ONLY, ALL)")
@ -331,6 +339,8 @@ class Database(object):
def profiling_info(self):
"""Returns a list containing current profiling information.
.. mongodoc:: profiling
"""
return list(self["system.profile"].find())
@ -463,6 +473,8 @@ class Database(object):
:Parameters:
- `name`: the name of the user to authenticate
- `password`: the password of the user to authenticate
.. mongodoc:: authenticate
"""
if not isinstance(name, basestring):
raise TypeError("name must be an instance of basestring")

View File

@ -35,6 +35,8 @@ class DBRef(object):
.. versionadded:: 1.1.1
The `database` parameter.
.. mongodoc:: dbrefs
"""
if not isinstance(collection, basestring):
raise TypeError("collection must be an instance of basestring")

View File

@ -68,6 +68,8 @@ class ObjectId(object):
hexadecimal digits).
.. _ObjectId: http://www.mongodb.org/display/DOCS/Object+IDs
.. mongodoc:: objectids
"""
if oid is None:
self.__generate()