Skip to content

Commit d7a6272

Browse files
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
1 parent 5ee39a2 commit d7a6272

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ concurrency:
2323
env:
2424
DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com'
2525
MAIN_PYTHON_VERSION: '3.8'
26+
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
27+
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}
2628

2729
jobs:
2830
debug:
@@ -135,6 +137,21 @@ jobs:
135137
token: ${{ secrets.GITHUB_TOKEN }}
136138
doc-artifact-name: HTML-doc-ansys-dpf-core.zip
137139
decompress-artifact: true
140+
141+
doc-index-dev:
142+
name: "Deploy dev index docs"
143+
runs-on: ubuntu-latest
144+
needs: upload-development-docs
145+
steps:
146+
- name: "Deploy the latest documentation index"
147+
uses: ansys/actions/doc-deploy-index@v4
148+
with:
149+
cname: ${{ env.DOCUMENTATION_CNAME }}/version/dev
150+
index-name: pydpf-core-vdev
151+
host-url: ${{ vars.MEILISEARCH_HOST_URL }}
152+
api-key: ${{ env.MEILISEARCH_API_KEY }}
153+
doc-artifact-name: HTML-doc-ansys-dpf-core.zip
154+
decompress-artifact: true
138155

139156
examples:
140157
if: startsWith(github.head_ref, 'master') || github.event.action == 'ready_for_review' || !github.event.pull_request.draft

.github/workflows/releaser.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
env:
88
DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com'
99
PYTHON_MAIN_VERSION: '3.10'
10+
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
11+
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}
1012

1113
jobs:
1214

@@ -63,3 +65,33 @@ jobs:
6365
token: ${{ secrets.GITHUB_TOKEN }}
6466
doc-artifact-name: HTML-doc-ansys-dpf-core.zip
6567
decompress-artifact: true
68+
69+
doc-index-stable:
70+
name: "Deploy stable docs index"
71+
runs-on: ubuntu-latest
72+
needs: upload_docs_release
73+
steps:
74+
- name: "Install Git and clone project"
75+
uses: actions/checkout@v4
76+
77+
- name: "Install the package requirements"
78+
run: pip install -e .
79+
80+
- name: "Get the version to PyMeilisearch"
81+
run: |
82+
VERSION=$(python -c "from ansys.dpf.core import __version__; print('.'.join(__version__.split('.')[:2]))")
83+
VERSION_MEILI=$(python -c "from ansys.dpf.core import __version__; print('-'.join(__version__.split('.')[:2]))")
84+
echo "Calculated VERSION: $VERSION"
85+
echo "Calculated VERSION_MEILI: $VERSION_MEILI"
86+
echo "VERSION=$VERSION" >> $GITHUB_ENV
87+
echo "VERSION_MEILI=$VERSION_MEILI" >> $GITHUB_ENV
88+
89+
- name: "Deploy the latest documentation index"
90+
uses: ansys/actions/doc-deploy-index@v4
91+
with:
92+
cname: ${{ env.DOCUMENTATION_CNAME }}/version/${{ env.VERSION }}
93+
index-name: pydpf-core-v${{ env.VERSION_MEILI }}
94+
host-url: ${{ vars.MEILISEARCH_HOST_URL }}
95+
api-key: ${{ env.MEILISEARCH_API_KEY }}
96+
doc-artifact-name: HTML-doc-ansys-dpf-core.zip
97+
decompress-artifact: true

docs/source/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,16 @@ def reset_servers(gallery_conf, fname, when):
199199
"version_match": get_version_match(__version__),
200200
},
201201
"navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
202+
"use_meilisearch": {
203+
"api_key": os.getenv("MEILISEARCH_PUBLIC_API_KEY", ""),
204+
"index_uids": {
205+
f"pydpf-core-v{get_version_match(__version__).replace('.', '-')}": "PyDPF-Core",
206+
},
207+
},
202208
}
203209

204210

211+
205212
# Add any paths that contain custom static files (such as style sheets) here,
206213
# relative to this directory. They are copied after the builtin static files,
207214
# so a file named "default.css" will overwrite the builtin "default.css".

0 commit comments

Comments
 (0)