diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 50ba1e391..d283d14f5 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -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 @@ -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/s3-upload-action@v1.3.3 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') || diff --git a/doc/conf.py b/doc/conf.py index 7a27b00b2..292626f07 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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' @@ -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 @@ -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) diff --git a/doc/switcher.json b/doc/switcher.json new file mode 100644 index 000000000..8a15973af --- /dev/null +++ b/doc/switcher.json @@ -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/" + } +]