summaryrefslogtreecommitdiff
path: root/efl/utils
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-01-25 03:51:55 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2014-01-25 03:51:55 +0200
commita85177bc4b55fb18ece08144430531230f16a364 (patch)
tree6e3f2be351f6d41c53d1484ca1a3707c3e4fb3b4 /efl/utils
parentb21fde2ba7b49d54b21ce860844dbeba3232acf2 (diff)
utils.deprecated: Handle docstring indentation when modifying it.
Diffstat (limited to 'efl/utils')
-rw-r--r--efl/utils/deprecated.pyx21
1 files 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):
39 update_wrapper(wrapper, f, assigned=assignments) 39 update_wrapper(wrapper, f, assigned=assignments)
40 40
41 # Version is required for the deprecated directive 41 # Version is required for the deprecated directive
42 if wrapper.__doc__ is not None and self.version is not None: 42
43 wrapper.__doc__ += "\n\n.. deprecated:: %s\n %s\n" % (self.version, self.message) 43 doc = wrapper.__doc__
44
45 if doc is not None and self.version is not None:
46 lines = doc.expandtabs().splitlines()
47
48 indent = 0
49 if len(lines) >= 2:
50 for line in lines[1:]:
51 stripped = line.lstrip()
52 if stripped:
53 indent = len(line) - len(stripped)
54 break
55
56 wrapper.__doc__ += "\n\n"
57
58 wrapper.__doc__ += indent * " " + ".. deprecated:: %s\n" % (self.version,)
59
60 wrapper.__doc__ += (indent + 4) * " " + "%s\n" % (self.message,)
44 61
45 return wrapper 62 return wrapper
46 63