readthedocs / sphinx-notfound-page

Create a custom 404 page with absolute URLs hardcoded
https://sphinx-notfound-page.readthedocs.io/
MIT License
48 stars 32 forks source link

Broken on Sphinx 7.2.0 #219

Closed hynek closed 12 months ago

hynek commented 1 year ago
docs: commands[0]> sphinx-build -n -T -W -b html -d /Users/hynek/FOSS/svcs/.tox/docs/tmp/doctrees docs docs/_build/html
Running Sphinx v7.2.0

Traceback (most recent call last):
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/application.py", line 232, in __init__
    self.setup_extension(extension)
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/application.py", line 405, in setup_extension
    self.registry.load_extension(self, extname)
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/registry.py", line 460, in load_extension
    metadata = setup(app)
               ^^^^^^^^^^
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/notfound/extension.py", line 337, in setup
    from sphinx.builders.html import setup_js_tag_helper
ImportError: cannot import name 'setup_js_tag_helper' from 'sphinx.builders.html' (/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/builders/html/__init__.py)

Exception occurred:
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/notfound/extension.py", line 337, in setup
    from sphinx.builders.html import setup_js_tag_helper
ImportError: cannot import name 'setup_js_tag_helper' from 'sphinx.builders.html' (/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/builders/html/__init__.py)
The full traceback has been saved in /var/folders/8c/ffnfsd7s3y151ptr05s8v3tw0000gn/T/sphinx-err-_fb_typ5.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Full traceback referenced in log:

# Platform:         darwin; (macOS-13.5-arm64-arm-64bit)
# Sphinx version:   7.2.0
# Python version:   3.11.4 (CPython)
# Docutils version: 0.20.1
# Jinja2 version:   3.1.2
# Pygments version: 2.16.1

# Last messages:

# Loaded extensions:

# Traceback:
Traceback (most recent call last):
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/application.py", line 232, in __init__
    self.setup_extension(extension)
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/application.py", line 405, in setup_extension
    self.registry.load_extension(self, extname)
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphinx/registry.py", line 460, in load_extension
    metadata = setup(app)
               ^^^^^^^^^^
  File "/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/notfound/extension.py", line 337, in setup
    from sphinx.builders.html import setup_js_tag_helper
ImportError: cannot import name 'setup_js_tag_helper' from 'sphinx.builders.html' (/Users/hynek/FOSS/svcs/.tox/docs/lib/python3.11/site-packages/sphi
nx/builders/html/__init__.py)
humitos commented 1 year ago

The helper was removed in Sphinx 7.2.0 at https://github.com/sphinx-doc/sphinx/commit/4b082f7db. We will need to use the new API for CSS and JS here. See https://github.com/sphinx-doc/sphinx/issues/11608

humitos commented 12 months ago

I released https://pypi.org/project/sphinx-notfound-page/1.0.0rc1/, please give it a try and let me know if it works fine for your use case.

hugovk commented 12 months ago

Works locally with https://github.com/python/devguide/pull/1155 with requirements.txt:

-sphinx-notfound-page
+sphinx-notfound-page==1.0.0rc1

Thanks!

ru-fu commented 12 months ago

Works fine here as well - thanks for the quick fix!

humitos commented 12 months ago

I plan to wait a couple of days before releasing the final 1.0.0 -- I think I will do it next Wednesday.

return42 commented 12 months ago

Not sure if it is related, but I got an error::

Theme error:
An error happened in rendering the page 404.
Reason: ValueError("invalid literal for int() with base 10: ''")

.. I'm still in analysis

return42 commented 12 months ago

FWI: in the theme.conf I had to set globaltoc_maxdepth to an integer ..

[options]
globaltoc_maxdepth = 5

it seems the default is an empty string ...

  File "site-packages/sphinx/themes/basic/../basic/layout.html", line 60, in template
    {%- include sidebartemplate %}
  File "site-packages/sphinx/themes/basic/globaltoc.html", line 11, in top-level template code
    {{ toctree(includehidden=theme_globaltoc_includehidden, collapse=theme_globaltoc_collapse, maxdepth=theme_globaltoc_maxdepth) }}
  File "site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
  File "site-packages/notfound/extension.py", line 128, in toctree
    toc = global_toctree_for_doc(
  File "sphinx/environment/adapters/toctree.py", line 86, in global_toctree_for_doc
    maxdepth=int(maxdepth),
ValueError: invalid literal for int() with base 10: ''

There was a similar issue in the past:

I assume the issue has been back by:

humitos commented 12 months ago

@return42 I opened #221 to track the issue you are reporting more in deep.

humitos commented 11 months ago

I released v1.0.0. I hope it works for everybody ๐Ÿ™๐Ÿผ

hynek commented 11 months ago

Can confirm โ€“ thanks for fixing!

return42 commented 11 months ago

Works :+1: .. thanks a lot for fixing! Not sure, may you also want to close ...?


Related:

humitos commented 11 months ago

Not sure, may you also want to close ...?

I think we can close it because I understand it's an upstream issue, yeah ๐Ÿ‘๐Ÿผ