From 0fa2e416b79a6026bc3c129e968542b60a46ff7c Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 18:58:40 +0200 Subject: [PATCH 1/9] Add version switcher --- .github/workflows/docs.yaml | 14 +++++++------- doc/conf.py | 31 ++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 50ba1e391..63266eb62 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -46,16 +46,16 @@ jobs: python -m pip install hatch - name: build docs run: hatch -v run docs:build - - name: Deploy dev - uses: peaceiris/actions-gh-pages@v3 + - name: upload dev 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'))) - with: - personal_token: ${{ secrets.ACCESS_TOKEN }} - external_repository: holoviz-dev/param - publish_dir: ./builtdocs - force_orphan: true + env: + TAG_VAR: ${{ steps.vars.outputs.tag }} + run: | + pipx install awscli + aws s3 sync --quiet ./builtdocs s3://param.holoviz.org/en/latest + aws s3 sync --quiet ./builtdocs s3://param.holoviz.org/en/$TAG_VAR - 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..29bf2078c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,11 +1,14 @@ # -*- coding: utf-8 -*- +import json + import param param.parameterized.docstring_signature = False param.parameterized.docstring_describe_params = False from nbsite.shared_conf import * # noqa +from nbsite.shared_conf import nbsite_setup project = 'param' authors = 'HoloViz developers' @@ -44,11 +47,16 @@ "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", + } + } extensions += [ # noqa @@ -67,3 +75,24 @@ myst_heading_anchors = 3 napoleon_numpy_docstring = True + +def add_version(): + with open('./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('./_static/switcher.json', 'w') as f: + json.dump(versions, f) + +def setup(app): + nbsite_setup(app) + app.connect('builder-inited', add_version) From 6674e8f2bbf968f0915059f5268303f295cebb37 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:01:48 +0200 Subject: [PATCH 2/9] Small fixes --- .github/workflows/docs.yaml | 4 ++++ doc/conf.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 63266eb62..be93c4606 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -25,6 +25,10 @@ jobs: name: Documentation runs-on: 'ubuntu-latest' timeout-minutes: 120 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} defaults: run: shell: bash -l {0} diff --git a/doc/conf.py b/doc/conf.py index 29bf2078c..050568380 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -8,7 +8,7 @@ param.parameterized.docstring_describe_params = False from nbsite.shared_conf import * # noqa -from nbsite.shared_conf import nbsite_setup +from nbsite.shared_conf import setup as nbsite_setup project = 'param' authors = 'HoloViz developers' From 1153cfdbcfea6f0ecf0c54b6c84fe92de23bd968 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:04:29 +0200 Subject: [PATCH 3/9] Ensure add_version does not error out --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 050568380..3cf5c7ac2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -76,7 +76,7 @@ napoleon_numpy_docstring = True -def add_version(): +def add_version(app): with open('./switcher.json', 'r') as f: versions = json.load(f) found = False From 30ce664b4e6f48ddc69d5ce451c8ef41c419c8eb Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:07:41 +0200 Subject: [PATCH 4/9] Add switcher.json --- doc/switcher.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 doc/switcher.json 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/" + } +] From 679563d246cd9b413721fb18943b024fa8a3b6e1 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:09:28 +0200 Subject: [PATCH 5/9] Fix paths --- doc/conf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 3cf5c7ac2..6b40c255f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import json +import pathlib import param @@ -10,6 +11,8 @@ 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' copyright_years['start_year'] = '2003' # noqa @@ -77,7 +80,7 @@ napoleon_numpy_docstring = True def add_version(app): - with open('./switcher.json', 'r') as f: + with open(DOC_PATH / 'switcher.json', 'r') as f: versions = json.load(f) found = False for v in versions: @@ -90,7 +93,7 @@ def add_version(app): 'url': "http://param.holoviz.org.s3-website-us-east-1.amazonaws.com/en/{version}/" }) - with open('./_static/switcher.json', 'w') as f: + with open(DOC_PATH / '_static' / 'switcher.json', 'w') as f: json.dump(versions, f) def setup(app): From 9e1408804ef36ee4bcc9b58fbe4127bda8727b8f Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:14:27 +0200 Subject: [PATCH 6/9] Add version_match --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index 6b40c255f..292626f07 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -58,6 +58,7 @@ "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 } } From dd9a565a3424310bea9a540bebf4352478f28b61 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:19:58 +0200 Subject: [PATCH 7/9] Define AWS region --- .github/workflows/docs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index be93c4606..b97b8d4da 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -28,7 +28,7 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + AWS_DEFAULT_REGION: us-east1 defaults: run: shell: bash -l {0} From ab76cf6950fed638f20deca7faf4507beed5e4b9 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:31:43 +0200 Subject: [PATCH 8/9] Attempt to use custom action --- .github/workflows/docs.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index b97b8d4da..afb416285 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -25,10 +25,6 @@ jobs: name: Documentation runs-on: 'ubuntu-latest' timeout-minutes: 120 - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east1 defaults: run: shell: bash -l {0} @@ -41,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 @@ -50,16 +48,18 @@ jobs: python -m pip install hatch - name: build docs run: hatch -v run docs:build - - name: upload dev + + - uses: shallwefootball/s3-upload-action@1.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'))) - env: - TAG_VAR: ${{ steps.vars.outputs.tag }} - run: | - pipx install awscli - aws s3 sync --quiet ./builtdocs s3://param.holoviz.org/en/latest - aws s3 sync --quiet ./builtdocs s3://param.holoviz.org/en/$TAG_VAR + name: Upload Dev Docs to S3 + with: + 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') || From 80d934f77006b9625f54294502a94767aa9abcac Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 30 Aug 2023 19:33:17 +0200 Subject: [PATCH 9/9] Fix version --- .github/workflows/docs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index afb416285..d283d14f5 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -49,7 +49,7 @@ jobs: - name: build docs run: hatch -v run docs:build - - uses: shallwefootball/s3-upload-action@1.3.3 + - 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')))