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

Problem with sub-projects #171

Open
JamesRandom opened this issue Sep 1, 2021 · 2 comments
Open

Problem with sub-projects #171

JamesRandom opened this issue Sep 1, 2021 · 2 comments

Comments

@JamesRandom
Copy link

I have a problem using the extension with sub-projects on readthedocs, and versioned sub-projects in particular.

For example, it partly works with “latest”: https://docs.graphcore.ai/projects/available-memory/en/latest/xyz.html
The images and styles are present (because they are picked up from the root project).
But the navigation links don’t work (they go to the root project and hence the root 404 page, which is kinda OK but not ideal)

On version branches the images and styles are not found because there is no equivalent version in the root project (e.g. it is linking to /en/1.0.0/_static/css/theme.css)
For example: https://docs.graphcore.ai/projects/available-memory/en/1.0.0/xyz.html

So, apparently, I need to set the UL prefix correctly. I tried the following settings:

  1. Setting notfound_urls_prefix = "/" or notfound_urls_prefix = None results in exactly the same behaviour as the default setting, including for "latest" as well as versions.

  2. Always go to the parent project for resources and links

notfound_urls_prefix = "/en/latest/"

This makes the versions act like “latest”. So the page looks OK, but the links are not correct.
For example: https://docs.graphcore.ai/projects/available-memory/en/2.1.0/xyz.html

  1. Always go to the correct project and version for resources and links
notfound_urls_prefix = "/projects/available-memory/en/2.2.0/“

In this case, everything works exactly as expected. Page looks correct and the links are correct.
For example: https://docs.graphcore.ai/projects/available-memory/en/2.2.0/xyz.html

However, this means that notfound_urls_prefix needs to be set specifically for every project and version. Which is doable (I already have to customise conf.py for each document) but it would be nicer if I didn't have to.

So I wonder if there is a better way?


Versions:

  • Sphinx==3.4.3
  • sphinx_rtd_theme==0.5.1
  • docutils==0.16
  • sphinx-notfound-page
@humitos
Copy link
Member

humitos commented Sep 1, 2021

However, this means that notfound_urls_prefix needs to be set specifically for every project and version. Which is doable (I already have to customise conf.py for each document) but it would be nicer if I didn't have to.

This is definitely not great 😄 However, I'm not sure how the sphinx-notfound-page extension could help here. It needs to know the URL path where it will be served to hardcode the links and resources.

There should be a hacky way to solve this with and embed Javascript in the extension, I suppose. It could parse the full URL as {domain}/projects/{alias}/{language}/{version} (e.g. https://docs.graphcore.ai/projects/available-memory/en/2.2.0/xyz.html) and re-write all the links and resources in the DOM --but I doubt that it will always cleanly work 😃

On the other hand, I thought Read the Docs weren't supporting 404 pages on subprojects, actually. See this issue that I opened some time ago there: readthedocs/readthedocs.org#5557

I'm not sure a clean way to solve this problem currently, even if Read the Docs picks the correct 404.html for the subproject 😞 . It seems that what you have found is the best we have for now 💪🏼

@JamesRandom
Copy link
Author

Thanks I hadn't seen that issue on Read the Docs.

I can see the problem with the general case. I wonder if would be possible for the sphinx-notfound-page extension to be configured to always go to the 404 page for the root project — that would suit me (all the subproject are set up with identical 404 pages, anyway).

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