Skip to content
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
25 changes: 25 additions & 0 deletions numpydoc/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,30 @@ def valid_options_in_parameter_description_sets(self, bar):
>>> result = 1 + 1
"""

def parameters_with_trailing_underscores(self, str_):
r"""
Ensure PR01 and PR02 errors are not raised with trailing underscores.

Parameters with trailing underscores need to be escaped to render
properly in the documentation since trailing underscores are used to
create links. Doing so without also handling the change in the validation
logic makes it impossible to both pass validation and render correctly.

Parameters
----------
str\_ : str
Some text.

See Also
--------
related : Something related.

Examples
--------
>>> result = 1 + 1
"""
pass


class BadGenericDocStrings:
"""Everything here has a bad docstring"""
Expand Down Expand Up @@ -1120,6 +1144,7 @@ def test_good_class(self, capsys):
"other_parameters",
"warnings",
"valid_options_in_parameter_description_sets",
"parameters_with_trailing_underscores",
],
)
def test_good_functions(self, capsys, func):
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def add_stars(param_name, info):
def parameter_mismatches(self):
errs = []
signature_params = self.signature_parameters
all_params = tuple(self.doc_all_parameters)
all_params = tuple(param.replace("\\", "") for param in self.doc_all_parameters)
missing = set(signature_params) - set(all_params)
if missing:
errs.append(error("PR01", missing_params=str(missing)))
Expand Down