kuuko pushed a commit to branch python-efl-1.8. http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=e7a5e594a45ade9175e11a0273d21520e64f7761
commit e7a5e594a45ade9175e11a0273d21520e64f7761 Author: Kai Huuhko <[email protected]> Date: Sat Jan 25 03:51:55 2014 +0200 utils.deprecated: Handle docstring indentation when modifying it. --- efl/utils/deprecated.pyx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/efl/utils/deprecated.pyx b/efl/utils/deprecated.pyx index abcf073..1e9767a 100644 --- a/efl/utils/deprecated.pyx +++ b/efl/utils/deprecated.pyx @@ -39,8 +39,25 @@ cdef class DEPRECATED(object): update_wrapper(wrapper, f, assigned=assignments) # Version is required for the deprecated directive - if wrapper.__doc__ is not None and self.version is not None: - wrapper.__doc__ += "\n\n.. deprecated:: %s\n %s\n" % (self.version, self.message) + + doc = wrapper.__doc__ + + if doc is not None and self.version is not None: + lines = doc.expandtabs().splitlines() + + indent = 0 + if len(lines) >= 2: + for line in lines[1:]: + stripped = line.lstrip() + if stripped: + indent = len(line) - len(stripped) + break + + wrapper.__doc__ += "\n\n" + + wrapper.__doc__ += indent * " " + ".. deprecated:: %s\n" % (self.version,) + + wrapper.__doc__ += (indent + 4) * " " + "%s\n" % (self.message,) return wrapper --
