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

Configure versions.json and remove the version switcher dropdown #3108

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,9 @@ results/
!docs/source/examples/notebooks/models/spm1.png
!docs/source/examples/notebooks/models/spm2.png

# do not ignore images in _static folder in docs
!docs/_static/favicon/favicon.png
!docs/_static/pybamm_logo.png

# tests
test_callback.log
14 changes: 8 additions & 6 deletions docs/source/_static/pybamm.css → docs/_static/pybamm.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ h3 {

- latest: orange
- stable: green
- old, PR: red
- old: red

For PRs, we use the "latest" label.

Colors from:

Expand All @@ -49,22 +51,22 @@ Nat Methods 8, 441 (2011). https://doi.org/10.1038/nmeth.1618
*/

/* If the active version has the name "latest", style it orange */
.version-switcher__button[data-active-version-name*="latest"] {
.version-switcher__container a[data-version-name*="latest"] {
background-color: #e69f00;
border-color: #e69f00;
color: #000000;
}

/* green for `stable` */
.version-switcher__button[data-active-version-name*="stable"] {
.version-switcher__container a[data-version-name*="stable"] {
background-color: #009e73;
border-color: #009e73;
}

/* red for `old` */
.version-switcher__button:not(
[data-active-version-name*="latest"],
[data-active-version-name*="stable"]
.version-switcher__container a:not(
[data-version-name*="latest"],
[data-version-name*="stable"]
) {
background-color: #980f0f;
border-color: #980f0f;
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
29 changes: 24 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@

html_theme = "pydata_sphinx_theme"

html_static_path = ["source/_static"]
html_static_path = ["_static"]

# Theme

# pydata theme options (see
# https://pydata-sphinx-theme.readthedocs.io/en/latest/index.html# for more information)
# mostly copied from numpy, scipy, pandas
html_logo = "source/_static/pybamm_logo.png"
html_favicon = "source/_static/favicon/favicon.png"
html_logo = "_static/pybamm_logo.png"
html_favicon = "_static/favicon/favicon.png"

html_theme_options = {
"logo": {
Expand Down Expand Up @@ -148,8 +148,8 @@
},
],
"switcher": {
"version_match": release,
"json_url": "https://pybamm.readthedocs.io/en/latest/_static/versions.json", # noqa: E501
"version_match": version,
"json_url": "https://docs.pybamm.org/en/latest/_static/versions.json",
},
# turn to False to not fail build if json_url is not found
"check_switcher": True,
Expand All @@ -168,6 +168,25 @@
],
}

# Version swticher configuration

# Check if building on readthedocs
version_match = os.environ.get("READTHEDOCS_VERSION")
# Check the version type on readthedocs
version_type = os.environ.get("READTHEDOCS_VERSION_TYPE")

# We want to use the local versions.json if building locally and on PRs (in which case
# the version type is "external"), and we set the versions accordingly

if version_match is None or version_type == "external":
# Use local versions.json if not building on readthedocs
# or if building on readthedocs but on PRs
html_theme_options["switcher"]["json_url"] = "_static/versions.json"

if version_type == "external":
# Set the version to latest on readthedocs PRs
html_theme_options["switcher"]["version_match"] = "latest"
Copy link

@OriolAbril OriolAbril Jul 19, 2023

Choose a reason for hiding this comment

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

This will only set the html_theme_options["switcher"]["version_match"], it won't work for stable nor latest. Currently, they'll get version = pybamm.__version__ (defined in line 33) which is not the version you want to have matched to them IUUC. In addition to these checks to cover local and PR builds, I think you should also have specific checks for stable and latest. You can use the version_match = os.environ.get("READTHEDOCS_VERSION") variable which you have defined a few lines higher. According to rtd docs it will take exactly the values latest/stable for their builds.

They do have independent builds and they appear on the versions.json file, so their builds should have the right value of the version match. Otherwise, users will click on latest and go to .../en/latest/... docs, but the "folded" version switcher won't show latest while browsing the docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review! As noted previously in our conversation—you mentioned that the version switcher is still not going to work for previous documentation releases, so we are deciding to remove the dropdown altogether in order to rely on the server-side readthedocs one. That is, unless there exists a workaround for not having to deal with patch releases with the latest versions.json set?


html_title = "%s v%s Manual" % (project, version)
html_last_updated_fmt = "%Y-%m-%d"
html_css_files = ["pybamm.css"]
Expand Down
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ explore the effect of different battery designs and modeling assumptions under a
.. grid:: 2

.. grid-item-card::
:img-top: source/_static/index-images/getting_started.svg
:img-top: _static/index-images/getting_started.svg

User Guide
^^^^^^^^^^
Expand All @@ -59,7 +59,7 @@ explore the effect of different battery designs and modeling assumptions under a
To the user guide

.. grid-item-card::
:img-top: source/_static/index-images/examples.svg
:img-top: _static/index-images/examples.svg

Examples
^^^^^^^^
Expand All @@ -77,7 +77,7 @@ explore the effect of different battery designs and modeling assumptions under a
To the examples

.. grid-item-card::
:img-top: source/_static/index-images/api.svg
:img-top: _static/index-images/api.svg

API Documentation
^^^^^^^^^^^^^^^^^
Expand All @@ -96,7 +96,7 @@ explore the effect of different battery designs and modeling assumptions under a
To the API documentation

.. grid-item-card::
:img-top: source/_static/index-images/contributor.svg
:img-top: _static/index-images/contributor.svg

Contributor's Guide
^^^^^^^^^^^^^^^^^^^
Expand Down