Skip to content

Commit

Permalink
CI: generate PDF documentation (#162)
Browse files Browse the repository at this point in the history
Add steps in `make.bat`, `Makefile` and `tox.ini` for compiling the PDF
documentation, and include them in CI/CD.

Co-authored-by: Dominik Gresch <[email protected]>
  • Loading branch information
jorgepiloto and greschd authored Jan 30, 2023
1 parent d6c4ca5 commit 917ae7b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,22 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: documentation-html
path: .tox/doc_out/
path: .tox/doc_out/html
retention-days: 7

- name: "Install OS packages for PDF"
run: |
sudo apt-get install latexmk texlive-latex-extra
- name: "Generate the PDF documentation with tox"
run: |
tox -e doc-linux-pdf
- name: "Upload PDF Documentation"
uses: actions/upload-artifact@v2
with:
name: documentation-pdf
path: .tox/doc_out/latex/ansys-dpf-composites.pdf
retention-days: 7

build-package:
Expand Down
6 changes: 6 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ clean:
rm -rf $(BUILDDIR)/*
rm -rf $(SOURCEDIR)/examples
find . -type d -name "_autosummary" -exec rm -rf {} +

# Customized pdf fov svg format images
pdf:
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
(test -f $(BUILDDIR)/latex/*.pdf && echo pdf exists) || exit 1
8 changes: 8 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set BUILDDIR=_build

if "%1" == "" goto help
if "%1" == "clean" goto clean
if "%1" == "pdf" goto pdf

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
Expand All @@ -37,6 +38,13 @@ goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:pdf
%SPHINXBUILD% -M latex %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
cd "%BUILDDIR%\latex"
for %%f in (*.tex) do (
pdflatex "%%f" --interaction=nonstopmode)

:end
popd
21 changes: 15 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ basepython =
allowlist_externals =
poetry
commands =poetry install -E docs
poetry build
poetry run pip install --find-links=.\dist ansys-dpf-composites
poetry run sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxworkdir}/doc_out" --color -n -vW --keep-going -bhtml
poetry run sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxworkdir}/doc_out/html" --color -n -vW --keep-going -bhtml

[testenv:doc-linux]
description = Check if documentation generates properly
Expand All @@ -83,6 +81,17 @@ passenv = PYDPF_COMPOSITES_DOCKER_CONTAINER_PORT
allowlist_externals =
poetry, xvfb-run
commands =poetry install -E docs
poetry build
poetry run pip install --find-links=.\dist ansys-dpf-composites
xvfb-run poetry run sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxworkdir}/doc_out" --color -n -vW --keep-going -bhtml
xvfb-run poetry run sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxworkdir}/doc_out/html" --color -n -vW --keep-going -bhtml

[testenv:doc-linux-pdf]
description = Check if documentation generates properly
setenv = REPO_ROOT = {toxinidir}
basepython =
python3.9
passenv = PYDPF_COMPOSITES_DOCKER_CONTAINER_PORT
allowlist_externals =
poetry, xvfb-run, bash, test
commands =poetry install -E docs
-xvfb-run poetry run sphinx-build -M latex -d "{toxworkdir}/doc_doctree" doc/source "{toxworkdir}/doc_out/latex" --color --keep-going
-bash -c "cd {toxworkdir}/doc_out/latex/ && latexmk -f -r latexmkrc -pdf *.tex -interaction=nonstopmode"
test -f "{toxworkdir}/doc_out/latex/ansys-dpf-composites.pdf"

0 comments on commit 917ae7b

Please sign in to comment.