Skip to content
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

Fix TocTree manipulation on Sphinx 7.2+ #1406

Merged
merged 5 commits into from
Aug 14, 2023

Conversation

AA-Turner
Copy link
Contributor

See #1404

This is the bare minimum required to restore the previous state. I intend to look into how pydata-sphinx-theme uses get_toctree_ancestors and if there are any longer-term improvements to be made.

A

from bs4 import BeautifulSoup
from docutils import nodes
from docutils.nodes import Node
from sphinx import addnodes
from sphinx.addnodes import toctree as toctree_node
from sphinx.application import Sphinx
from sphinx.environment.adapters.toctree import TocTree
from sphinx.environment.adapters.toctree import _get_toctree_ancestors, TocTree
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to version-guard this import too:

Running Sphinx v5.3.0

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1406/lib/python3.9/site-packages/sphinx/config.py", line 350, in eval_config_file
    exec(code, namespace)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/checkouts/1406/docs/conf.py", line 14, in <module>
    import pydata_sphinx_theme
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1406/lib/python3.9/site-packages/pydata_sphinx_theme/__init__.py", line 15, in <module>
    from . import edit_this_page, logo, pygment, short_link, toctree, translator, utils
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1406/lib/python3.9/site-packages/pydata_sphinx_theme/toctree.py", line 14, in <module>
    from sphinx.environment.adapters.toctree import _get_toctree_ancestors, TocTree
ImportError: cannot import name '_get_toctree_ancestors' from 'sphinx.environment.adapters.toctree' (/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1406/lib/python3.9/site-packages/sphinx/environment/adapters/toctree.py)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, of course!

@drammock drammock merged commit a3f0892 into pydata:main Aug 14, 2023
13 of 15 checks passed
@drammock
Copy link
Collaborator

thanks @AA-Turner

@AA-Turner
Copy link
Contributor Author

Thank you!

To make you aware, Sphinx 7.2 is planned for release this week, so users of pydata-sphinx-theme will need to use a version with this fix included.

A

@drammock
Copy link
Collaborator

thanks for the heads-up. We're overdue for a release anyway so I'll try to wrap up our remaining blockers ASAP

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

Successfully merging this pull request may close these issues.

None yet

2 participants