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

`globaltoc_maxdepth` fails on its default value #221

Closed humitos closed 11 months ago

humitos 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:

Originally posted by @return42 in https://github.com/readthedocs/sphinx-notfound-page/issues/219#issuecomment-1694691135

humitos commented 12 months ago

@return42 do you have a minimal reproducible example I can test? At first sight it doesn't seem a problem with the extension itself but on Sphinx or the theme, I'd say.

humitos commented 12 months ago

I reported a similar issue with includehidden= at https://github.com/sphinx-doc/sphinx/issues/11607 and it seems the regression was introduced in the same commit.

return42 commented 12 months ago

minimal reproducible example I can test?

Sorry, I don't have one at hand / we use the pallets-sphinx-themes

At first sight it doesn't seem a problem with the extension itself but on Sphinx or the theme, I'd say.

AFAIK its a sphinx error .. the default of globaltoc_maxdepth is an empty string if unset in the theme .. and then Sphinx raises an error:

File "sphinx/environment/adapters/toctree.py", line 86, in global_toctree_for_doc
    maxdepth=int(maxdepth),
ValueError: invalid literal for int() with base 10: ''
humitos commented 11 months ago

Thanks for you help debugging this. I'm closing this issue since it's an upstream issue.

AA-Turner commented 11 months ago

@return42 please test with Sphinx 7.2.5; if the issue persists please open a new Sphinx issue.

A

return42 commented 11 months ago

@AA-Turner I can confirm issue does no longer exists in Sphinx 7.2.5 .. thanks a lot for having an eye on :+1: