viff

changeset 736:0f6bc89072ae

Added viff.util to documentation.
author Martin Geisler <mg@daimi.au.dk>
date Fri, 25 Apr 2008 08:25:28 +0200
parents f51415df0335
children 75f932a949eb
files doc/implementation.txt doc/util.txt viff/util.py
diffstat 3 files changed, 24 insertions(+), 16 deletions(-) [+]
line diff
     1.1 --- a/doc/implementation.txt	Fri Apr 25 08:24:12 2008 +0200
     1.2 +++ b/doc/implementation.txt	Fri Apr 25 08:25:28 2008 +0200
     1.3 @@ -7,6 +7,7 @@
     1.4  .. toctree::
     1.5     :maxdepth: 2
     1.6  
     1.7 +   util
     1.8     field
     1.9     shamir
    1.10     matrix
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/doc/util.txt	Fri Apr 25 08:25:28 2008 +0200
     2.3 @@ -0,0 +1,6 @@
     2.4 +
     2.5 +Utility Functions Module
     2.6 +========================
     2.7 +
     2.8 +.. automodule:: viff.util
     2.9 +   :members:
     3.1 --- a/viff/util.py	Fri Apr 25 08:24:12 2008 +0200
     3.2 +++ b/viff/util.py	Fri Apr 25 08:25:28 2008 +0200
     3.3 @@ -18,19 +18,21 @@
     3.4  """Miscellaneous utility functions.
     3.5  
     3.6  This module contains various utility functions used in all parts of
     3.7 -the VIFF code. The most important is the L{rand} random generator
     3.8 +the VIFF code. The most important is the :data:`rand` random generator
     3.9  which is seeded with a known seed each time. Using this generator for
    3.10  all random numbers ensures that a protocol run can be reproduced at a
    3.11  later time.
    3.12  """
    3.13  
    3.14 +__docformat__ = "restructuredtext"
    3.15 +
    3.16  import os
    3.17  import random
    3.18  import warnings
    3.19  from twisted.internet.defer import Deferred, succeed, gatherResults
    3.20  from gmpy import mpz
    3.21  
    3.22 -#: Seed for L{rand}.
    3.23 +#: Seed for :data:`rand`.
    3.24  _seed = os.environ.get('SEED')
    3.25  
    3.26  if _seed is None:
    3.27 @@ -41,8 +43,8 @@
    3.28      #: Random number generator used by all VIFF code.
    3.29      #:
    3.30      #: The generator is by default initialized with a random seed,
    3.31 -    #: unless the environment variable C{SEED} is set to a value, in
    3.32 -    #: which case that value is used instead. If C{SEED} is defined,
    3.33 +    #: unless the environment variable :envvar:`SEED` is set to a value, in
    3.34 +    #: which case that value is used instead. If :envvar:`SEED` is defined,
    3.35      #: but empty, then no seed is used and a protocol cannot be
    3.36      #: reproduced exactly.
    3.37      rand = random.Random(_seed)
    3.38 @@ -61,19 +63,17 @@
    3.39      """Decorator used for wrapper functions.
    3.40  
    3.41      It is important to use this decorator on any wrapper functions in
    3.42 -    order to ensure that they end up with correct C{__name__} and
    3.43 -    C{__doc__} attributes.
    3.44 +    order to ensure that they end up with correct :attr:`__name__` and
    3.45 +    :attr:`__doc__` attributes.
    3.46  
    3.47 -    In addition, if the environment variable C{VIFF_NO_WRAP} is
    3.48 +    In addition, if the environment variable :envvar:`VIFF_NO_WRAP` is
    3.49      defined, then the wrapper functions will be turned into functions
    3.50 -    that I{do not} wrap -- instead they let their argument function
    3.51 +    that *do not* wrap -- instead they let their argument function
    3.52      through unchanged. This is done so that epydoc and Sphinx can see
    3.53      the true function arguments when generating documentation. Just
    3.54 -    remember that your code will break if C{VIFF_NO_WRAP} is set, so
    3.55 -    it should only be used when documentation is being generated.
    3.56 -
    3.57 -    @param func: the function that will be wrapped.
    3.58 -    @type func: callable
    3.59 +    remember that your code will break if :envvar:`VIFF_NO_WRAP` is
    3.60 +    set, so it should only be used when documentation is being
    3.61 +    generated.
    3.62      """
    3.63      if os.environ.get('VIFF_NO_WRAP'):
    3.64          # Return a decorator which ignores the functions it is asked
    3.65 @@ -168,10 +168,11 @@
    3.66      """Clone a Deferred.
    3.67  
    3.68      The returned clone will fire with the same result as the original
    3.69 -    Deferred, but will otherwise be independent.
    3.70 +    :class:`Deferred`, but will otherwise be independent.
    3.71  
    3.72 -    It is an error to call callback on the clone as it will result in
    3.73 -    an AlreadyCalledError when the original Deferred is triggered.
    3.74 +    It is an error to call :meth:`callback` on the clone as it will
    3.75 +    result in an :exc:`AlreadyCalledError` when the original
    3.76 +    :class:`Deferred` is triggered.
    3.77  
    3.78      >>> x = Deferred()
    3.79      >>> x.addCallback(lambda result: result * 10) # doctest: +ELLIPSIS