Skip to content

DOC [PST] version switcher and warning banner #28347

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

Merged

Conversation

Charlie-XIAO
Copy link
Contributor

@Charlie-XIAO Charlie-XIAO commented Feb 2, 2024

Please note that this PR targets the new_web_theme branch!

Towards #28084. This main task of this PR is to configure the version switcher and the version warning banner.

Here is the list of things left to be done in this PR (if any). Maintainers please feel free to modify.

  • Placeholder.

@Charlie-XIAO Charlie-XIAO changed the title DOC switch to pydata-sphinx-theme [4>1] version switcher and warning … DOC switch to pydata-sphinx-theme [4>1] version switcher and warning banner Feb 2, 2024
Copy link

github-actions bot commented Feb 2, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: b2a91b6. Link to the linter CI: here

@Charlie-XIAO
Copy link
Contributor Author

Charlie-XIAO commented Feb 2, 2024

Part I: Generate the version switcher JSON

You may want to look at this documentation first. In short, the changes under build_tools/circle/ are to extend the original script that generates the "All versions and download" page to also generate the version switcher JSON required by pydata-sphinx-theme. The generated JSON is saved at doc/versions.json and in conf.py this file is added to html_extra_path. It will then be pushed to https://scikit-learn.org/{ver}/versions.json. For now I'm using the JSON generated by the script, hosted under my website, so that maintainers can check how things work.

Part II: Tweak the version switcher (optional)

I think it might be nice to move the "Other versions and download" button in the navbar dropdown button into the version switcher, so that all version-related stuff are in the same place. My current approach is a bit of... hacky? Since the version switcher is itself populated by JS at load time, if we want to add another tab to the version switcher dropdown we need to use JS as well. More importantly to ensure the added tab is the last one we need to wait until the pydata-sphinx-theme script finishes. I've got no idea what the standard way is: my current approach is to add a listener to the dropdown button, hoping that no one clicks that button faster than JS executes 🤣. The JS is not too complex, but if maintainers think this is not desired I can revert to use the current "Other versions and download".

@Charlie-XIAO Charlie-XIAO changed the title DOC switch to pydata-sphinx-theme [4>1] version switcher and warning banner DOC [PST] version switcher and warning banner Feb 7, 2024
@Charlie-XIAO Charlie-XIAO marked this pull request as ready for review February 10, 2024 18:16
Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Nice!

@adrinjalali adrinjalali added the Waiting for Second Reviewer First reviewer is done, need a second one! label Feb 13, 2024
@ogrisel
Copy link
Member

ogrisel commented Mar 11, 2024

The banner looks good on the landing page:

image

or on the Examples index page:

image

however it's missing when navigating to a particular example of the gallery:

image

I also checked navigating to subpages of the narrative and API docs and the banner is there is both case. On the example pages have a missing banner.

@Charlie-XIAO
Copy link
Contributor Author

Charlie-XIAO commented Mar 11, 2024

Perhaps you haven't scrolled to the top (the breadcrumbs are not showing up)? If you navigate from the gallery index page to gallery example pages it jumps to the anchor on the header so the page is not automatically at the top; the banner only shows up when you scroll to the top (this is the pydata-sphinx-theme behavior).

image

@ogrisel
Copy link
Member

ogrisel commented Mar 11, 2024

Perhaps you haven't scrolled to the top (the breadcrumbs are not showing up)? If you navigate from the gallery index page to gallery example pages it jumps to the anchor on the header so the page is not automatically at the top; the banner only shows up when you scroll to the top (this is the pydata-sphinx-theme behavior).

Indeed you are right. Please ignore my comment then. I suppose this is good the way it is.

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM. Please feel free to do update the json URL to https://scikit-learn.org/_pst_preview/versions.json and merge this PR.

@Charlie-XIAO Charlie-XIAO merged commit 05eb574 into scikit-learn:new_web_theme Mar 12, 2024
@Charlie-XIAO Charlie-XIAO deleted the pydata-4_1-ver-switch branch March 12, 2024 01:50
@Charlie-XIAO
Copy link
Contributor Author

If the URL causes any issue I'll fix in a follow-up PR. Thanks @ogrisel!

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

Successfully merging this pull request may close these issues.

3 participants