Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move "Attributes" and "Methods" below "Parameters" #571

Merged
merged 5 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions numpydoc/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ class NumpyDocString(Mapping):
"Summary": [""],
"Extended Summary": [],
"Parameters": [],
"Attributes": [],
"Methods": [],
"Returns": [],
"Yields": [],
"Receives": [],
"Other Parameters": [],
"Raises": [],
"Warns": [],
"Other Parameters": [],
"Attributes": [],
"Methods": [],
"Warnings": [],
"See Also": [],
"Notes": [],
"Warnings": [],
"References": "",
"Examples": "",
"index": {},
Expand Down Expand Up @@ -549,8 +549,10 @@ def __str__(self, func_role=""):
out += self._str_signature()
out += self._str_summary()
out += self._str_extended_summary()
out += self._str_param_list("Parameters")
for param_list in ("Attributes", "Methods"):
out += self._str_param_list(param_list)
for param_list in (
"Parameters",
"Returns",
"Yields",
"Receives",
Expand All @@ -563,8 +565,6 @@ def __str__(self, func_role=""):
out += self._str_see_also(func_role)
for s in ("Notes", "References", "Examples"):
out += self._str_section(s)
for param_list in ("Attributes", "Methods"):
out += self._str_param_list(param_list)
out += self._str_index()
return "\n".join(out)

Expand Down
12 changes: 6 additions & 6 deletions numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ def __str__(self, indent=0, func_role="obj"):
"summary": self._str_summary(),
"extended_summary": self._str_extended_summary(),
"parameters": self._str_param_list("Parameters"),
"attributes": (
self._str_param_list("Attributes", fake_autosummary=True)
if self.attributes_as_param_list
else self._str_member_list("Attributes")
),
"methods": self._str_member_list("Methods"),
"returns": self._str_returns("Returns"),
"yields": self._str_returns("Yields"),
"receives": self._str_returns("Receives"),
Expand All @@ -370,12 +376,6 @@ def __str__(self, indent=0, func_role="obj"):
"notes": self._str_section("Notes"),
"references": self._str_references(),
"examples": self._str_examples(),
"attributes": (
self._str_param_list("Attributes", fake_autosummary=True)
if self.attributes_as_param_list
else self._str_member_list("Attributes")
),
"methods": self._str_member_list("Methods"),
}
ns = {k: "\n".join(v) for k, v in ns.items()}

Expand Down
4 changes: 2 additions & 2 deletions numpydoc/templates/numpydoc_docstring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
{{summary}}
{{extended_summary}}
{{parameters}}
{{attributes}}
{{methods}}
{{returns}}
{{yields}}
{{receives}}
Expand All @@ -13,5 +15,3 @@
{{notes}}
{{references}}
{{examples}}
{{attributes}}
{{methods}}
45 changes: 37 additions & 8 deletions numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,17 @@ def test_duplicate_signature():
b
c

Other Parameters
----------------

another parameter : str
This parameter is less important.

Notes
-----

Some notes about the class.

Examples
--------
For usage examples, see `ode`.
Expand All @@ -1223,10 +1234,6 @@ def test_class_members_doc():
jac : callable ``jac(t, y, *jac_args)``
Bbb.

Examples
--------
For usage examples, see `ode`.

Attributes
----------
t : float
Expand All @@ -1251,6 +1258,19 @@ def test_class_members_doc():
b
c

Other Parameters
----------------
another parameter : str
This parameter is less important.

Notes
-----
Some notes about the class.

Examples
--------
For usage examples, see `ode`.

""",
)

Expand Down Expand Up @@ -1304,10 +1324,6 @@ def no_period(self):
**jac** : callable ``jac(t, y, *jac_args)``
Bbb.

.. rubric:: Examples

For usage examples, see `ode`.

:Attributes:

**t** : float
Expand Down Expand Up @@ -1345,6 +1361,19 @@ def no_period(self):
**c**
===== ==========

:Other Parameters:

**another parameter** : str
This parameter is less important.

.. rubric:: Notes

Some notes about the class.

.. rubric:: Examples

For usage examples, see `ode`.

""",
)

Expand Down