Skip to content

Commit a2e9eb4

Browse files
committed
Add numpydoc lint config and fix warnings
To run numpydoc lint, currently a fork of numpydoc is required, due to an unhandled exception when using sphinx cross-links in the `See Also` section. See: numpy/numpydoc#558 As still experimental, numpydoc linting/validation is not checked or required for future contributions.
1 parent 1db3afd commit a2e9eb4

File tree

3 files changed

+244
-142
lines changed

3 files changed

+244
-142
lines changed

doc/source/conf.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
extensions = [
3636
"sphinx.ext.autodoc",
3737
"sphinx.ext.viewcode",
38-
"sphinx.ext.napoleon",
38+
"sphinx.ext.napoleon", # has to be loaded before sphinx_autodoc_typehints
39+
"sphinx_autodoc_typehints",
3940
"sphinx.ext.intersphinx",
4041
"sphinx_qt_documentation",
4142
"sphinx_design",
4243
"sphinx_favicon",
4344
"sphinxext.rediraffe",
4445
"sphinxcontrib.images",
45-
"sphinx_autodoc_typehints"
4646
]
4747

4848
# Add any paths that contain templates here, relative to this directory.
@@ -67,6 +67,10 @@
6767
napoleon_use_admonition_for_notes = True
6868
napoleon_use_admonition_for_references = True
6969
napoleon_use_rtype = True
70+
napoleon_use_param = False
71+
napoleon_use_keyword = False
72+
napoleon_attr_annotations = True
73+
napoleon_use_ivar = True
7074
napoleon_custom_sections = [("Signals", "params_style")]
7175
napoleon_preprocess_types = True
7276
napoleon_type_aliases = {
@@ -77,6 +81,12 @@
7781
# 'ColorMapSpecifier': ':class:`str`, (:class:`str`, :class:`str`), or :class:`~pyqtgraph.ColorMap`',
7882
}
7983

84+
85+
# makes things far more legible
86+
python_use_unqualified_type_names = True
87+
python_display_short_literal_types = True
88+
89+
8090
# The encoding of source files.
8191
#source_encoding = 'utf-8-sig'
8292

@@ -135,13 +145,23 @@
135145
# A list of ignored prefixes for module index sorting.
136146
#modindex_common_prefix = []
137147

138-
autodoc_inherit_docstrings = False
148+
# Automatically extract typehints when specified and place them in
149+
# descriptions of the relevant function/method.
150+
autodoc_typehints = "description"
151+
autodoc_typehints_format = 'short'
152+
autodoc_typehints_description_target = 'documented_params'
153+
autodoc_typehints_defaults = 'braces'
154+
autodoc_typehints_use_rtype = True
155+
156+
139157
autodoc_mock_imports = [
140158
"scipy",
141159
"h5py",
142160
"matplotlib",
143161
]
144162

163+
# autodoc_type_aliases = {}
164+
145165

146166
# -- Options for HTML output ---------------------------------------------------
147167

pyproject.toml

+16
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ ignore_errors = true
5050
[[tool.mypy.overrides]]
5151
module = "pyqtgraph.flowchart.*" # the list will increase
5252
ignore_errors = true # will be changed to `false` when it's ready
53+
54+
[tool.numpydoc_validation]
55+
checks = [
56+
"all", # report on all checks, except the below
57+
"EX01",
58+
"SA01",
59+
"GL08", # object does not have a docstring
60+
"ES01", # no extended summary found
61+
]
62+
# remember to use single quotes for regex in TOML
63+
exclude = [ # don't report on objects that match any of these regex
64+
]
65+
66+
override_GL06 = [
67+
'Signals' # allow sections to start with "Signals"
68+
]

0 commit comments

Comments
 (0)