From d7a62720c3ee876e8df19cb0b90ef9e24b0a3adc Mon Sep 17 00:00:00 2001 From: Revathy Venugopal <104772255+Revathyvenugopal162@users.noreply.github.com> Date: Fri, 13 Oct 2023 09:44:47 -0400 Subject: [PATCH] doc: enhance search bar experience by using pymeilisearch (#1179) * feat: add meilisearch indexing * fix: Update docs/source/conf.py * fix: env variable * fix: indentation * fix: the version * fix: the version --- .github/workflows/ci.yml | 17 +++++++++++++++++ .github/workflows/releaser.yml | 32 ++++++++++++++++++++++++++++++++ docs/source/conf.py | 7 +++++++ 3 files changed, 56 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b46e7f3422..3416db207f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ concurrency: env: DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com' MAIN_PYTHON_VERSION: '3.8' + MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} + MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }} jobs: debug: @@ -135,6 +137,21 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} doc-artifact-name: HTML-doc-ansys-dpf-core.zip decompress-artifact: true + + doc-index-dev: + name: "Deploy dev index docs" + runs-on: ubuntu-latest + needs: upload-development-docs + steps: + - name: "Deploy the latest documentation index" + uses: ansys/actions/doc-deploy-index@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }}/version/dev + index-name: pydpf-core-vdev + host-url: ${{ vars.MEILISEARCH_HOST_URL }} + api-key: ${{ env.MEILISEARCH_API_KEY }} + doc-artifact-name: HTML-doc-ansys-dpf-core.zip + decompress-artifact: true examples: if: startsWith(github.head_ref, 'master') || github.event.action == 'ready_for_review' || !github.event.pull_request.draft diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index a8780ed5ac..a42d04e76c 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -7,6 +7,8 @@ on: env: DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com' PYTHON_MAIN_VERSION: '3.10' + MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} + MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }} jobs: @@ -63,3 +65,33 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} doc-artifact-name: HTML-doc-ansys-dpf-core.zip decompress-artifact: true + + doc-index-stable: + name: "Deploy stable docs index" + runs-on: ubuntu-latest + needs: upload_docs_release + steps: + - name: "Install Git and clone project" + uses: actions/checkout@v4 + + - name: "Install the package requirements" + run: pip install -e . + + - name: "Get the version to PyMeilisearch" + run: | + VERSION=$(python -c "from ansys.dpf.core import __version__; print('.'.join(__version__.split('.')[:2]))") + VERSION_MEILI=$(python -c "from ansys.dpf.core import __version__; print('-'.join(__version__.split('.')[:2]))") + echo "Calculated VERSION: $VERSION" + echo "Calculated VERSION_MEILI: $VERSION_MEILI" + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "VERSION_MEILI=$VERSION_MEILI" >> $GITHUB_ENV + + - name: "Deploy the latest documentation index" + uses: ansys/actions/doc-deploy-index@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }}/version/${{ env.VERSION }} + index-name: pydpf-core-v${{ env.VERSION_MEILI }} + host-url: ${{ vars.MEILISEARCH_HOST_URL }} + api-key: ${{ env.MEILISEARCH_API_KEY }} + doc-artifact-name: HTML-doc-ansys-dpf-core.zip + decompress-artifact: true diff --git a/docs/source/conf.py b/docs/source/conf.py index ee10796ec3..d6c82e7a73 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -199,9 +199,16 @@ def reset_servers(gallery_conf, fname, when): "version_match": get_version_match(__version__), }, "navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"], + "use_meilisearch": { + "api_key": os.getenv("MEILISEARCH_PUBLIC_API_KEY", ""), + "index_uids": { + f"pydpf-core-v{get_version_match(__version__).replace('.', '-')}": "PyDPF-Core", + }, + }, } + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css".