mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
evaluate content at function start
This commit is contained in:
parent
921e4ed2ee
commit
66fa40c300
|
@ -28,13 +28,14 @@ def dedent(content):
|
||||||
as it fails to dedent multiline docstrings that include
|
as it fails to dedent multiline docstrings that include
|
||||||
unindented text on the initial line.
|
unindented text on the initial line.
|
||||||
"""
|
"""
|
||||||
|
content = unicode(content)
|
||||||
whitespace_counts = [len(line) - len(line.lstrip(' '))
|
whitespace_counts = [len(line) - len(line.lstrip(' '))
|
||||||
for line in content.splitlines()[1:] if line.lstrip()]
|
for line in content.splitlines()[1:] if line.lstrip()]
|
||||||
|
|
||||||
# unindent the content if needed
|
# unindent the content if needed
|
||||||
if whitespace_counts:
|
if whitespace_counts:
|
||||||
whitespace_pattern = '^' + (' ' * min(whitespace_counts))
|
whitespace_pattern = '^' + (' ' * min(whitespace_counts))
|
||||||
content = re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', unicode(content))
|
content = re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', content)
|
||||||
|
|
||||||
return content.strip()
|
return content.strip()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user