diff options
author | chris.burns <chris.burns@localhost> | 2007-12-15 23:27:14 +0000 |
---|---|---|
committer | chris.burns <chris.burns@localhost> | 2007-12-15 23:27:14 +0000 |
commit | 22fbdc5c744674550be074550862645ddf423b31 (patch) | |
tree | 30fcc217bd8420d64ccda7e243c0838e2af5e3ff | |
parent | 94e351cbda3fb151af4ae18d6ebfc9b409e27022 (diff) | |
download | numpy-22fbdc5c744674550be074550862645ddf423b31.tar.gz |
Added docstrings to deprecate funcs
-rw-r--r-- | utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -84,6 +84,15 @@ else: return func def deprecate(func, oldname=None, newname=None): + """Deprecate old functions. + Issues a DeprecationWarning, adds warning to oldname's docstring, + rebinds oldname.__name__ and returns new function object. + + Example: + oldfunc = deprecate(newfunc, 'oldfunc', 'newfunc') + + """ + import warnings if oldname is None: oldname = func.func_name @@ -113,6 +122,17 @@ def deprecate(func, oldname=None, newname=None): return newfunc def deprecate_with_doc(somestr): + """Decorator to deprecate functions and provide detailed documentation + with 'somestr' that is added to the functions docstring. + + Example: + depmsg = 'function numpy.lib.foo has been merged into numpy.lib.io.foobar' + @deprecate_with_doc(depmsg) + def foo(): + pass + + """ + def _decorator(func): newfunc = deprecate(func) newfunc.__doc__ += "\n" + somestr |