From 7883605f673834b23cda65abc98abc03beec8901 Mon Sep 17 00:00:00 2001 From: Ilan Steemers Date: Thu, 2 Jul 2015 23:25:11 +0200 Subject: [PATCH] Starting rtd docs --- docs/conf.py | 15 +++++++---- docs/index.rst | 9 ++++--- docs/management.rst | 20 +++++++++++++++ docs/usage.rst | 61 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 docs/management.rst create mode 100644 docs/usage.rst diff --git a/docs/conf.py b/docs/conf.py index eb573f5..c81df97 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,6 +18,10 @@ import os import shlex import alabaster +myPath = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, myPath + '/../') +os.environ['DJANGO_SETTINGS_MODULE'] = 'django_q.tests.settings' + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -34,6 +38,7 @@ import alabaster extensions = [ 'alabaster', 'sphinx.ext.todo', + #'sphinx.ext.autodoc' ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -59,16 +64,16 @@ author = 'Ilan Steemers' # built documents. # # The short X.Y version. -version = '0.1.0' +version = '0.1.4' # The full version, including alpha/beta/rc tags. -release = '0.1.0' +release = '0.1.4.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -116,10 +121,10 @@ html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the -# documentation. +# documentation.None html_theme_options = { 'description': "A multiprocessing task queue for Django", - 'github_user': 'koed00', + 'github_user': 'Koed00', 'github_repo': 'django-q', 'gittip_user': 'koed00', 'travis_button': True, diff --git a/docs/index.rst b/docs/index.rst index 957dc12..b6a1abe 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,12 +11,15 @@ Contents: .. toctree:: :maxdepth: 2 + Introduction + Installation + Usage + Management + Admin + Architecture -Indices and tables -================== * :ref:`genindex` -* :ref:`modindex` * :ref:`search` diff --git a/docs/management.rst b/docs/management.rst new file mode 100644 index 0000000..88e1859 --- /dev/null +++ b/docs/management.rst @@ -0,0 +1,20 @@ +Management commands +=================== + +$project offers the following Django management commands + + +qcluster +-------- + +.. code:: bash + + python management.py qcluster + + +qmonitor +-------- + +.. code:: bash + + python management.py qmonitor diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..4132f4f --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,61 @@ +Usage +===== + +Use :py:func:`async` from your code to quickly offload tasks: + +.. code:: python + + from django_q import async, result + + # create the task + async('math.copysign', 2, -2) + + # or with import and storing the id + import math.copysign + + task_id = async(copysign, 2, -2) + + # get the result + task_result = result(task_id) + + # result returns None if the task has not been executed yet + # so in most cases you will want to use a hook: + + async('math.modf', 2.5, hook='hooks.print_result') + + # hooks.py + def print_result(task): + print(task.result) + +.. py:function:: async(func, *args, [hook=None,] **kwargs) + + Puts a task in the cluster queue + + :param func: The task function to execute + :param args: The arguments for the task function + :type func: str or object + :param hook: Optional function to call after execution + :type hook: str or object + :param kwargs: Keyword arguments for the task function + :returns: The name of the task + :rtype: str + +.. py:function:: result(name) + + Gets the result of a previously executed task + + :param str name: the name of the task + :returns: The result of the executed task + +.. py:function:: get_task(name) + + Returns a previously executed task + + :param str name: the name of the task + :returns: The task + :rtype: Task + + +.. py:class:: Task + + Database model describing an executed task \ No newline at end of file