Make new_fn have old_fn's doc string. This is particularly useful for the ``do_...`` commands that hook into the help system. Adapted from from a comp.lang.python posting by Duncan Booth.
(new_fn, old_fn, additional_text="")
| 181 | |
| 182 | |
| 183 | def decorate_fn_with_doc(new_fn, old_fn, additional_text=""): |
| 184 | """Make new_fn have old_fn's doc string. This is particularly useful |
| 185 | for the ``do_...`` commands that hook into the help system. |
| 186 | Adapted from from a comp.lang.python posting |
| 187 | by Duncan Booth.""" |
| 188 | def wrapper(*args, **kw): |
| 189 | return new_fn(*args, **kw) |
| 190 | if old_fn.__doc__: |
| 191 | wrapper.__doc__ = strip_indentation(old_fn.__doc__) + additional_text |
| 192 | return wrapper |
| 193 | |
| 194 | |
| 195 | class Pdb(OldPdb): |