File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ from ..trim_docstring import trim_docstring
2
+
3
+
4
+ def test_trim_docstring ():
5
+ class WellDocumentedObject (object ):
6
+ """
7
+ This object is very well-documented. It has multiple lines in its
8
+ description.
9
+
10
+ Multiple paragraphs too
11
+ """
12
+ pass
13
+
14
+ assert (trim_docstring (WellDocumentedObject .__doc__ ) ==
15
+ "This object is very well-documented. It has multiple lines in its\n "
16
+ "description.\n \n Multiple paragraphs too" )
17
+
18
+ class UndocumentedObject (object ):
19
+ pass
20
+
21
+ assert trim_docstring (UndocumentedObject .__doc__ ) is None
Original file line number Diff line number Diff line change
1
+ import inspect
2
+
3
+
4
+ def trim_docstring (docstring ):
5
+ # Cleans up whitespaces from an indented docstring
6
+ #
7
+ # See https://www.python.org/dev/peps/pep-0257/
8
+ # and https://docs.python.org/2/library/inspect.html#inspect.cleandoc
9
+ return inspect .cleandoc (docstring ) if docstring else None
You can’t perform that action at this time.
0 commit comments