From 22769ef9963555234cc73077765ea993ce2b7fc9 Mon Sep 17 00:00:00 2001 From: Stefanie Molin <24376333+stefmolin@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:24:16 -0400 Subject: [PATCH 1/5] Update validate.py to allow parameters with trailing underscores. --- numpydoc/validate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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))) From 79932091b63aa1a4b77b2ad68cf5467b9ded5699 Mon Sep 17 00:00:00 2001 From: Stefanie Molin <24376333+stefmolin@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:37:33 -0400 Subject: [PATCH 2/5] Add test to ensure that escaping trailing underscores in parameters is accounted for. --- numpydoc/tests/test_validate.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 97c621e5..339c3d6c 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -482,6 +482,29 @@ 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 escape the them to render + properly in the documentation since trailing underscores are used to + create links. + + Parameters + ---------- + str\_ : str + Some text. + + See Also + -------- + related : Something related. + + Examples + -------- + >>> result = 1 + 1 + """ + pass + class BadGenericDocStrings: """Everything here has a bad docstring""" From e535bbe20afb106fc1ffcb6d68139148c6428964 Mon Sep 17 00:00:00 2001 From: Stefanie Molin <24376333+stefmolin@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:40:39 -0400 Subject: [PATCH 3/5] Update test_validate.py --- numpydoc/tests/test_validate.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 339c3d6c..800a2d47 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -486,9 +486,10 @@ 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 escape the them to render + Parameters with trailing underscores need to be escaped to render properly in the documentation since trailing underscores are used to - create links. + create links. Doing so without also handling the change in the validation + logic makes it impossible to both pass validation and render correctly. Parameters ---------- From 077b8a181372841772d9f085357f08b3297d44ba Mon Sep 17 00:00:00 2001 From: Stefanie Molin <24376333+stefmolin@users.noreply.github.com> Date: Fri, 19 Aug 2022 19:00:49 -0400 Subject: [PATCH 4/5] Fix spacing in test case. --- numpydoc/tests/test_validate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 800a2d47..09f0a3bd 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -485,7 +485,7 @@ def valid_options_in_parameter_description_sets(self, bar): 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 @@ -504,7 +504,7 @@ def parameters_with_trailing_underscores(self, str_): -------- >>> result = 1 + 1 """ - pass + pass class BadGenericDocStrings: From 08a401a2e1d55283c8fd18171ac8b0d85358d33d Mon Sep 17 00:00:00 2001 From: Stefanie Molin <24376333+stefmolin@users.noreply.github.com> Date: Wed, 24 Aug 2022 20:01:08 -0400 Subject: [PATCH 5/5] Add parameters_with_trailing_underscores to test_good_functions() --- numpydoc/tests/test_validate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 09f0a3bd..080affab 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -1144,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):