diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 97c621e5..080affab 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -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""" @@ -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): diff --git a/numpydoc/validate.py b/numpydoc/validate.py index 4a323b92..cc058f0d 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -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)))