Skip to content

Commit

Permalink
Fix sphinxext related issues
Browse files Browse the repository at this point in the history
Sphinx 6.2.1 is the last version of Sphinx that supports Python 3.8, so
this updates the dev requirements to use that.

There were changes in the ast module, so this updates the sphinxext code
to stop using deprecated things.

This adds "sphinx" as an extra and adds that to the relevant
documentation.
  • Loading branch information
willkg committed Oct 3, 2023
1 parent 3b9638c commit 23ea240
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ Run::

Some configuration environments require additional dependencies::


# For INI support
$ pip install 'everett[ini]'

# for YAML support
$ pip install 'everett[yaml]'

Additionally, if you want to use the Sphinx extension to document
your configuration, you need to add Sphinx::

# to use the Sphinx extension
$ pip install 'everett[sphinx]'

Quick start
===========
Expand Down
8 changes: 4 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Requirements file for developing on Everett.
-e .[ini,yaml]
-e .[ini,yaml,sphinx]

black==23.9.1
check-manifest==0.49
Expand All @@ -12,6 +12,6 @@ tox-gh-actions==3.1.3
twine==4.0.2
types-PyYAML==6.0.12.12

# These require Python 3.8+ before we can update them
Sphinx==5.3.0
sphinx_rtd_theme==1.0.0
# We need to drop support for Python 3.8 before we can update this further.
Sphinx==6.2.1
sphinx_rtd_theme==1.3.0
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def get_file(fn):

INSTALL_REQUIRES = []
EXTRAS_REQUIRE = {
"sphinx": ["sphinx"],
"ini": ["configobj"],
"yaml": ["PyYAML"],
}
Expand Down
12 changes: 9 additions & 3 deletions src/everett/sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

"""Sphinx extension for auto-documenting components with configuration."""
"""Sphinx extension for auto-documenting components with configuration.
To use this, you must install the optional requirements::
$ pip install 'everett[sphinx]'
"""

import ast
from importlib import import_module
Expand Down Expand Up @@ -705,12 +711,12 @@ def extract_configuration(
# }
for key, val in zip(node.keys, node.values):
if (
isinstance(key, ast.Str)
isinstance(key, ast.Constant)
and isinstance(val, ast.Call)
and isinstance(val.func, ast.Name)
and val.func.id == variable_name
):
config_nodes.append((key.s, val))
config_nodes.append((key.value, val))

CONFIG_ARGS = [
"key",
Expand Down

0 comments on commit 23ea240

Please sign in to comment.