Skip to content

Commit e2b838f

Browse files
committed
make napoleon aliases global; Note -> Notes
1 parent 86b54e6 commit e2b838f

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/custom_inherit/_doc_parse_tools/napoleon_parse_tools.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
__all__ = ["merge_google_napoleon_docs", "merge_numpy_napoleon_docs"]
99

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+
1021

1122
def parse_napoleon_doc(doc, style):
1223
""" Extract the text from the various sections of a numpy-formatted docstring.
@@ -29,7 +40,7 @@ def parse_napoleon_doc(doc, style):
2940
"Attributes",
3041
"Methods",
3142
"Warning",
32-
"Note",
43+
"Notes",
3344
"Parameters",
3445
"Other Parameters",
3546
"Keyword Arguments",
@@ -40,19 +51,9 @@ def parse_napoleon_doc(doc, style):
4051
"See Also",
4152
"References",
4253
"Todo",
43-
"Example",
4454
"Examples",
4555
]
4656

47-
aliases = {
48-
"Args": "Parameters",
49-
"Arguments": "Parameters",
50-
"Keyword Args": "Keyword Arguments",
51-
"Return": "Returns",
52-
"Warnings": "Warning",
53-
"Yield": "Yields",
54-
}
55-
5657
doc_sections = OrderedDict([(key, None) for key in napoleon_sections])
5758

5859
section_items.set_defaults(doc_sections)
@@ -75,8 +76,8 @@ def parse_napoleon_doc(doc, style):
7576
if style == "numpy"
7677
else (line[:-1] if line.endswith(":") else line)
7778
)
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)] = (
8081
"\n".join(body).rstrip() if body else None
8182
)
8283
body = []
@@ -86,7 +87,7 @@ def parse_napoleon_doc(doc, style):
8687
else:
8788
body.append(line)
8889
except StopIteration:
89-
doc_sections[aliases.get(key, key)] = "\n".join(body)
90+
doc_sections[ALIASES.get(key, key)] = "\n".join(body)
9091
break
9192

9293
section_items.parse(doc_sections)

0 commit comments

Comments
 (0)