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

Add the Sphinx notfound page extension #15669

Merged
merged 5 commits into from
Dec 3, 2024

Conversation

oraNod
Copy link
Collaborator

@oraNod oraNod commented Nov 26, 2024

SUMMARY

Add https://sphinx-notfound-page.readthedocs.io/en/latest/installation.html

This is an attempt to fix the 404 page issues on read the docs.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Docs
AWX VERSION

n/a

ADDITIONAL INFORMATION

follows up on #15668

@oraNod
Copy link
Collaborator Author

oraNod commented Nov 26, 2024

I've added this to a project from my fork: https://oranod-awx.readthedocs.io/en/latest/

You can request a fake page name like foo.html and see the 404 page is there. The cowsay image is apparently getting picked up by the extension but the theme isn't applied.

Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

Comparing https://oranod-awx.readthedocs.io/en/latest/ and https://oranod-awx.readthedocs.io/en/latest/foo.html:

- <title>Ansible AWX Documentation &mdash; Ansible AWX community documentation</title>
+ <title>Oh no! &mdash; Ansible AWX community documentation</title>
-       <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+       <link rel="stylesheet" href="/en/latest/_CascadingStyleSheet('_static/pygments.css', priority=200, rel='stylesheet', type='text/css')" type="text/css" />
-       <link rel="stylesheet" href="_static/css/ansible.css" type="text/css" />
+       <link rel="stylesheet" href="/en/latest/_CascadingStyleSheet('_static/css/ansible.css', priority=200, rel='stylesheet', type='text/css')" type="text/css" />
-       <link rel="stylesheet" href="_static/css/rtd-ethical-ads.css" type="text/css" />
+       <link rel="stylesheet" href="/en/latest/_CascadingStyleSheet('_static/css/rtd-ethical-ads.css', priority=500, rel='stylesheet', type='text/css')" type="text/css" />
-     <link rel="shortcut icon" href="_static/images/Ansible-Mark-RGB_Black.png"/>
+     <link rel="shortcut icon" href="/en/latest/_static/images/Ansible-Mark-RGB_Black.png"/>
    <!--[if lt IE 9]>
-     <script src="_static/js/html5shiv.min.js"></script>
+     <script src="/en/latest/_static/js/html5shiv.min.js"></script>
    <![endif]-->
  
-         <script src="_static/jquery.js?v=5d32c60e"></script>
+         <script src="/en/latest/_static/jquery.js?v=5d32c60e"></script>
-         <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
+         <script src="/en/latest/_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
-         <script src="_static/documentation_options.js?v=a9b6e813"></script>
+         <script src="/en/latest/_static/documentation_options.js?v=a9b6e813"></script>
-         <script src="_static/doctools.js?v=888ff710"></script>
+         <script src="/en/latest/_static/doctools.js?v=888ff710"></script>
-         <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
+         <script src="/en/latest/_static/sphinx_highlight.js?v=dc90522c"></script>
-     <script src="_static/js/theme.js"></script>
+     <script src="/en/latest/_static/js/theme.js"></script>

I'm not sure why _CascadingStyleSheet() is leaking into the rendered HTML output. I think I saw this before, but never looked deep. The theme demo seems to be fine: https://sphinx-ansible-theme.readthedocs.io/en/latest/foo.html.

I think there's some incompatibility between versions of CPython, Sphinx and the underlying sphinx-rtd-theme. Somebody will probably have to bisect it.

readthedocs/sphinx-notfound-page#224 mentions the same problem and ansible/ansible-documentation#678 links ansible/ansible-documentation@9d4c6db that suggests that changing what settings are used might be the fix: https://github.com/ansible/ansible-documentation/pull/827/files#diff-de16707d76a94c258b2d4ba2b8f95910db018b923e2b4834dacf47c8964b2a90R340.

docs/docsite/requirements.txt Outdated Show resolved Hide resolved
@oraNod oraNod force-pushed the notfound-page-ext branch from 49b22be to 2197c4e Compare December 2, 2024 17:24
@oraNod oraNod requested a review from webknjaz December 2, 2024 17:24
@oraNod oraNod force-pushed the notfound-page-ext branch from 2197c4e to ef4279b Compare December 2, 2024 17:25
Copy link

sonarqubecloud bot commented Dec 2, 2024

@oraNod
Copy link
Collaborator Author

oraNod commented Dec 2, 2024

Thanks for taking a look @webknjaz I completely forgot that the Ansible docs had a similar problem. I wasn't really involved in that one though so I guess it didn't stick.

I'm not sure I'll be the best at explaining why but upgrading the requirements seems to have worked. The 404 page is doing it's thing on my fork and I don't see that issue with _CascadingStyleSheet() leaking through. From what I can tell the upgrade didn't break anything - I was concerned about the API guide but that looks OK to me. Maybe when that starts getting updated we'll need to take another look.

The 404 page doesn't look right in the PR preview but I suspect that is down to the settings I added to conf.py. Anyway, you can see it in action from my fork here: https://oranod-awx.readthedocs.io/en/latest/404.html

Or this non-existent page: https://oranod-awx.readthedocs.io/en/latest/foo.html

Copy link
Member

@tvo318 tvo318 left a comment

Choose a reason for hiding this comment

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

I trust the previews are accurate. Thanks for getting this done so quickly, @oraNod!

@samccann
Copy link
Contributor

samccann commented Dec 2, 2024

My brain is still on PTO but I looked at https://ansible--15669.org.readthedocs.build/projects/awx/en/15669/foo.html and it has the same formatting problem.

@oraNod
Copy link
Collaborator Author

oraNod commented Dec 2, 2024

My brain is still on PTO but I looked at https://ansible--15669.org.readthedocs.build/projects/awx/en/15669/foo.html and it has the same formatting problem.

Thanks @samccann I think this is down to the settings in conf.py that specify the path to the 404 page, which I guess doesn't exist in the preview environment. I could be wrong but it works in my fork where it did not before.

@oraNod oraNod mentioned this pull request Dec 3, 2024
11 tasks
Copy link
Contributor

@gundalow gundalow left a comment

Choose a reason for hiding this comment

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

CI errors (API Check) aren't related to this change

@gundalow gundalow merged commit cdb294c into ansible:devel Dec 3, 2024
25 of 26 checks passed
@samccann
Copy link
Contributor

samccann commented Dec 3, 2024

Why are 404pages so hard lol. So it has the correct formatting, but there is no versin flyout menu on the lower right on the custom 404 page. Rather than bang against this even more, I recommend we just change the wording to remove mention of that. The page already has a direct link to the 24.6.1 version of the docs.

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

Successfully merging this pull request may close these issues.

5 participants