Skip to content

Commit

Permalink
DOC: Avoid examples with GIF
Browse files Browse the repository at this point in the history
  • Loading branch information
SMoraisAnsys committed Apr 25, 2024
1 parent f9405b6 commit 1170461
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
4 changes: 4 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ clean: .install-deps
html-no-examples: .install-deps
@echo "Building HTML pages without examples."
export PYAEDT_DOC_RUN_EXAMPLES="0"
export PYAEDT_DOC_USE_GIF="1"
@# FIXME: currently linkcheck freezes and further investigation must be performed
@# @$(SPHINXBUILD) -M linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(LINKCHECKOPTS) $(O)
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Expand All @@ -55,6 +56,7 @@ html-no-examples: .install-deps
html: .install-deps
@echo "Building HTML pages with examples."
export PYAEDT_DOC_RUN_EXAMPLES="1"
export PYAEDT_DOC_USE_GIF="1"
@# FIXME: currently linkcheck freezes and further investigation must be performed
@# @$(SPHINXBUILD) -M linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(LINKCHECKOPTS) $(O)
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Expand All @@ -64,6 +66,7 @@ html: .install-deps
pdf-no-examples: .install-deps
@echo "Building PDF pages without examples."
export PYAEDT_DOC_RUN_EXAMPLES="0"
export PYAEDT_DOC_USE_GIF="0"
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
(test -f $(BUILDDIR)/latex/PyAEDT-Documentation-*.pdf && echo pdf exists) || exit 1
Expand All @@ -72,6 +75,7 @@ pdf-no-examples: .install-deps
pdf: .install-deps
@echo "Building PDF pages with examples."
export PYAEDT_DOC_RUN_EXAMPLES="1"
export PYAEDT_DOC_USE_GIF="0"
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
(test -f $(BUILDDIR)/latex/PyAEDT-Documentation-*.pdf && echo pdf exists) || exit 1
Expand Down
4 changes: 4 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ goto end
:html
echo Building HTML pages with examples
set PYAEDT_DOC_RUN_EXAMPLES=1
set PYAEDT_DOC_USE_GIF=1
::FIXME: currently linkcheck freezes and further investigation must be performed
::%SPHINXBUILD% -M linkcheck %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %LINKCHECKOPTS% %O%
%SPHINXBUILD% -M html %SOURCEDIR% %BUILDDIR%
Expand All @@ -71,6 +72,7 @@ goto end
:html-no-examples
echo Building HTML pages without examples
set PYAEDT_DOC_RUN_EXAMPLES=0
set PYAEDT_DOC_USE_GIF=1
if not exist "source\examples" mkdir "source\examples"
echo Examples> source\examples\index.rst
echo ========> source\examples\index.rst
Expand All @@ -84,6 +86,7 @@ goto end
:pdf
echo Building PDF pages with examples
set PYAEDT_DOC_RUN_EXAMPLES=1
set PYAEDT_DOC_USE_GIF=0
%SPHINXBUILD% -M latex %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
cd "%BUILDDIR%\latex"
for %%f in (*.tex) do (
Expand All @@ -94,6 +97,7 @@ goto end
:pdf-no-examples
echo Building PDF pages without examples
set PYAEDT_DOC_RUN_EXAMPLES=0
set PYAEDT_DOC_USE_GIF=0
if not exist "source\examples" mkdir "source\examples"
echo Examples> source\examples\index.rst
echo ========> source\examples\index.rst
Expand Down
26 changes: 4 additions & 22 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,10 @@ def remove_doctree(app, exception):
shutil.rmtree(app.doctreedir, ignore_errors=True)
logger.info(f"Doctree removed.")

# NOTE: The list of skipped files requires to be updated every time a new example
# with GIF content is created or removed.
def skip_gif_examples_to_build_pdf(app):
"""Callback function for builder-inited event.
Add examples showing GIF to the list of excluded files when building PDF files.
Parameters
----------
app :
The application object representing the Sphinx process.
"""
if app.builder.name == 'latex':
app.config.exclude_patterns.extend([
'Maxwell2D_Transient.py',
'Maxwell2D_DCConduction.py',
'Hfss_Icepak_Coupling.py',
])


def setup(app):
app.add_directive('pprint', PrettyPrintDirective)
app.connect('autodoc-skip-member', autodoc_skip_member)
app.connect('build-finished', remove_doctree)
app.connect('builder-inited', skip_gif_examples_to_build_pdf)


local_path = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -152,6 +131,7 @@ def setup(app):

# Do not run examples by default
run_examples = bool(int(os.getenv("PYAEDT_DOC_RUN_EXAMPLES", "0")))
use_gif = bool(int(os.getenv("PYAEDT_DOC_USE_GIF", "1")))

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -324,9 +304,11 @@ def setup(app):
# Modules for which function level galleries are created. In
"doc_module": "ansys-pyaedt",
"image_scrapers": ("pyvista", "matplotlib"),
"ignore_pattern": "flycheck*",
"ignore_pattern": r"flycheck.*",
"thumbnail_size": (350, 350),
}
if not use_gif:
sphinx_gallery_conf["ignore_pattern"] = sphinx_gallery_conf["ignore_pattern"] + r"|.*Maxwell2D_Transient\.py|.*Maxwell2D_DCConduction\.py|.*Hfss_Icepak_Coupling\.py"

jinja_contexts = {
"main_toctree": {
Expand Down

0 comments on commit 1170461

Please sign in to comment.