diff options
author | Stefanie Molin <24376333+stefmolin@users.noreply.github.com> | 2022-08-25 04:51:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 04:51:27 -0400 |
commit | 4ef89d4da0d494a5b7f6ecf1bd613599e50336bf (patch) | |
tree | 6a18e3be0f29946b08f851163f566c89b278a5d6 | |
parent | 5720f08d105f3ad9ce52537a06232eb5d5b22247 (diff) | |
download | numpydoc-4ef89d4da0d494a5b7f6ecf1bd613599e50336bf.tar.gz |
ENH: Update validate.py to allow parameters with trailing underscores. (#425)
* Update validate.py to allow parameters with trailing underscores.
* Add test to ensure that escaping trailing underscores in parameters is accounted for.
* Update test_validate.py
* Fix spacing in test case.
* Add parameters_with_trailing_underscores to test_good_functions()
-rw-r--r-- | numpydoc/tests/test_validate.py | 25 | ||||
-rw-r--r-- | numpydoc/validate.py | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 97c621e..080affa 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -482,6 +482,30 @@ class GoodDocStrings: >>> 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 @@ class TestValidator: "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 4a323b9..cc058f0 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -330,7 +330,7 @@ class Validator: 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))) |