Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sphinx-build warnings and turn warnings into errors #942

Merged
merged 7 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ build:
python: "3.11"

sphinx:
configuration: docs/conf.py
configuration: docs/conf.py
fail_on_warning: true
44 changes: 38 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ def _compute_navigation_tree(context):
furo._compute_navigation_tree = _compute_navigation_tree


# Pull in fix from https://github.com/sphinx-doc/sphinx/pull/11222/files to fix
# "invalid signature for autoattribute ('ops.pebble::ServiceDict.backoff-delay')"
import re
import sphinx.ext.autodoc
sphinx.ext.autodoc.py_ext_sig_re = re.compile(
r'''^ ([\w.]+::)? # explicit module name
([\w.]+\.)? # module and/or class name(s)
([^.()]+) \s* # thing name
(?: \((.*)\) # optional: arguments
(?:\s* -> \s* (.*))? # return annotation
)? $ # and nothing more
''', re.VERBOSE)


# -- Project information -----------------------------------------------------

project = 'The Operator Framework'
Expand Down Expand Up @@ -59,12 +73,30 @@ def _compute_navigation_tree(context):
# domain name if present. Example entries would be ('py:func', 'int') or
# ('envvar', 'LD_LIBRARY_PATH').
nitpick_ignore = [
('py:class', 'TextIO'), # typing.TextIO confuses the nitpicker
('py:class', 'method'), # types.Method confuses the nitpicker
('py:class', '_ModelBackend'), # private
('py:class', '_ModelCache'), # private
('py:class', 'ipaddress.ip_address'), # fake (AFAIK there is no ABC)
('py:class', 'ipaddress.ip_network'), # ditto
('py:class', '_AddressDict'),
('py:class', '_ChangeDict'),
('py:class', '_CheckInfoDict'),
('py:class', '_FileInfoDict'),
('py:class', '_IOSource'),
('py:class', '_NetworkDict'),
('py:class', '_ProgressDict'),
('py:class', '_Readable'),
('py:class', '_RelationMetaDict'),
('py:class', '_ResourceMetaDict'),
('py:class', '_ServiceInfoDict'),
('py:class', '_StorageMetaDict'),
('py:class', '_SystemInfoDict'),
('py:class', '_TaskDict'),
('py:class', '_TextOrBinaryIO'),
('py:class', '_WarningDict'),
('py:class', '_WebSocket'),
('py:class', '_Writeable'),
('py:class', 'ops.model._ModelBackend'),
('py:class', 'ops.model._ModelCache'),
('py:class', 'ops.storage.JujuStorage'),
('py:class', 'ops.storage.SQLiteStorage'),
('py:class', 'ops.testing.CharmType'),
('py:obj', 'ops.testing.CharmType'),
]

# Add any Sphinx extension module names here, as strings. They can be
Expand Down
4 changes: 3 additions & 1 deletion ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
'ObjectEvents',
'PreCommitEvent',
'PrefixedEvents',
'Serializable',
'StoredDict',
'StoredList',
'StoredSet',
Expand Down Expand Up @@ -174,7 +175,7 @@
# This allows "import ops; ops.main(Charm)" to work as expected.
from . import main # type: ignore # noqa: F401

# Explicitly import names from sub-modules so users can just "import ops" and
# Explicitly import names from submodules so users can just "import ops" and
# then use them as "ops.X".
from .charm import ( # noqa: F401
ActionEvent,
Expand Down Expand Up @@ -236,6 +237,7 @@
ObjectEvents,
PreCommitEvent,
PrefixedEvents,
Serializable,
StoredDict,
StoredList,
StoredSet,
Expand Down
Loading