From 117046131ffa4f0fce994460a8b17d8d36212b85 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Thu, 25 Apr 2024 15:13:22 +0200 Subject: [PATCH] DOC: Avoid examples with GIF --- doc/Makefile | 4 ++++ doc/make.bat | 4 ++++ doc/source/conf.py | 26 ++++---------------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index c802e4b8bf7..6b135dfaa78 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -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) @@ -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) @@ -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 @@ -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 diff --git a/doc/make.bat b/doc/make.bat index b2a0365656d..bc9100f4b20 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -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% @@ -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 @@ -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 ( @@ -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 diff --git a/doc/source/conf.py b/doc/source/conf.py index c92d06bc5ee..0ee8620684c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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__)) @@ -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 --------------------------------------------------- @@ -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": {