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

Use PyData Sphinx theme version switcher #46936

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions doc/source/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,14 @@ table.autosummary tr > td:first-child > p > a > code > span {
color: var(--pst-color-light);
text-decoration: underline;
}

/* Prevent the the PyData theme Version Switcher from getting too large */
.version-switcher__menu {
max-height: 496px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to use a relative unit here so it scales with the user's font size.

overflow: scroll;
}

/* Hide the RTD version switcher since we are using PyData theme one */
#rtd-footer-container {
display: none;
}
5 changes: 5 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def render_svg_logo(path):
},
"navbar_start": ["navbar-ray-logo"],
"navbar_end": [
"version-switcher",
"navbar-icon-links",
"navbar-anyscale",
],
Expand All @@ -313,6 +314,10 @@ def render_svg_logo(path):
"navigation_depth": 4,
"pygment_light_style": "stata-dark",
"pygment_dark_style": "stata-dark",
"switcher": {
"json_url": "https://docs.ray.io/en/master/_static/versions.json",
"version_match": os.getenv("READTHEDOCS_VERSION", "master"),
},
}

html_context = {
Expand Down
7 changes: 4 additions & 3 deletions doc/source/custom_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ def pregenerate_example_rsts(
repo_url = "https://github.com/ray-project/ray.git"
static_dir_name = "_static"
version_json_filename = "versions.json"
dereference_suffix = "^{}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed this change before - do we need these to be defined at the module level and not in the function that uses them? We really don't want to pollute the module namespace if we can avoid it, and as far as I can tell these are only being used in generate_versions_json.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will raise a follow up PR to address this since this one got merged. Thanks!



def generate_version_url(version):
Expand All @@ -1286,11 +1287,11 @@ def generate_versions_json():
"utf-8"
)
# Extract release versions from tags
tags = re.findall(r"refs/tags/(.+?)(?:\^|\s|$)", output)
tags = re.findall(r"refs/tags/(.+)", output)
for tag in tags:
if ray_prefix in tag:
if ray_prefix in tag and dereference_suffix not in tag:
version = tag.split(ray_prefix)[1]
if Version(version) >= Version(min_version):
if version not in git_versions and Version(version) >= Version(min_version):
git_versions.append(version)
git_versions.sort(key=Version, reverse=True)

Expand Down
Loading