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 version switcher #827

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 11 additions & 7 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
python-version: '3.9'
- name: Set output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
run: |
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "path=en/${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: graphviz
run: sudo apt install graphviz graphviz-dev
- name: env setup
Expand All @@ -46,16 +48,18 @@ jobs:
python -m pip install hatch
- name: build docs
run: hatch -v run docs:build
- name: Deploy dev
uses: peaceiris/actions-gh-pages@v3

- uses: shallwefootball/[email protected]
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'dev') ||
(github.event_name == 'push' && (contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
name: Upload Dev Docs to S3
with:
personal_token: ${{ secrets.ACCESS_TOKEN }}
external_repository: holoviz-dev/param
publish_dir: ./builtdocs
force_orphan: true
aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_bucket: param.holoviz.org
source_dir: ./builtdocs
destination_dir: ${{ steps.vars.outputs.path }}
- name: Deploy main
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'main') ||
Expand Down
35 changes: 34 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# -*- coding: utf-8 -*-

import json
import pathlib

import param

param.parameterized.docstring_signature = False
param.parameterized.docstring_describe_params = False

from nbsite.shared_conf import * # noqa
from nbsite.shared_conf import setup as nbsite_setup

DOC_PATH = pathlib.Path(__file__).parent

project = 'param'
authors = 'HoloViz developers'
Expand Down Expand Up @@ -44,11 +50,17 @@
"icon": "fa-brands fa-discord",
},
],
"navbar_start": ["navbar-logo", "version-switcher"],
"footer_start": [
"copyright",
"last-updated",
],
"analytics": {"google_analytics_id": 'G-KD5GGLCB54'}
"analytics": {"google_analytics_id": 'G-KD5GGLCB54'},
"switcher": {
"json_url": "http://param.holoviz.org.s3-website-us-east-1.amazonaws.com/en/latest/_static/switcher.json",
"version_match": version
}

}

extensions += [ # noqa
Expand All @@ -67,3 +79,24 @@
myst_heading_anchors = 3

napoleon_numpy_docstring = True

def add_version(app):
with open(DOC_PATH / 'switcher.json', 'r') as f:
versions = json.load(f)
found = False
for v in versions:
if version == v.get('version'):
found = True
if not found:
versions.insert(1, {
'name': 'Version {version[1:]}',
'version': version,
'url': "http://param.holoviz.org.s3-website-us-east-1.amazonaws.com/en/{version}/"
})

with open(DOC_PATH / '_static' / 'switcher.json', 'w') as f:
json.dump(versions, f)

def setup(app):
nbsite_setup(app)
app.connect('builder-inited', add_version)
11 changes: 11 additions & 0 deletions doc/switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name": "latest",
"url": "https://param.holoviz.org/en/latest/"
},
{
"name": "Version 2.0.0 RC2",
"version": "v2.0.0rc2",
"url": "https://param.holoviz.org/en/2.0.0rc2/"
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this file manually written, or will it be auto-updated over time?

Copy link
Member Author

Choose a reason for hiding this comment

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

Something will have to commit an update to the file. Will see what bokeh does.

]
Loading