Skip to content

Issue with pydata-sphinx-theme and an empty toctree #253

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

Open
sarina opened this issue Mar 6, 2025 · 1 comment
Open

Issue with pydata-sphinx-theme and an empty toctree #253

sarina opened this issue Mar 6, 2025 · 1 comment

Comments

@sarina
Copy link

sarina commented Mar 6, 2025

Hi,

I found a weird bug where adding this extension to a single page app (index.rst without a toctree), pydata-sphinx-theme threw an error. To work around this, I added dummy.rst files to each app in a hidden toctree, which seems silly but did work.

I believe the problem comes from this code: https://github.com/readthedocs/sphinx-notfound-page/blob/main/notfound/extension.py#L147-L148 - we return None if there's no toctree here, but when pydata-sphinx-theme tries to consume this, it fails on https://github.com/pydata/pydata-sphinx-theme/blob/fc54589ae964055ea32a9d407fcc812cd77887a8/src/pydata_sphinx_theme/toctree.py#L367 because we've passed it a None object.

I don't know the best way to fix this - should I PR to pydata-sphinx-theme to throw a reasonable error there if they get a None object? Should we do something in this extension? Any advice is great, I'm happy to make a PR to fix.

Ref: openedx-unsupported/edx-documentation#2332

@humitos
Copy link
Member

humitos commented Mar 17, 2025

I suppose it should return an empty string ("") when there is no toctree based on the types from the original function: https://github.com/sphinx-doc/sphinx/blob/v7.2.3/sphinx/builders/html/__init__.py#L941 and https://github.com/sphinx-doc/sphinx/blob/v7.2.3/sphinx/builders/html/__init__.py#L426 and https://github.com/sphinx-doc/sphinx/blob/v7.2.3/sphinx/builders/html/__init__.py#L947

Could you try that and check if it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants