Changeset 1794

Show
Ignore:
Timestamp:
07/31/07 01:10:06 (1 year ago)
Author:
arj..@yirdis.nl
Message:

lots of docstring updates, for better epydoc html.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphas/trunk/epydoc.conf

    r1296 r1794  
    1010parse: yes 
    1111introspect: yes 
    12 #exclude: .*\.tests.* 
     12exclude: .*\.tests.* 
    1313inheritance: listed 
    1414private: no 
     
    2222top: gaphas 
    2323frames: no 
    24 sourcecode: no 
     24sourcecode: yes 
    2525 
  • gaphas/trunk/gaphas/canvas.py

    r1789 r1794  
    2020    Context used for updating and drawing items in a drawing canvas. 
    2121 
    22         >>> c=Context(one=1,two='two') 
    23         >>> c.one 
    24        
    25         >>> c.two 
    26         'two' 
    27         >>> try: c.one = 2 
    28         ... except: 'got exc' 
    29         'got exc' 
     22    >>> c=Context(one=1,two='two') 
     23    >>> c.one 
     24   
     25    >>> c.two 
     26    'two' 
     27    >>> try: c.one = 2 
     28    ... except: 'got exc' 
     29    'got exc' 
    3030    """ 
    3131    def __init__(self, **kwargs): 
     
    3939    """ 
    4040    Container class for items. 
    41  
    42     Attributes: 
    43      - projector: canvas constraint projector between item and canvas 
    44        coordinates 
    45      - sorter: items sorter in order used to add items to canvas 
    4641    """ 
    4742 
     
    6358    def add(self, item, parent=None): 
    6459        """ 
    65         Add an item to the canvas 
    66  
    67             >>> c = Canvas() 
    68             >>> from gaphas import item 
    69             >>> i = item.Item() 
    70             >>> c.add(i) 
    71             >>> len(c._tree.nodes) 
    72            
    73             >>> i._canvas is c 
    74             True 
     60        Add an item to the canvas. 
     61 
     62        >>> c = Canvas() 
     63        >>> from gaphas import item 
     64        >>> i = item.Item() 
     65        >>> c.add(i) 
     66        >>> len(c._tree.nodes) 
     67       
     68        >>> i._canvas is c 
     69        True 
    7570        """ 
    7671        assert item not in self._tree.nodes, 'Adding already added node %s' % item 
     
    10095    def remove(self, item): 
    10196        """ 
    102         Remove item from the canvas 
    103  
    104             >>> c = Canvas() 
    105             >>> from gaphas import item 
    106             >>> i = item.Item() 
    107             >>> c.add(i) 
    108             >>> c.remove(i) 
    109             >>> c._tree.nodes 
    110             [] 
    111             >>> i._canvas 
    112  
     97        Remove item from the canvas. 
     98 
     99        >>> c = Canvas() 
     100        >>> from gaphas import item 
     101        >>> i = item.Item() 
     102        >>> c.add(i) 
     103        >>> c.remove(i) 
     104        >>> c._tree.nodes 
     105        [] 
     106        >>> i._canvas 
    113107        """ 
    114108        for child in reversed(self.get_children(item)): 
     
    139133    def get_all_items(self): 
    140134        """ 
    141         Get a list of all items 
    142             >>> c = Canvas() 
    143             >>> c.get_all_items() 
    144             [] 
    145             >>> from gaphas import item 
    146             >>> i = item.Item() 
    147             >>> c.add(i
    148             >>> c.get_all_items() # doctest: +ELLIPSIS 
    149             [<gaphas.item.Item ...>] 
    150  
     135        Get a list of all items. 
     136 
     137        >>> c = Canvas() 
     138        >>> c.get_all_items() 
     139        [] 
     140        >>> from gaphas import item 
     141        >>> i = item.Item(
     142        >>> c.add(i) 
     143        >>> c.get_all_items() # doctest: +ELLIPSIS 
     144        [<gaphas.item.Item ...>] 
    151145        """ 
    152146        return self._tree.nodes 
     
    156150        Return the root items of the canvas. 
    157151 
    158             >>> c = Canvas() 
    159             >>> c.get_all_items() 
    160             [] 
    161             >>> from gaphas import item 
    162             >>> i = item.Item() 
    163             >>> c.add(i) 
    164             >>> ii = item.Item() 
    165             >>> c.add(ii, i) 
    166             >>> c.get_root_items() # doctest: +ELLIPSIS 
    167             [<gaphas.item.Item ...>] 
     152        >>> c = Canvas() 
     153        >>> c.get_all_items() 
     154        [] 
     155        >>> from gaphas import item 
     156        >>> i = item.Item() 
     157        >>> c.add(i) 
     158        >>> ii = item.Item() 
     159        >>> c.add(ii, i) 
     160        >>> c.get_root_items() # doctest: +ELLIPSIS 
     161        [<gaphas.item.Item ...>] 
    168162        """ 
    169163        return self._tree.get_children(None) 
     
    178172    def get_parent(self, item): 
    179173        """ 
    180         See tree.Tree.get_parent() 
    181             >>> c = Canvas() 
    182             >>> from gaphas import item 
    183             >>> i = item.Item() 
    184             >>> c.add(i) 
    185             >>> ii = item.Item() 
    186             >>> c.add(ii, i) 
    187             >>> c.get_parent(i) 
    188             >>> c.get_parent(ii) # doctest: +ELLIPSIS 
    189             <gaphas.item.Item ...> 
     174        See `tree.Tree.get_parent()`. 
     175 
     176        >>> c = Canvas() 
     177        >>> from gaphas import item 
     178        >>> i = item.Item() 
     179        >>> c.add(i) 
     180        >>> ii = item.Item() 
     181        >>> c.add(ii, i) 
     182        >>> c.get_parent(i) 
     183        >>> c.get_parent(ii) # doctest: +ELLIPSIS 
     184        <gaphas.item.Item ...> 
    190185        """ 
    191186        return self._tree.get_parent(item) 
     
    193188    def get_ancestors(self, item): 
    194189        """ 
    195         See tree.Tree.get_ancestors() 
    196             >>> c = Canvas() 
    197             >>> from gaphas import item 
    198             >>> i = item.Item() 
    199             >>> c.add(i) 
    200             >>> ii = item.Item() 
    201             >>> c.add(ii, i) 
    202             >>> iii = item.Item() 
    203             >>> c.add(iii, ii) 
    204             >>> list(c.get_ancestors(i)) 
    205             [] 
    206             >>> list(c.get_ancestors(ii)) # doctest: +ELLIPSIS 
    207             [<gaphas.item.Item ...>] 
    208             >>> list(c.get_ancestors(iii)) # doctest: +ELLIPSIS 
    209             [<gaphas.item.Item ...>, <gaphas.item.Item ...>] 
     190        See `tree.Tree.get_ancestors()`. 
     191 
     192        >>> c = Canvas() 
     193        >>> from gaphas import item 
     194        >>> i = item.Item() 
     195        >>> c.add(i) 
     196        >>> ii = item.Item() 
     197        >>> c.add(ii, i) 
     198        >>> iii = item.Item() 
     199        >>> c.add(iii, ii) 
     200        >>> list(c.get_ancestors(i)) 
     201        [] 
     202        >>> list(c.get_ancestors(ii)) # doctest: +ELLIPSIS 
     203        [<gaphas.item.Item ...>] 
     204        >>> list(c.get_ancestors(iii)) # doctest: +ELLIPSIS 
     205        [<gaphas.item.Item ...>, <gaphas.item.Item ...>] 
    210206        """ 
    211207        return self._tree.get_ancestors(item) 
     
    213209    def get_children(self, item): 
    214210        """ 
    215         See tree.Tree.get_children() 
    216             >>> c = Canvas() 
    217             >>> from gaphas import item 
    218             >>> i = item.Item() 
    219             >>> c.add(i) 
    220             >>> ii = item.Item() 
    221             >>> c.add(ii, i) 
    222             >>> iii = item.Item() 
    223             >>> c.add(iii, ii) 
    224             >>> list(c.get_children(iii)) 
    225             [] 
    226             >>> list(c.get_children(ii)) # doctest: +ELLIPSIS 
    227             [<gaphas.item.Item ...>] 
    228             >>> list(c.get_children(i)) # doctest: +ELLIPSIS 
    229             [<gaphas.item.Item ...>] 
     211        See `tree.Tree.get_children()`. 
     212 
     213        >>> c = Canvas() 
     214        >>> from gaphas import item 
     215        >>> i = item.Item() 
     216        >>> c.add(i) 
     217        >>> ii = item.Item() 
     218        >>> c.add(ii, i) 
     219        >>> iii = item.Item() 
     220        >>> c.add(iii, ii) 
     221        >>> list(c.get_children(iii)) 
     222        [] 
     223        >>> list(c.get_children(ii)) # doctest: +ELLIPSIS 
     224        [<gaphas.item.Item ...>] 
     225        >>> list(c.get_children(i)) # doctest: +ELLIPSIS 
     226        [<gaphas.item.Item ...>] 
    230227        """ 
    231228        return self._tree.get_children(item) 
     
    233230    def get_all_children(self, item): 
    234231        """ 
    235         See tree.Tree.get_all_children() 
    236             >>> c = Canvas() 
    237             >>> from gaphas import item 
    238             >>> i = item.Item() 
    239             >>> c.add(i) 
    240             >>> ii = item.Item() 
    241             >>> c.add(ii, i) 
    242             >>> iii = item.Item() 
    243             >>> c.add(iii, ii) 
    244             >>> list(c.get_all_children(iii)) 
    245             [] 
    246             >>> list(c.get_all_children(ii)) # doctest: +ELLIPSIS 
    247             [<gaphas.item.Item ...>] 
    248             >>> list(c.get_all_children(i)) # doctest: +ELLIPSIS 
    249             [<gaphas.item.Item ...>, <gaphas.item.Item ...>] 
     232        See `tree.Tree.get_all_children()`. 
     233 
     234        >>> c = Canvas() 
     235        >>> from gaphas import item 
     236        >>> i = item.Item() 
     237        >>> c.add(i) 
     238        >>> ii = item.Item() 
     239        >>> c.add(ii, i) 
     240        >>> iii = item.Item() 
     241        >>> c.add(iii, ii) 
     242        >>> list(c.get_all_children(iii)) 
     243        [] 
     244        >>> list(c.get_all_children(ii)) # doctest: +ELLIPSIS 
     245        [<gaphas.item.Item ...>] 
     246        >>> list(c.get_all_children(i)) # doctest: +ELLIPSIS 
     247        [<gaphas.item.Item ...>, <gaphas.item.Item ...>] 
    250248        """ 
    251249        return self._tree.get_all_children(item) 
     
    253251    def get_connected_items(self, item): 
    254252        """ 
    255         Return a set of items that are connected to @item
     253        Return a set of items that are connected to ``item``
    256254        The list contains tuples (item, handle). As a result an item may be 
    257255        in the list more than once (depending on the number of handles that 
    258         are connected). If @item is connected to itself it will also appear 
     256        are connected). If ``item`` is connected to itself it will also appear 
    259257        in the list. 
    260258 
    261             >>> c = Canvas() 
    262             >>> from gaphas import item 
    263             >>> i = item.Line() 
    264             >>> c.add(i) 
    265             >>> ii = item.Line() 
    266             >>> c.add(ii) 
    267             >>> iii = item.Line() 
    268             >>> c.add (iii) 
    269             >>> i.handles()[0].connected_to = ii 
    270             >>> list(c.get_connected_items(i)) 
    271             [] 
    272             >>> ii.handles()[0].connected_to = iii 
    273             >>> list(c.get_connected_items(ii)) # doctest: +ELLIPSIS 
    274             [(<gaphas.item.Line ...>, <Handle object on (0, 0)>)] 
    275             >>> list(c.get_connected_items(iii)) # doctest: +ELLIPSIS 
    276             [(<gaphas.item.Line ...>, <Handle object on (0, 0)>)] 
     259        >>> c = Canvas() 
     260        >>> from gaphas import item 
     261        >>> i = item.Line() 
     262        >>> c.add(i) 
     263        >>> ii = item.Line() 
     264        >>> c.add(ii) 
     265        >>> iii = item.Line() 
     266        >>> c.add (iii) 
     267        >>> i.handles()[0].connected_to = ii 
     268        >>> list(c.get_connected_items(i)) 
     269        [] 
     270        >>> ii.handles()[0].connected_to = iii 
     271        >>> list(c.get_connected_items(ii)) # doctest: +ELLIPSIS 
     272        [(<gaphas.item.Line ...>, <Handle object on (0, 0)>)] 
     273        >>> list(c.get_connected_items(iii)) # doctest: +ELLIPSIS 
     274        [(<gaphas.item.Line ...>, <Handle object on (0, 0)>)] 
    277275        """ 
    278276        connected_items = set() 
     
    285283    def get_matrix_i2c(self, item, calculate=False): 
    286284        """ 
    287         Get the Item to Canvas matrix for @item. 
    288  
    289         item: The item who's item-to-canvas transformation matrix should be 
    290               found 
    291         calculate: True will allow this function to actually calculate it, 
    292               in stead of raising an AttributeError when no matrix is present 
    293               yet. Note that out-of-date matrices are not recalculated. 
     285        Get the Item to Canvas matrix for ``item``. 
     286 
     287        item: 
     288            The item who's item-to-canvas transformation matrix should be 
     289            found 
     290        calculate: 
     291            True will allow this function to actually calculate it, 
     292            in stead of raising an AttributeError when no matrix is present 
     293            yet. Note that out-of-date matrices are not recalculated. 
    294294        """ 
    295295        if item._matrix_i2c is None or calculate: 
     
    300300    def get_matrix_c2i(self, item, calculate=False): 
    301301        """ 
    302         Get the Canvas to Item matrix for @item
    303         See get_matrix_i2c()
     302        Get the Canvas to Item matrix for ``item``
     303        See `get_matrix_i2c()`
    304304        """ 
    305305        if item._matrix_c2i is None or calculate: 
     
    313313        Set an update request for the item.  
    314314 
    315             >>> c = Canvas() 
    316             >>> from gaphas import item 
    317             >>> i = item.Item() 
    318             >>> ii = item.Item() 
    319             >>> c.add(i) 
    320             >>> c.add(ii, i) 
    321             >>> len(c._dirty_items) 
    322            
    323             >>> c.update_now() 
    324             >>> len(c._dirty_items) 
    325            
     315        >>> c = Canvas() 
     316        >>> from gaphas import item 
     317        >>> i = item.Item() 
     318        >>> ii = item.Item() 
     319        >>> c.add(i) 
     320        >>> c.add(ii, i) 
     321        >>> len(c._dirty_items) 
     322       
     323        >>> c.update_now() 
     324        >>> len(c._dirty_items) 
     325       
    326326        """ 
    327327        if update: 
     
    342342    def require_update(self): 
    343343        """ 
    344         Returns True or False depending on if an update is needed. 
    345  
    346             >>> c=Canvas() 
    347             >>> c.require_update() 
    348             False 
    349             >>> from gaphas import item 
    350             >>> i = item.Item() 
    351             >>> c.add(i) 
    352             >>> c.require_update() 
    353             False 
     344        Returns ``True`` or ``False`` depending on if an update is needed. 
     345 
     346        >>> c=Canvas() 
     347        >>> c.require_update() 
     348        False 
     349        >>> from gaphas import item 
     350        >>> i = item.Item() 
     351        >>> c.add(i) 
     352        >>> c.require_update() 
     353        False 
    354354 
    355355        Since we're not in a GTK+ mainloop, the update is not scheduled 
    356         asynchronous. Therefor require_update() returns False
     356        asynchronous. Therefore ``require_update()`` returns ``False``
    357357        """ 
    358358        return bool(self._dirty_items) 
     
    530530 
    531531        For example having an item 
     532 
    532533        >>> from item import Element 
    533534        >>> c = Canvas() 
     
    540541 
    541542        and moving its first handle a bit 
     543 
    542544        >>> e.handles()[0].x += 1 
    543545        >>> map(float, e.handles()[0].pos) 
     
    545547 
    546548        After normalization 
     549 
    547550        >>> c._normalize([e])          # doctest: +ELLIPSIS 
    548551        set([<gaphas.item.Element object at ...>]) 
     
    602605        that is used to create a context. 
    603606 
    604             >>> c = Canvas() 
    605             >>> c.update_now() 
     607        >>> c = Canvas() 
     608        >>> c.update_now() 
    606609        """ 
    607610        for view in self._registered_views: 
     
    617620class VariableProjection(solver.Projection): 
    618621    """ 
    619     Project a single gaphas.solver.Variable to another space/coordinate system. 
     622    Project a single `solver.Variable` to another space/coordinate system. 
    620623 
    621624    The value has been set in the "other" coordinate system. A callback is 
  • gaphas/trunk/gaphas/constraint.py

    r1793 r1794  
    11""" 
    2 Module ``gaphas.constraint`` contains several flavors of constraint solver 
    3 classes (constraints for short), for example 
    4  - equality constraint - two variables should have the same value 
    5  - less than constraint - keep one variables smaller than other 
    6  
    7 Variables should be of type ``gaphas.solver.Variable``. 
     2This module contains several flavors of constraint classes. 
     3Each has a method `Constraint.solve_for(name)` and a method 
     4`Constraint.mark_dirty(v)`. These methods are used by the constraint solver 
     5(`solver.Solver`) to set the variables. 
     6 
     7Variables should be of type `solver.Variable`. 
    88 
    99See classes' documentation below for constraints description and for 
    1010examples of their usage. 
    1111 
     12EqualsConstraint 
     13    Make 'a' and 'b' equal. 
     14LessThanConstraint 
     15    Ensure one variable stays smaller than the other. 
     16CenterConstraint 
     17    Ensures a Variable is kept between two other variables. 
     18EquationConstraint 
     19    Solve a linear equation. 
     20BalanceConstraint 
     21    Keeps three variables in line, maintaining a specific ratio. 
     22LineConstraint 
     23    Solves the equation where a line is connected to a line or side at a 
     24    specific point. 
     25 
    1226New constraint class should derive from Constraint class abstract class and 
    13 implement Constraint.solve_for(Variable) method to update a variable with 
     27implement `Constraint.solve_for(Variable)` method to update a variable with 
    1428appropriate value. 
    1529""" 
     
    179193class LessThanConstraint(Constraint): 
    180194    """ 
    181     Ensure @smaller is less than @bigger. The variable that is passed 
     195    Ensure ``smaller`` is less than ``bigger``. The variable that is passed 
    182196    as to-be-solved is left alone (cause it is the variable that has not 
    183197    been moved lately). Instead the other variable is solved. 
     
    195209 
    196210    Also minimal delta between two values can be set 
     211 
    197212    >>> a, b = Variable(10.0), Variable(8.0) 
    198213    >>> lt = LessThanConstraint(smaller=a, bigger=b, delta=5) 
     
    225240    Takes a function, named arg value (opt.) and returns a Constraint object 
    226241    Calling EquationConstraint.solve_for will solve the equation for 
    227     variable @arg, so that the outcome is 0. 
     242    variable ``arg``, so that the outcome is 0. 
    228243 
    229244    >>> from solver import Variable 
     
    359374class BalanceConstraint(Constraint): 
    360375    """ 
    361     Ensure that a variable @v is between values specified by @band 
    362     and in distance proportional from @band[0]
     376    Ensure that a variable ``v`` is between values specified by ``band`` 
     377    and in distance proportional from ``band[0]``
    363378 
    364379    Consider 
     380 
    365381    >>> from solver import Variable, WEAK 
    366382    >>> a, b, c = Variable(2.0), Variable(3.0), Variable(2.3, WEAK) 
     
    373389    (Variable(2, 20), Variable(3, 20), Variable(2.3, 10)) 
    374390 
    375     Band does not have to be band[0] < band[1] 
     391    Band does not have to be ``band[0] < band[1]`` 
     392 
    376393    >>> a, b, c = Variable(3.0), Variable(2.0), Variable(2.45, WEAK) 
    377394    >>> bc = BalanceConstraint(band=(a,b), v=c) 
     
    463480        """ 
    464481        Solve the equation for the connected_handle. 
     482         
    465483        >>> from gaphas.solver import Variable 
    466484        >>> line = (Variable(0), Variable(0)), (Variable(30), Variable(20)) 
  • gaphas/trunk/gaphas/decorators.py

    r1670 r1794  
    1818    the GTK main loop. Otherwise the method is executed directly. 
    1919 
    20     Note: the current implementation of async single mode only works for 
    21           methods, not functions. 
     20    Note: 
     21        the current implementation of async single mode only works for 
     22        methods, not functions. 
    2223 
    2324    Calling the async function from outside the gtk main loop will yield 
    2425    imediate execution: 
    2526 
    26     async just works on functions (as long as single=False): 
     27    async just works on functions (as long as ``single=False``): 
    2728 
    28         >>> a = async()(lambda: 'Hi') 
    29         >>> a() 
    30         'Hi' 
     29    >>> a = async()(lambda: 'Hi') 
     30    >>> a() 
     31    'Hi' 
    3132 
    3233    Simple method: 
    3334     
    34         >>> class A(object): 
    35         ...     @async(single=False, priority=gobject.PRIORITY_HIGH) 
    36         ...     def a(self): 
    37         ...         print 'idle-a', gobject.main_depth() 
     35    >>> class A(object): 
     36    ...     @async(single=False, priority=gobject.PRIORITY_HIGH) 
     37    ...     def a(self): 
     38    ...         print 'idle-a', gobject.main_depth() 
    3839     
    3940    Methods can also set sinle mode to True (the method is only scheduled one). 
    4041 
    41         >>> class B(object): 
    42         ...     @async(single=True) 
    43         ...     def b(self): 
    44         ...         print 'idle-b', gobject.main_depth() 
     42    >>> class B(object): 
     43    ...     @async(single=True) 
     44    ...     def b(self): 
     45    ...         print 'idle-b', gobject.main_depth() 
    4546 
    4647    This is a helper function used to test classes A and B from within the GTK+ 
    4748    main loop: 
    4849 
    49         >>> def delayed(): 
    50         ...     print 'before' 
    51         ...     a = A() 
    52         ...     b = B() 
    53         ...     a.a() 
    54         ...     b.b() 
    55         ...     a.a() 
    56         ...     b.b() 
    57         ...     a.a() 
    58         ...     b.b() 
    59         ...     print 'after' 
    60         ...     gobject.timeout_add(100, gtk.main_quit) 
    61         >>> gobject.timeout_add(1, delayed) > 0 # timeout id may vary 
    62         True 
    63         >>> import gtk 
    64         >>> gtk.main() 
    65         before 
    66         after 
    67         idle-a 1 
    68         idle-a 1 
    69         idle-a 1 
    70         idle-b 1 
     50    >>> def delayed(): 
     51    ...     print 'before' 
     52    ...     a = A() 
     53    ...     b = B() 
     54    ...     a.a() 
     55    ...     b.b() 
     56    ...     a.a() 
     57    ...     b.b() 
     58    ...     a.a() 
     59    ...     b.b() 
     60    ...     print 'after' 
     61    ...     gobject.timeout_add(100, gtk.main_quit) 
     62    >>> gobject.timeout_add(1, delayed) > 0 # timeout id may vary 
     63    True 
     64    >>> import gtk 
     65    >>> gtk.main() 
     66    before 
     67    after 
     68    idle-a 1 
     69    idle-a 1 
     70    idle-a 1 
     71    idle-b 1 
    7172 
    72     As you can see, although b.b() has been called three times, it's only 
     73    As you can see, although ``b.b()`` has been called three times, it's only 
    7374    executed once. 
    7475    """ 
     
    111112    Enforce a function or method is not executed recursively: 
    112113 
    113         >>> class A(object): 
    114         ...     @nonrecursive 
    115         ...     def a(self, x=1): 
    116         ...         print x 
    117         ...         self.a(x+1) 
    118         >>> A().a() 
    119        
    120         >>> A().a() 
    121        
     114    >>> class A(object): 
     115    ...     @nonrecursive 
     116    ...     def a(self, x=1): 
     117    ...         print x 
     118    ...         self.a(x+1) 
     119    >>> A().a() 
     120   
     121    >>> A().a() 
     122   
    122123    """ 
    123124    def wrapper(*args, **kwargs): 
  • gaphas/trunk/gaphas/geometry.py

    r1710 r1794  
    475475def rectangle_clip(recta, rectb): 
    476476    """ 
    477     Return the clipped rectangle of recta and rectb. If they do not intersect, 
    478     None is returned. 
     477    Return the clipped rectangle of ``recta`` and ``rectb``. If they do not 
     478    intersect, ``None`` is returned. 
     479 
    479480    >>> rectangle_clip((0, 0, 20, 20), (10, 10, 20, 20)) 
    480481    (10, 10, 10, 10) 
  • gaphas/trunk/gaphas/solver.py

    r1753 r1794  
    99 
    1010Gaphas' solver allows to define constraints between Variable instances. 
    11 Constraint classes are defined in gaphas.constraint module. 
     11Constraint classes are defined in `gaphas.constraint` module. 
    1212 
    1313How It Works 
    14 ============ 
     14------------ 
    1515Every constraint contains list of variables and has to be registered in 
    16 solver object. Variables change (Variables.dirty, Solver.request_resolve 
     16solver object. Variables change (`Variable.dirty()`, `Solver.request_resolve()` 
    1717methods) and their constraints are marked by solver as dirty. To solve 
    1818constraints, solver loops through dirty constraints and asks constraint for 
     
    2727(weakest variable invariants defined above) 
    2828 
    29 Having weakest variable (Constraint.weakest method) every constraint is 
    30 being asked to solve itself (Constraint.solv_for method) changing 
    31 appropriate variables to make the constraint valid again. 
     29Having weakest variable (`constraint.Constraint.weakest()` method) every 
     30constraint is being asked to solve itself (`constraint.Constraint.solve_for()` 
     31method) changing appropriate variables to make the constraint valid again. 
    3232""" 
    3333 
     
    232232    def __truediv__(self, other): 
    233233        """ 
    234         #>>> from __future__ import division 
    235234        >>> Variable(5.) / 4 
    236235        1.25 
     
    302301    def __rtruediv__(self, other): 
    303302        """ 
    304         #>>> from __future__ import division 
    305303        >>> 5. / Variable(4) 
    306304        1.25 
     
    355353        If projections_only is set to True, only constraints using the 
    356354        variable through a Projection instance (e.i. variable itself is not 
    357         in Constraint.variables()) are marked. 
     355        in `constraint.Constraint.variables()`) are marked. 
    358356 
    359357        Example: 
     358 
    360359        >>> from constraint import EquationConstraint 
    361360        >>> a, b, c = Variable(1.0), Variable(2.0), Variable(3.0) 
     
    401400 
    402401        Example: 
     402 
    403403        >>> from constraint import EquationConstraint 
    404404        >>> s = Solver() 
     
    429429    @observed 
    430430    def remove_constraint(self, constraint): 
    431         """ Remove a constraint from the solver 
     431        """ 
     432        Remove a constraint from the solver 
     433 
    432434        >>> from constraint import EquationConstraint 
    433435        >>> s = Solver() 
     
    443445 
    444446        Removing a constraint twice has no effect: 
     447 
    445448        >>> s.remove_constraint(c) 
    446  
    447449        """ 
    448450        for v in constraint.variables(): 
     
    460462        Return an iterator of constraints that work with variable. 
    461463        The variable in question should be exposed by the constraints 
    462         variables() method. 
     464        `constraint.Constraint.variables()` method. 
    463465 
    464466        >>> from constraint import EquationConstraint 
     
    486488        """ 
    487489        Example: 
     490 
    488491        >>> from constraint import EquationConstraint 
    489492        >>> a, b, c = Variable(1.0), Variable(2.0), Variable(3.0) 
  • gaphas/trunk/gaphas/state.py

    r1791 r1794  
    2626 
    2727# This string is added to each docstring in order to denote is's observed 
    28 OBSERVED_DOCSTRING = \ 
    29         '\n\nThis method is @observed. See gaphas.state for extra info.\n' 
     28#OBSERVED_DOCSTRING = \ 
     29#        '\n\n        This method is @observed. See gaphas.state for extra info.\n' 
    3030 
    3131# Tell @observed to dispatch invokation messages by default 
     
    6363    dec = decorator(wrapper, func) 
    6464     
    65     dec.__doc__ = (dec.__doc__ or '') + OBSERVED_DOCSTRING 
     65    #dec.__doc__ = (dec.__doc__ or '') + OBSERVED_DOCSTRING 
    6666    func.__observer__ = dec 
    6767    if DISPATCH_BY_DEFAULT: