|
19 | 19 |
|
20 | 20 | """robottools.context.method |
21 | 21 |
|
22 | | -Provides :class:`contextmethod` for creating `testlibrary` method decorators |
23 | | -to separate method implementations for different contexts |
24 | | -of :class:`ContextHandler`s. |
| 22 | +Provides :class:`robottools.contextmethod` |
| 23 | +for creating Test Library method decorators, |
| 24 | +separating method implementations for different contexts |
| 25 | +of :class:`robottools.ContextHandler`-derived definitions. |
25 | 26 |
|
26 | 27 | .. moduleauthor:: Stefan Zimmermann <zimmermann.code@gmail.com> |
27 | 28 | """ |
|
32 | 33 |
|
33 | 34 | class contextmethod(object): |
34 | 35 | """Class for creating `testlibrary` method decorators |
35 | | - to separate method implementations for different contexts |
36 | | - of :class:`ContextHandler`s. |
| 36 | + to separate method implementations for different contexts |
| 37 | + of :class:`ContextHandler`s. |
37 | 38 |
|
38 | | - - Decorated methods get Context name attributes for decorating |
| 39 | + * Decorated methods get Context name attributes for decorating |
39 | 40 | the Context specific method implementations:: |
40 | 41 |
|
41 | 42 | @contextmethod(Handler) |
42 | 43 | def method(self, ...): |
43 | 44 | pass |
44 | 45 |
|
45 | | - @method.<context name> |
| 46 | + @method.context_name |
46 | 47 | def context_method(self, ...): |
47 | 48 | ... |
48 | 49 |
|
49 | | - - By default, on method call only the implementation |
| 50 | + * By default, on method call only the implementation |
50 | 51 | matching the currently active Context will be called. |
51 | 52 |
|
52 | | - - A @contextmethod.combined(Handler) decorated method |
| 53 | + * A ``@contextmethod.combined(Handler)`` decorated method |
53 | 54 | will call all context specific implementations |
54 | | - and return a `dict` containing the results by Context name keys. |
55 | | - - contextmethod.combined decorated methods will get an additional |
56 | | - .result decorator for defining a hook method |
| 55 | + and return a ``dict`` containing the results by Context name keys. |
| 56 | + * contextmethod.combined decorated methods will get an additional |
| 57 | + ``.result`` decorator for defining a hook method |
57 | 58 | processing the results dict before final return:: |
58 | 59 |
|
59 | 60 | @method.result |
60 | 61 | def result_method(self, results_dict): |
61 | 62 | ... |
62 | 63 | return results_dict # or whatever... |
63 | 64 |
|
64 | | - - A @contextmethod.combined.lazy(Handler) decorated method |
65 | | - will return a :class:`LazyDict` which will call |
66 | | - the context specific implementations on first ['<context name>'] access. |
| 65 | + * A ``@contextmethod.combined.lazy(Handler)`` decorated method |
| 66 | + will return a ``moretools.LazyDict`` instance which will call |
| 67 | + the context specific implementations on first |
| 68 | + ``['context_name']`` access. |
67 | 69 | """ |
68 | 70 | def __init__(self, *handlers, **options): |
69 | 71 | """Create a decorator for the given `handlers`. |
70 | 72 |
|
71 | | - - Currently only 1 Handler supported :( - will change soon :) |
72 | | - - `options` are implicitly given |
73 | | - by derived :class:`combined` and :class:`lazy`. |
| 73 | + * Currently only 1 Handler supported :( - will change soon :) |
| 74 | + * `options` are implicitly given |
| 75 | + by derived :class:`contextmethod.combined` and ``moretools.Lazy``. |
74 | 76 | """ |
75 | 77 | self.handlers = handlers |
76 | 78 | self.combined = options.pop('combined', False) |
@@ -132,6 +134,7 @@ def resultdeco(resultfunc): |
132 | 134 | method.result = resultdeco |
133 | 135 |
|
134 | 136 | method.__name__ = func.__name__ |
| 137 | + method.__doc__ = func.__doc__ |
135 | 138 | return method |
136 | 139 |
|
137 | 140 |
|
|
0 commit comments