7
7
8
8
__all__ = ["merge_google_napoleon_docs" , "merge_numpy_napoleon_docs" ]
9
9
10
+ ALIASES = {
11
+ "Args" : "Parameters" ,
12
+ "Arguments" : "Parameters" ,
13
+ "Keyword Args" : "Keyword Arguments" ,
14
+ "Return" : "Returns" ,
15
+ "Warnings" : "Warning" ,
16
+ "Yield" : "Yields" ,
17
+ "Note" : "Notes" ,
18
+ "Example" : "Examples" ,
19
+ }
20
+
10
21
11
22
def parse_napoleon_doc (doc , style ):
12
23
""" Extract the text from the various sections of a numpy-formatted docstring.
@@ -29,7 +40,7 @@ def parse_napoleon_doc(doc, style):
29
40
"Attributes" ,
30
41
"Methods" ,
31
42
"Warning" ,
32
- "Note " ,
43
+ "Notes " ,
33
44
"Parameters" ,
34
45
"Other Parameters" ,
35
46
"Keyword Arguments" ,
@@ -40,19 +51,9 @@ def parse_napoleon_doc(doc, style):
40
51
"See Also" ,
41
52
"References" ,
42
53
"Todo" ,
43
- "Example" ,
44
54
"Examples" ,
45
55
]
46
56
47
- aliases = {
48
- "Args" : "Parameters" ,
49
- "Arguments" : "Parameters" ,
50
- "Keyword Args" : "Keyword Arguments" ,
51
- "Return" : "Returns" ,
52
- "Warnings" : "Warning" ,
53
- "Yield" : "Yields" ,
54
- }
55
-
56
57
doc_sections = OrderedDict ([(key , None ) for key in napoleon_sections ])
57
58
58
59
section_items .set_defaults (doc_sections )
@@ -75,8 +76,8 @@ def parse_napoleon_doc(doc, style):
75
76
if style == "numpy"
76
77
else (line [:- 1 ] if line .endswith (":" ) else line )
77
78
)
78
- if header and (header in doc_sections or header in aliases ):
79
- doc_sections [aliases .get (key , key )] = (
79
+ if header and (header in doc_sections or header in ALIASES ):
80
+ doc_sections [ALIASES .get (key , key )] = (
80
81
"\n " .join (body ).rstrip () if body else None
81
82
)
82
83
body = []
@@ -86,7 +87,7 @@ def parse_napoleon_doc(doc, style):
86
87
else :
87
88
body .append (line )
88
89
except StopIteration :
89
- doc_sections [aliases .get (key , key )] = "\n " .join (body )
90
+ doc_sections [ALIASES .get (key , key )] = "\n " .join (body )
90
91
break
91
92
92
93
section_items .parse (doc_sections )
0 commit comments