Skip to content

Commit 29bf100

Browse files
committed
feat: enable multidocs (#278)
* feat: enable multidocs * fix: rename requirements_doc file * feat: enable PDF build * feat: disable Python cache * fiz: change build-dir * feat: install pandoc * fix: skip deps cache
1 parent 2b62c09 commit 29bf100

File tree

4 files changed

+59
-44
lines changed

4 files changed

+59
-44
lines changed

.github/workflows/testing-and-deployment.yml

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99
PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners
1010
PYMAPDL_START_INSTANCE: FALSE
1111
DOCKER_PACKAGE: ghcr.io/pyansys/pymapdl/mapdl
12+
DOCUMENTATION_CNAME: reader.docs.pyansys.com
1213

1314
on:
1415
pull_request:
@@ -24,55 +25,30 @@ concurrency:
2425

2526
jobs:
2627
doc_build:
27-
name: Build Documentation
28+
name: Build documentation
2829
runs-on: ubuntu-latest
29-
3030
steps:
31-
- uses: actions/checkout@v3
32-
33-
- name: Setup Python
34-
uses: actions/setup-python@v4
35-
with:
36-
python-version: "3.10"
37-
3831
- name: Setup headless display
3932
uses: pyvista/setup-headless-display-action@v2
4033

41-
- name: Install ansys-mapdl-reader
42-
run: |
43-
pip install -e .
44-
cd tests/
45-
python -c "from ansys.mapdl import reader as pymapdl_reader; print(pymapdl_reader.Report())"
46-
47-
- name: Install OS packages
48-
run: |
49-
sudo apt-get update
50-
sudo apt-get install zip pandoc -qy
51-
52-
- name: Build Documentation
53-
run: |
54-
pip install -r requirements/requirements_docs.txt --disable-pip-version-check
55-
make -C doc html
56-
cd doc/build/html/
57-
zip -r ../../../${{ env.PACKAGE_NAME }}-HTML.zip ./*
58-
59-
- name: Upload
60-
uses: actions/upload-artifact@v3
34+
- name: Build project documentation
35+
uses: ansys/actions/doc-build@v4
6136
with:
62-
name: ${{ env.PACKAGE_NAME }}-Documentation
63-
path: |
64-
${{ env.PACKAGE_NAME }}-HTML.zip
65-
doc/build/latex/*.pdf
66-
retention-days: 7
37+
dependencies: 'pandoc'
38+
skip-dependencies-cache: true
39+
use-python-cache: false
40+
python-version: "3.10"
6741

68-
- name: Deploy
69-
uses: JamesIves/github-pages-deploy-action@v4
70-
if: startsWith(github.ref, 'refs/tags/')
42+
doc-deploy-dev:
43+
name: Upload development documentation
44+
runs-on: ubuntu-latest
45+
needs: [doc_build]
46+
if: github.ref == 'refs/heads/main'
47+
steps:
48+
- uses: ansys/actions/doc-deploy-dev@v4
7149
with:
50+
cname: ${{ env.DOCUMENTATION_CNAME }}
7251
token: ${{ secrets.GITHUB_TOKEN }}
73-
branch: gh-pages
74-
folder: doc/build/html
75-
clean: true
7652

7753
build:
7854
name: Build and Test
@@ -262,6 +238,12 @@ jobs:
262238
- name: Display structure of downloaded files
263239
run: ls -R
264240

241+
- name: Compressing HTML documentation
242+
uses: vimtor/[email protected]
243+
with:
244+
files: documentation-html
245+
dest: documentation-html.zip
246+
265247
- name: Upload to Public PyPi
266248
run: |
267249
pip install twine
@@ -279,3 +261,15 @@ jobs:
279261
./**/*.whl
280262
./**/*.zip
281263
./**/*.pdf
264+
265+
doc-deploy-release:
266+
name: Upload release documentation
267+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
268+
runs-on: ubuntu-latest
269+
needs: [Release]
270+
steps:
271+
- name: Deploy the stable documentation
272+
uses: ansys/actions/doc-deploy-stable@v4
273+
with:
274+
cname: ${{ env.DOCUMENTATION_CNAME }}
275+
token: ${{ secrets.GITHUB_TOKEN }}

doc/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
SPHINXOPTS =
66
SPHINXBUILD = sphinx-build
77
SOURCEDIR = source
8-
BUILDDIR = build
8+
BUILDDIR = _build
99

1010
# Put it first so that "make" without argument is like "make help".
1111
help:
@@ -21,5 +21,11 @@ help:
2121

2222
# customized clean due to examples gallery
2323
clean:
24-
rm -rf build
24+
rm -rf $(BUILDDIR)
2525
rm -rf source/examples
26+
27+
# Create PDF
28+
pdf:
29+
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
30+
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
31+
(test -f $(BUILDDIR)/latex/*.pdf && echo pdf exists) || exit 1

doc/source/conf.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import warnings
44

5-
from ansys_sphinx_theme import pyansys_logo_black
5+
from ansys_sphinx_theme import get_version_match, pyansys_logo_black
66
import pyvista
77
from sphinx_gallery.sorting import FileNameSortKey
88

@@ -141,13 +141,28 @@
141141

142142

143143
# -- Options for HTML output -------------------------------------------------
144+
cname = os.getenv("DOCUMENTATION_CNAME", default="nocname.com")
145+
switcher_version = get_version_match(version)
144146
html_short_title = html_title = "PyMAPDL - Legacy Reader"
145147
html_theme = "ansys_sphinx_theme"
146148
html_logo = pyansys_logo_black
149+
html_context = {
150+
"github_user": "ansys",
151+
"github_repo": "pymapdl-reader",
152+
"github_version": "main",
153+
"doc_path": "doc/source",
154+
}
147155
html_theme_options = {
148-
"github_url": "https://github.com/pyansys/pymapdl-reader",
156+
"switcher": {
157+
"json_url": f"https://{cname}/versions.json",
158+
"version_match": switcher_version,
159+
},
160+
"check_switcher": False,
161+
"github_url": "https://github.com/ansys/pymapdl-reader",
149162
"show_prev_next": False,
150163
"show_breadcrumbs": True,
164+
"collapse_navigation": True,
165+
"use_edit_page_button": True,
151166
"additional_breadcrumbs": [
152167
("PyAnsys", "https://docs.pyansys.com/"),
153168
],

0 commit comments

Comments
 (0)