Skip to content

Commit a949deb

Browse files
DOC: implement multi-doc in v0.61 (#1677)
* Adapt to multidoc for v0.61 * Adapt precommit for the patch for multidoc for v0.61 * Resolve style error * rename reqirement.doc in ci/cd * Modify make file * Modify deploy actions * Modify theme name * FIX: output doc/_build dir * CI: deploy only stable Co-authored-by: Jorge Martinez Garrido <[email protected]>
1 parent eba1898 commit a949deb

File tree

7 files changed

+53
-51
lines changed

7 files changed

+53
-51
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ env:
2626
RESET_DOC_BUILD_CACHE: 0
2727
RESET_AUTOSUMMARY_CACHE: 0
2828
PACKAGE_NAME: PyMAPDL
29+
DOCUMENTATION_CNAME: 'mapdl.docs.pyansys.com'
30+
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.ref }}
33+
cancel-in-progress: true
2934

3035
jobs:
3136

@@ -136,7 +141,7 @@ jobs:
136141
uses: actions/cache@v2
137142
with:
138143
path: ~/.cache/pip
139-
key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements_docs*.txt') }}
144+
key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements_doc*.txt') }}
140145
restore-keys: |
141146
Python-${{ runner.os }}-${{ matrix.python-version }}
142147
@@ -177,7 +182,7 @@ jobs:
177182
- name: Cache docs build directory
178183
uses: actions/cache@v2
179184
with:
180-
path: doc/build
185+
path: doc/_build
181186
key: doc-build-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }}
182187
restore-keys: |
183188
doc-build-${{ steps.version.outputs.PYMAPDL_VERSION }}
@@ -192,34 +197,24 @@ jobs:
192197
193198
- name: Install Docs Build Requirements
194199
run: |
195-
pip install -r requirements/requirements_docs.txt
200+
pip install -r requirements/requirements_doc.txt
196201
197202
- name: Build Documentation
198203
run: |
199204
xvfb-run make -C doc html SPHINXOPTS="-j auto -W --keep-going"
200205
201206
- name: Zip documentation
202207
run: |
203-
cd doc/build/html
208+
cd doc/_build/html
204209
zip -r PyMAPDL_documentation.zip *
205210
206211
- name: Upload HTML Documentation
207212
uses: actions/upload-artifact@v2
208213
with:
209214
name: HTML-Documentation
210-
path: doc/build/html/PyMAPDL_documentation.zip
215+
path: doc/_build/html/PyMAPDL_documentation.zip
211216
retention-days: 7
212217

213-
- name: Deploy
214-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
215-
uses: JamesIves/[email protected]
216-
with:
217-
repository-name: pyansys/pymapdl-docs
218-
token: ${{ steps.get_workflow_token.outputs.token }}
219-
BRANCH: gh-pages
220-
FOLDER: doc/build/html
221-
CLEAN: true
222-
223218
- name: Build PDF Documentation
224219
working-directory: doc
225220
run: make pdf
@@ -228,7 +223,7 @@ jobs:
228223
uses: actions/upload-artifact@v2
229224
with:
230225
name: PDF-Documentation
231-
path: doc/build/latex/pymapdl*.pdf
226+
path: doc/_build/latex/pymapdl*.pdf
232227
retention-days: 7
233228

234229
build_test:
@@ -349,3 +344,17 @@ jobs:
349344
overwrite: "{
350345
title: `Release FAILED!`,
351346
}"
347+
348+
upload_docs_release:
349+
name: "Upload release documentation"
350+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
351+
runs-on: ubuntu-latest
352+
needs: [release]
353+
steps:
354+
- name: Deploy the stable documentation
355+
uses: pyansys/actions/doc-deploy-stable@v2
356+
with:
357+
cname: ${{ env.DOCUMENTATION_CNAME }}
358+
token: ${{ secrets.GITHUB_TOKEN }}
359+
python-version: '3.9'
360+

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ repos:
1313
"--force-sort-within-sections",
1414
"--skip-glob", "*__init__.py",
1515
]
16-
- repo: https://gitlab.com/PyCQA/flake8
17-
rev: 3.9.2
16+
- repo: https://github.com/PyCQA/flake8
17+
rev: 6.0.0
1818
hooks:
1919
- id: flake8
2020

doc/Makefile

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,34 @@
1-
# Minimal makefile for Sphinx documentation
2-
#
3-
4-
# You can set these variables from the command line.
51
SPHINXOPTS = -j auto
62
SPHINXBUILD = sphinx-build
73
SOURCEDIR = source
8-
BUILDDIR = build
4+
BUILDDIR = _build
5+
96

107
# Put it first so that "make" without argument is like "make help".
118
help:
129
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13-
1410
.PHONY: help Makefile
15-
1611
# Catch-all target: route all unknown targets to Sphinx using the new
1712
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1813
%: Makefile
1914
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20-
21-
2215
# customized clean due to examples gallery
2316
clean:
2417
rm -rf $(BUILDDIR)/*
2518
rm -rf source/examples
2619
find . -type d -name "_autosummary" -exec rm -rf {} +
27-
2820
# customized clean due to examples gallery
2921
clean-except-examples:
3022
rm -rf $(BUILDDIR)/*
3123
rm -rf images/auto-generated
3224
find . -type d -name "_autosummary" -exec rm -rf {} +
33-
3425
# customized to build the pdf rather than using latexpdf due to various issues
3526
# with our docs like GIFs being written as PNG.
3627
pdf:
3728
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
3829
python validate_png.py # clean-up GIFs mislabeled as PNG
39-
cd build/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
40-
(test -f build/latex/*.pdf && echo pdf exists) || exit 1
30+
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
31+
(test -f $(BUILDDIR)/latex/*.pdf && echo pdf exists) || exit 1
4132

4233
# manually deploy to https://github.com/pyansys/pymapdl-docs
4334
# WARNING: Use with care as this overwrites history of gh-pages
@@ -47,12 +38,12 @@ deploy:
4738
@echo "This overwrites the history of gh-pages."
4839
@echo "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
4940
@echo "Deploying..."
50-
touch build/html/.nojekyll
51-
echo "mapdldocs.pyansys.com" >> build/html/CNAME
52-
cd build/html && git init
53-
cd build/html && git add .
54-
cd build/html && git checkout -b gh-pages
55-
cd build/html && git commit -am "manual build"
56-
cd build/html && git remote add origin https://github.com/pyansys/pymapdl-docs
57-
cd build/html && git push -u origin gh-pages --force
58-
rm -rf build/html/.git
41+
touch $(BUILDDIR)/html/.nojekyll
42+
echo "mapdldocs.pyansys.com" >> $(BUILDDIR)/html/CNAME
43+
cd $(BUILDDIR)/html && git init
44+
cd $(BUILDDIR)/html && git add .
45+
cd $(BUILDDIR)/html && git checkout -b gh-pages
46+
cd $(BUILDDIR)/html && git commit -am "manual build"
47+
cd $(BUILDDIR)/html && git remote add origin https://github.com/pyansys/pymapdl-docs
48+
cd $(BUILDDIR)/html && git push -u origin gh-pages --force
49+
rm -rf $(BUILDDIR)/html/.git

doc/make.bat

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
@ECHO OFF
2-
32
pushd %~dp0
4-
53
REM Command file for Sphinx documentation
6-
74
if "%SPHINXBUILD%" == "" (
85
set SPHINXBUILD=sphinx-build
96
)
107
set SOURCEDIR=source
11-
set BUILDDIR=build
8+
set BUILDDIR=_build
9+
1210

1311
if "%1" == "" goto help
1412

@@ -24,12 +22,10 @@ if errorlevel 9009 (
2422
echo.http://sphinx-doc.org/
2523
exit /b 1
2624
)
27-
2825
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
2926
goto end
3027

3128
:help
3229
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33-
3430
:end
35-
popd
31+
popd

doc/source/conf.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import os
44
import warnings
55

6+
from ansys_sphinx_theme import get_version_match, pyansys_logo_black
67
import numpy as np
7-
from pyansys_sphinx_theme import pyansys_logo_black
88
import pyvista
99
from sphinx_gallery.sorting import FileNameSortKey
1010

11+
cname = os.getenv("DOCUMENTATION_CNAME", "nocname.com")
1112
from ansys.mapdl.core import __version__
1213

1314
# Manage errors
@@ -167,7 +168,7 @@
167168

168169
# -- Options for HTML output -------------------------------------------------
169170
html_short_title = html_title = "PyMAPDL"
170-
html_theme = "pyansys_sphinx_theme"
171+
html_theme = "ansys_sphinx_theme"
171172
html_logo = pyansys_logo_black
172173
html_theme_options = {
173174
"github_url": "https://github.com/pyansys/pymapdl",
@@ -176,6 +177,11 @@
176177
"additional_breadcrumbs": [
177178
("PyAnsys", "https://docs.pyansys.com/"),
178179
],
180+
"switcher": {
181+
"json_url": f"https://{cname}/release/versions.json",
182+
"version_match": get_version_match(__version__),
183+
},
184+
"navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
179185
}
180186

181187
# -- Options for HTMLHelp output ---------------------------------------------

doc/validate_png.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from PIL import Image
1010

1111
this_path = os.path.dirname(os.path.abspath(__file__))
12-
check_path = os.path.join(this_path, "build", "latex")
12+
check_path = os.path.join(this_path, "_build", "latex")
1313
if not os.path.isdir(check_path):
1414
raise FileNotFoundError(f"Invalid path {check_path}")
1515

requirements/requirements_docs.txt renamed to requirements/requirements_doc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ matplotlib==3.5.1
88
numpydoc==1.2
99
pandas==1.4.1
1010
plotly==5.6.0
11-
pyansys_sphinx_theme==0.2.3
11+
ansys_sphinx_theme==0.8.0
1212
pypandoc==1.7.4
1313
pytest-sphinx==0.3.1
1414
pythreejs==2.3.0

0 commit comments

Comments
 (0)