Permalink
Browse files

Moar docs

  • Loading branch information...
jonashaag committed Nov 25, 2010
1 parent 6ebf0b4 commit 1e37f60825e8725617c2a640ca8e6461cda711ed
View
@@ -7,3 +7,4 @@
.project
django_mongodb_engine.egg-info
build
+.build
@@ -47,8 +47,8 @@ def sql_indexes_for_field(self, model, field, **kwargs):
if field.db_index:
kwargs = {}
opts = model._meta
- col = getattr(self.connection.db_connection, opts.db_table)
- descending = getattr(model._meta, "descending_indexes", [])
+ col = getattr(self.connection.database, opts.db_table)
+ descending = getattr(opts, "descending_indexes", [])
direction = (field.attname in descending and -1) or 1
kwargs["unique"] = field.unique
col.ensure_index([(field.name, direction)], **kwargs)
View
@@ -3,7 +3,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
-SPHINXBUILD = DJANGO_SETTINGS_MODULE="testproj.settings" sphinx-build
+SPHINXBUILD = DJANGO_SETTINGS_MODULE="tests.settings" sphinx-build
PAPER =
# Internal variables.
@@ -1,4 +1,8 @@
def setup(app):
+ from docutils.parsers.rst.directives.admonitions import Note
+
+ app.add_directive('forthelazy', Note) # for now
+
app.add_crossref_type(
directivename="setting",
rolename="setting",
View
@@ -18,6 +18,8 @@
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.coverage',
#'sphinxcontrib.issuetracker',
+ 'sphinx.ext.todo',
+ 'sphinx.ext.intersphinx',
'django_mongodb_engine_docs',
]
@@ -84,3 +86,6 @@
issuetracker_user = "django-mongodb-engine"
issuetracker_project = "mongodb-engine"
issuetracker_issue_pattern = r'[Ii]ssue #(\d+)'
+
+intersphinx_mapping = {'python' : ('http://docs.python.org', None),
+ 'django' : ('http://docs.djangoproject.com/en/dev/', 'django.inv')}
View
@@ -1,22 +0,0 @@
-======================================
- :mod:`django_mongodb_engine.contrib`
-======================================
-
-The :mod:`django_mongodb_engine.contrib` module contains the :class:`MongoDBManager`
-class, which provides support for performing MapReduce queries on Django models.
-(TODO: + execjs?).
-
-.. autoclass:: django_mongodb_engine.contrib.MongoDBManager
-
- .. method:: map_reduce
-
- See :meth:`django_mongodb_engine.contrib.mapreduce.MapReduceMixin.map_reduce`
-
-
-MapReduce Support for Django Models
------------------------------------
-.. autoclass:: django_mongodb_engine.contrib.mapreduce.MapReduceMixin
- :members:
-
-.. autoclass:: django_mongodb_engine.contrib.mapreduce.MapReduceResult
- :members:
View
@@ -0,0 +1,81 @@
+Other Cool Stuff
+================
+
+.. _mapreduce:
+
+Map/Reduce Support
+------------------
+For usage examples, see :file:`tests/contrib/tests.py`.
+
+.. autoclass:: django_mongodb_engine.contrib.MongoDBManager
+.. automodule:: django_mongodb_engine.contrib.mapreduce
+ :members:
+
+.. _mongodb-fields:
+
+Fields
+------
+.. automodule:: django_mongodb_engine.fields
+ :members:
+
+.. _collection-options:
+
+Collection Options
+------------------
+Collection flags can be set in a :class:`MongoMeta` attribute in a model,
+similar to Django's :class:`Meta` class:
+
+.. code-block:: python
+
+ class MyModel(models.Model):
+ # your fields here
+
+ class MongoMeta:
+ # your flags here
+
+Those flags can be:
+
+``index_together`` (default: ``[]``)
+ A list of dictionaries containing an item with the key *field* and a list of
+ field names or :samp:`({field name}, {index direction})` tuples to
+ index together, optionally containing keyword arguments to pass to
+ :meth:`pymongo.Collection.ensure_index`. For example, ::
+
+ index_together = [{'fields' : ['name', ('last_name', -1)],
+ 'name' : 'name-lastname-index'}]
+
+ results in this call::
+
+ target_collection.ensure_index([('name', 1), ('last_name', -1)], name='name-lastname-index')
+
+``descending_indexes`` (default: ``[]``)
+ A list of fields whose index shall be descending rather than ascending.
+ For example, ::
+
+ class MyModel(models.Model):
+ a = models.CharField(db_index=True)
+ b = models.CharField(db_index=True)
+
+ class MongoMeta:
+ descending_indexes = ['b']
+
+ would create an ascending index on field ``a`` and a descending one on ``b``.
+
+``capped`` (default: :const:`False`)
+ A boolean specifying whether the collection for the model shall be capped.
+
+``collection_size`` and ``collection_max`` (default: unset)
+ If using a ``capped`` collection, those two options specify the size (in bytes)
+ and the maximum number of objects of the capped collection, respectively.
+
+
+Automatic Model Instance (De)Referencing
+----------------------------------------
+If you set the ``MONGODB_AUTOMATIC_REFERENCING`` option to :class:`True` in
+your :file:`settings.py`, django-mongodb-engine automatically references
+model instances in :class:`lists <ListField>` or :class:`dicts <DictField>` on
+saves and dereferences them when you access an attribute.
+
+.. todo::
+
+ Example
Oops, something went wrong.

0 comments on commit 1e37f60

Please sign in to comment.