Open greyli opened 3 years ago
Hi! Thanks for opening this issue.
I took a quick look at this and it seems that for some reason builder
variable at the line you linked is a Sphinx sphinx.application.Sphinx
instead of a Sphinx HTML builder (e.g. sphinx.builders.html.StandaloneHTMLBuilder
).
I don't know too much about how the theme works, but I'd say that this line https://github.com/pallets/pallets-sphinx-themes/blob/master/src/pallets_sphinx_themes/versions.py#L132 is not returning what we are expecting (an Sphinx HTML builder)
We are overriding the pathto
function for the context at https://github.com/readthedocs/sphinx-notfound-page/blob/master/notfound/extension.py#L148 so that may be the reason.
Could you explain a little more what pathto.__closure__[0].cell_contents
does?
@greyli friendly ping :)
Could you explain a little more what pathto.closure[0].cell_contents does?
I'm not familiar with the Sphinx theme either...
Hey @davidism, could you explain what this line does?
It's been a long time since I looked at this code.
That function is called in the Jinja page template to generate a URL to a different version of the docs. It's a bit hazy, but I recall having to be fairly careful about how I generated the URL to account for different Sphinx configurations.
In order to generate a URL, I need to call the get_target_uri
method on the Sphinx builder
object, but neither of those are available in the Jinja render context. However, the pathto
function, which is defined as an inner function of the buider.handle_page
method, is available. Since pathto
references self
, I can look at the function closure to get that reference to self
again, which is the builder
object.
It's entirely possible I missed something while writing this code the first time. These Sphinx objects, and the way they're called and interact, is essentially undocumented, so I spent quite a lot of time just stepping through with a debugger and finding things that would generate the values I needed. If there had been a way to get a reference to the builder at a different time, I would hopefully have used that, but one way or another I couldn't find that while writing the code.
Hey, I've just encountered this error again on my end, see https://app.readthedocs.org/projects/flask-utils/builds/24649777
Are you still able to reproduce this issue? If so, can you try rebuilding your docs without using this extension? Do you have the same issue? I'm asking because I still don't see this issue related to this extension in particular 🤷🏼
Hi, I tried to add sphinx-notfound-page (Version 0.6 or master) for Flask (with Pallets Sphinx Themes).
with the following conf:
then the build failed:
Full build log: https://readthedocs.org/projects/flaskx/builds/13534094/
The error related to this line in Pallets Sphinx Theme. I'm not quite sure if it's an issue of sphinx-notfound-page since I'm not very familiar with Sphinx, any thoughts will be helpful. Thanks!
Related issue: https://github.com/pallets/pallets-sphinx-themes/issues/34