Skip to content

Commit

Permalink
fix _Opt deprecation warning (#236)
Browse files Browse the repository at this point in the history
* fix _Opt deprecation warning

closes #234

* build(deps): docs

* ci(docs): build on Python 3.12
  • Loading branch information
drts01 authored May 28, 2024
1 parent bf8ef76 commit 64ed88f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
version: py312
docs:
docker:
- image: 'cimg/python:3.11'
- image: 'cimg/python:3.12'
steps:
- checkout
- run: pip install --user tox
Expand Down
63 changes: 25 additions & 38 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,88 +1,75 @@
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --extra=doc --output-file=docs/requirements.txt pyproject.toml
#
alabaster==0.7.13
alabaster==0.7.16
# via sphinx
anyascii==0.3.2
astroid==3.2.2
# via sphinx-autoapi
astroid==2.15.6
# via sphinx-autoapi
babel==2.12.1
babel==2.15.0
# via sphinx
certifi==2023.7.22
certifi==2024.2.2
# via requests
charset-normalizer==3.2.0
charset-normalizer==3.3.2
# via requests
docutils==0.18.1
docutils==0.20.1
# via
# sphinx
# sphinx-rtd-theme
# sphinx-tabs
idna==3.4
idna==3.7
# via requests
imagesize==1.4.1
# via sphinx
jinja2==3.1.2
jinja2==3.1.4
# via
# sphinx
# sphinx-autoapi
lazy-object-proxy==1.9.0
# via astroid
markupsafe==2.1.3
markupsafe==2.1.5
# via jinja2
packaging==23.1
packaging==24.0
# via sphinx
pygments==2.16.1
pygments==2.18.0
# via
# sphinx
# sphinx-tabs
pyyaml==6.0.1
# via sphinx-autoapi
requests==2.31.0
requests==2.32.2
# via sphinx
snowballstemmer==2.2.0
# via sphinx
sphinx==7.2.3
sphinx==7.3.7
# via
# sphinx-autoapi
# sphinx-notfound-page (pyproject.toml)
# sphinx-rtd-theme
# sphinx-tabs
# sphinxcontrib-applehelp
# sphinxcontrib-devhelp
# sphinxcontrib-htmlhelp
# sphinxcontrib-jquery
# sphinxcontrib-qthelp
# sphinxcontrib-serializinghtml
# sphinxemoji
sphinx-autoapi==2.1.1
sphinx-autoapi==3.1.1
# via sphinx-notfound-page (pyproject.toml)
sphinx-rtd-theme==1.3.0
sphinx-rtd-theme==2.0.0
# via sphinx-notfound-page (pyproject.toml)
sphinx-tabs==3.4.1
sphinx-tabs==3.4.5
# via sphinx-notfound-page (pyproject.toml)
sphinxcontrib-applehelp==1.0.7
sphinxcontrib-applehelp==1.0.8
# via sphinx
sphinxcontrib-devhelp==1.0.5
sphinxcontrib-devhelp==1.0.6
# via sphinx
sphinxcontrib-htmlhelp==2.0.4
sphinxcontrib-htmlhelp==2.0.5
# via sphinx
sphinxcontrib-jquery==4.1
# via sphinx-rtd-theme
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==1.0.6
sphinxcontrib-qthelp==1.0.7
# via sphinx
sphinxcontrib-serializinghtml==1.1.9
sphinxcontrib-serializinghtml==1.1.10
# via sphinx
sphinxemoji==0.2.0
sphinxemoji==0.3.1
# via sphinx-notfound-page (pyproject.toml)
typing-extensions==4.7.1
# via astroid
urllib3==2.0.4
urllib3==2.2.1
# via requests
wrapt==1.15.0
# via astroid
33 changes: 22 additions & 11 deletions notfound/extension.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import html
import docutils.nodes
import os
import warnings

import docutils.nodes
import sphinx
from sphinx.environment.collectors import EnvironmentCollector
from sphinx.errors import ExtensionError
Expand All @@ -13,7 +13,6 @@

class BaseURIError(ExtensionError):
"""Exception for malformed base URI."""
pass


# https://www.sphinx-doc.org/en/stable/extdev/appapi.html#event-html-collect-pages
Expand Down Expand Up @@ -167,7 +166,11 @@ def toctree(*args, **kwargs):
# We have to overwrite them here to use our own `pathto` function.
# The code is borrowed exactly from Sphinx 7.2.2, there is no changes.
if sphinx.version_info >= (7, 2):
from sphinx.builders.html._assets import _CascadingStyleSheet, _file_checksum, _JavaScript
from sphinx.builders.html._assets import (
_CascadingStyleSheet,
_file_checksum,
_JavaScript,
)

outdir = app.outdir

Expand Down Expand Up @@ -266,14 +269,22 @@ def validate_configs(app, *args, **kwargs):
Shows a warning if one of the configs is not valid.
"""
default, rebuild, types = app.config.values.get('notfound_urls_prefix')
if app.config.notfound_urls_prefix != default:
if app.config.notfound_urls_prefix and not all([
app.config.notfound_urls_prefix.startswith('/'),
app.config.notfound_urls_prefix.endswith('/'),
]):
message = 'notfound_urls_prefix should start and end with "/" (slash)'
warnings.warn(message, UserWarning, stacklevel=2)
notfound_urls_prefix = app.config.notfound_urls_prefix
default = (
app.config.values.get("notfound_urls_prefix").default
if sphinx.version_info >= (7, 2)
else app.config.values.get("notfound_urls_prefix")[0]
)

if (
notfound_urls_prefix != default
and notfound_urls_prefix
and not (
notfound_urls_prefix.startswith("/") or notfound_urls_prefix.endswith("/")
)
):
message = 'notfound_urls_prefix should start and end with "/" (slash)'
warnings.warn(message, UserWarning, stacklevel=2)


def setup(app):
Expand Down

0 comments on commit 64ed88f

Please sign in to comment.