Skip to content

Commit 2e3e329

Browse files
Remove numpydoc validation from Sphinx build (#2480)
1 parent dc1809c commit 2e3e329

File tree

3 files changed

+46
-67
lines changed

3 files changed

+46
-67
lines changed

docs/conf.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import inspect
1616
import os
1717
import sys
18-
import tomllib
1918
import warnings
2019
from pathlib import Path
2120

@@ -184,22 +183,6 @@
184183
# ----------------
185184
numpydoc_class_members_toctree = False # https://stackoverflow.com/a/73294408
186185

187-
with open(PROJECT_ROOT / "tools/tool-data.toml", "rb") as f:
188-
numpydoc_skip_errors = tomllib.load(f)["numpydoc_skip_errors"]
189-
190-
numpydoc_validation_checks = {"all"} | set(numpydoc_skip_errors)
191-
numpydoc_validation_exclude = { # regex to ignore during docstring check
192-
r"\.__getitem__",
193-
r"\.__contains__",
194-
r"\.__hash__",
195-
r"\.__mul__",
196-
r"\.__sub__",
197-
r"\.__add__",
198-
r"\.__iter__",
199-
r"\.__div__",
200-
r"\.__neg__",
201-
}
202-
203186
# Add any paths that contain custom static files (such as style sheets) here,
204187
# relative to this directory. They are copied after the builtin static files,
205188
# so a file named "default.css" will overwrite the builtin "default.css".

tools/numpydoc-public-api.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import importlib
1212
import logging
1313
import sys
14-
import tomllib
1514
import types
1615
from pathlib import Path
1716

@@ -26,6 +25,51 @@
2625
PUBLIC_MODULES = ["parcels", "parcels.interpolators"]
2726
ROOT_PACKAGE = "parcels"
2827

28+
# full list of numpydoc error codes: https://numpydoc.readthedocs.io/en/latest/validation.html
29+
SKIP_ERRORS = [
30+
"GL01", # parcels is fine with the summary line starting directly after `"""`, or on the next line.
31+
"SA01", # Parcels doesn't require the "See also" section
32+
"SA04", #
33+
"ES01", # We don't require the extended summary for all docstrings
34+
"EX01", # We don't require the "Examples" section for all docstrings
35+
"SS06", # Not possible to make all summaries one line
36+
#
37+
# To be fixed up
38+
"GL02", # Closin÷g quotes should be placed in the line after the last text in the docstring (do not close the quotes in the same line as the text, or leave a blank line between the last text and the quotes)
39+
"GL03", # Double line break found; please use only one blank line to separate sections or paragraphs, and do not leave blank lines at the end of docstrings
40+
"GL05", # Tabs found at the start of line "{line_with_tabs}", please use whitespace only
41+
"GL06", # Found unknown section "{section}". Allowed sections are: {allowed_sections}
42+
"GL07", # Sections are in the wrong order. Correct order is: {correct_sections}
43+
"GL08", # The object does not have a docstring
44+
"SS01", # No summary found (a short summary in a single line should be present at the beginning of the docstring)
45+
"SS02", # Summary does not start with a capital letter
46+
"SS03", # Summary does not end with a period
47+
"SS04", # Summary contains heading whitespaces
48+
"SS05", # Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
49+
"PR01", # Parameters {missing_params} not documented
50+
"PR02", # Unknown parameters {unknown_params}
51+
"PR03", # Wrong parameters order. Actual: {actual_params}. Documented: {documented_params}
52+
"SA02", # Missing period at end of description for See Also "{reference_name}" reference
53+
"SA03", # Description should be capitalized for See Also
54+
#
55+
# TODO consider whether to continue ignoring the following
56+
"GL09", # Deprecation warning should precede extended summary
57+
"GL10", # reST directives {directives} must be followed by two colons
58+
"PR04", # Parameter "{param_name}" has no type
59+
"PR05", # Parameter "{param_name}" type should not finish with "."
60+
"PR06", # Parameter "{param_name}" type should use "{right_type}" instead of "{wrong_type}"
61+
"PR07", # Parameter "{param_name}" has no description
62+
"PR08", # Parameter "{param_name}" description should start with a capital letter
63+
"PR09", # Parameter "{param_name}" description should finish with "."
64+
"PR10", # Parameter "{param_name}" requires a space before the colon separating the parameter name and type
65+
"RT01", # No Returns section found
66+
"RT02", # The first line of the Returns section should contain only the type, unless multiple values are being returned
67+
"RT03", # Return value has no description
68+
"RT04", # Return value description should start with a capital letter
69+
"RT05", # Return value description should finish with "."
70+
"YD01", # No Yields section found
71+
]
72+
2973

3074
def is_built_in(type_or_instance: type | object):
3175
if isinstance(type_or_instance, type):
@@ -100,8 +144,6 @@ def main():
100144

101145
logger.setLevel(log_level)
102146

103-
with open(PROJECT_ROOT / "tools/tool-data.toml", "rb") as f:
104-
skip_errors = tomllib.load(f)["numpydoc_skip_errors"]
105147
public_api = []
106148
for module in PUBLIC_MODULES:
107149
public_api += walk_module(module)
@@ -117,7 +159,7 @@ def main():
117159
if res["type"] in ("module", "float", "int", "dict"):
118160
continue
119161
for err in res["errors"]:
120-
if err[0] not in skip_errors:
162+
if err[0] not in SKIP_ERRORS:
121163
print(f"{item}: {err}")
122164
errors += 1
123165
sys.exit(errors)

tools/tool-data.toml

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)