Skip to content

Commit

Permalink
docs(python): Add version switcher to API reference (#10488)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored Aug 15, 2023
1 parent 0357177 commit c40976b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
working-directory: py-polars/docs
env:
SPHINXOPTS: -W --jobs=auto
POLARS_VERSION: ${{ github.ref_name }}
run: make html

- name: Deploy Python docs for latest development version
Expand Down
5 changes: 3 additions & 2 deletions py-polars/docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* To have blue background of width of the block (instead of width of content) */
dl.class > dt:first-of-type {
dl.class>dt:first-of-type {
display: block !important;
}

Expand Down Expand Up @@ -28,7 +28,7 @@ div.bd-sidebar-primary {
background-image: linear-gradient(90deg, var(--pst-gradient-sidebar-left) 0%, var(--pst-gradient-sidebar-right) 100%);
}

footer.bd-footer{
footer.bd-footer {
background-color: var(--pst-color-on-background);
}

Expand All @@ -39,6 +39,7 @@ footer.bd-footer{
div.bd-sidebar-secondary {
display: none;
}

label.sidebar-toggle.secondary-toggle {
display: none !important;
}
12 changes: 12 additions & 0 deletions py-polars/docs/source/_static/version_switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"name": "dev",
"version": "dev",
"url": "https://pola-rs.github.io/polars/py-polars/dev/"
},
{
"name": "0.18 (stable)",
"version": "0.18",
"url": "https://pola-rs.github.io/polars/py-polars/html/"
}
]
12 changes: 11 additions & 1 deletion py-polars/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
github_root = "https://github.com/pola-rs/polars"
web_root = "https://pola-rs.github.io"

# Specify version for version switcher dropdown menu
switcher_version_env = os.environ.get("POLARS_VERSION", "main")
version_match = re.fullmatch(r"py-(\d+\.\d+)\.\d+.*", switcher_version_env)
switcher_version = version_match.group(1) if version_match is not None else "dev"

html_theme_options = {
"external_links": [
{
Expand Down Expand Up @@ -124,8 +129,13 @@
"logo": {
"image_light": f"{static_assets_root}/logos/polars-logo-dark-medium.png",
"image_dark": f"{static_assets_root}/logos/polars-logo-dimmed-medium.png",
"link": f"{web_root}/polars/py-polars/html/reference/index.html",
},
"switcher": {
"json_url": f"{web_root}/polars/py-polars/dev/_static/version_switcher.json",
"version_match": switcher_version,
},
"navbar_end": ["version-switcher", "navbar-icon-links"],
"check_switcher": False,
}

# sphinx-favicon - Add support for custom favicons
Expand Down

0 comments on commit c40976b

Please sign in to comment.