From 4d8b232ad7aae890e4aabd7e5e1804c849b82fa6 Mon Sep 17 00:00:00 2001 From: Camille <78221213+clatapie@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:13:45 +0000 Subject: [PATCH] Fixing DynamicScrapper (#198) Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> --- .github/workflows/ci_cd.yml | 61 ++++++++----------- .../README.rst => source/_static/README.md} | 0 doc/source/_static/README.rst | 0 doc/source/conf.py | 9 +-- pyproject.toml | 1 + 5 files changed, 31 insertions(+), 40 deletions(-) rename doc/{_static/README.rst => source/_static/README.md} (100%) delete mode 100644 doc/source/_static/README.rst diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 95300480..653baded 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -20,10 +20,10 @@ env: PYMAPDL_START_INSTANCE: FALSE PYMAPDL_PORT: 21000 # default won't work on GitHub runners PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners + RESET_PIP_CACHE: 0 RESET_AUTOSUMMARY_CACHE: 0 RESET_EXAMPLES_CACHE: 0 RESET_DOC_BUILD_CACHE: 0 - RESET_PIP_CACHE: 0 concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -45,14 +45,14 @@ jobs: name: "Documentation Style Check" runs-on: ubuntu-latest steps: - - name: PyAnsys documentation style checks + - name: "PyAnsys documentation style checks" uses: ansys/actions/doc-style@v5 with: token: ${{ secrets.GITHUB_TOKEN }} smoke-tests: - name: Build and Smoke tests + name: "Build and Smoke tests" runs-on: ${{ matrix.os }} needs: [code-style] strategy: @@ -69,7 +69,7 @@ jobs: - should-release: false os: windows-latest steps: - - name: Build wheelhouse and perform smoke test + - name: "Build wheelhouse and perform smoke test" uses: ansys/actions/build-wheelhouse@v5 with: library-name: ${{ env.PACKAGE_NAME }} @@ -107,7 +107,7 @@ jobs: restore-keys: | Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.mapdl-version }} - - name: Install ansys-mapdl-core + - name: "Install ansys-mapdl-core" run: | python -m pip install ansys-mapdl-core @@ -149,7 +149,7 @@ jobs: name: ${{ matrix.mapdl-version }}-remote.xml flags: remote,${{ matrix.mapdl-version }} - - name: Upload coverage artifacts + - name: "Upload coverage artifacts" uses: actions/upload-artifact@v4 with: name: ${{ matrix.mapdl-version }}-remote.xml @@ -214,15 +214,16 @@ jobs: doc-build: - name: Doc building + name: "Doc building" runs-on: ubuntu-latest needs: [doc-style] + outputs: + ANSYSMATH_VERSION: ${{ steps.version.outputs.ANSYSMATH_VERSION }} env: PYMAPDL_PORT: 21000 # default won't work on GitHub runners PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners PYMAPDL_START_INSTANCE: FALSE steps: - # This checkout is repeated later at the 'doc-build' action. This could be avoided by copything the sh file here, but introduces some code duplicity. - name: "Install Git and checkout project" uses: actions/checkout@v4 @@ -231,11 +232,6 @@ jobs: with: python-version: ${{ env.MAIN_PYTHON_VERSION }} - - name: "Install OS packages" - run: | - sudo apt update - sudo apt install pandoc - - name: "Cache pip" uses: actions/cache@v4 with: @@ -244,9 +240,9 @@ jobs: restore-keys: | Python-v${{ env.RESET_PIP_CACHE }}-Linux-${{ env.MAIN_PYTHON_VERSION }} - - name: "Install ansys-math-core" + - name: "Install ansys-math-core and documentation requirements" run: | - pip install . + pip install .[doc] - name: "Login in Github container registry" uses: docker/login-action@v3.0.0 @@ -262,57 +258,54 @@ jobs: MAPDL_IMAGE: '${{ env.DOCKER_PACKAGE }}:${{ env.DOCKER_IMAGE_VERSION_DOCS_BUILD }}' - name: "Retrieve AnsysMath version" + id: version run: | - echo "ANSYSMATH_VERSION=$(python -c 'from ansys.math.core import __version__; print(__version__)')" >> $GITHUB_ENV + echo "ANSYSMATH_VERSION=$(python -c 'from ansys.math.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT echo "AnsysMath version is: $(python -c "from ansys.math.core import __version__; print(__version__)")" - name: "Cache examples" uses: actions/cache@v4 with: path: doc/source/examples - key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ env.ANSYSMATH_VERSION }}-${{ github.sha }} + key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.ANSYSMATH_VERSION }}-${{ github.sha }} restore-keys: | - Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ env.ANSYSMATH_VERSION }} - + Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.ANSYSMATH_VERSION }} + - name: "Cache docs build directory" uses: actions/cache@v4 with: path: doc/_build - key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.ANSYSMATH_VERSION }}-${{ github.sha }} + key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.ANSYSMATH_VERSION }}-${{ github.sha }} restore-keys: | - doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.ANSYSMATH_VERSION }} + doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.ANSYSMATH_VERSION }} + - name: "Cache autosummary" uses: actions/cache@v4 with: path: doc/source/**/_autosummary/*.rst - key: autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ env.ANSYSMATH_VERSION }}-${{ github.sha }} + key: autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.ANSYSMATH_VERSION }}-${{ github.sha }} restore-keys: | - autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ env.ANSYSMATH_VERSION }} - - - name: "Install docs build requirements" - run: | - pip install .[doc] - - - name: List - run: pip list + autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.ANSYSMATH_VERSION }} - name: "Run Ansys documentation building action" uses: ansys/actions/doc-build@v5 with: python-version: ${{ env.MAIN_PYTHON_VERSION }} - checkout: false skip-install: true - sphinxopts: -j auto + checkout: false + sphinxopts: -j auto --keep-going requires-xvfb: true + skip-json-build: true + dependencies: pandoc package: - name: Package library + name: "Package library" needs: [doc-build, build-test] runs-on: ubuntu-latest steps: - - name: Build library source and wheel artifacts + - name: "Build library source and wheel artifacts" uses: ansys/actions/build-library@v5 with: library-name: ${{ env.PACKAGE_NAME }} diff --git a/doc/_static/README.rst b/doc/source/_static/README.md similarity index 100% rename from doc/_static/README.rst rename to doc/source/_static/README.md diff --git a/doc/source/_static/README.rst b/doc/source/_static/README.rst deleted file mode 100644 index e69de29b..00000000 diff --git a/doc/source/conf.py b/doc/source/conf.py index 162b8102..a7dad7e0 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -7,6 +7,7 @@ from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_black import numpy as np import pyvista +from pyvista.plotting.utilities.sphinx_gallery import DynamicScraper from sphinx_gallery.sorting import FileNameSortKey from ansys.math.core import __version__ @@ -18,11 +19,6 @@ # must be less than or equal to the XVFB window size pyvista.global_theme.window_size = np.array([1024, 768]) -# Save figures in specified directory -pyvista.FIGURE_PATH = os.path.join(os.path.abspath("./images/"), "auto-generated/") -if not os.path.exists(pyvista.FIGURE_PATH): - os.makedirs(pyvista.FIGURE_PATH) - # necessary when building the sphinx gallery pyvista.BUILDING_GALLERY = True pymath.BUILDING_GALLERY = True @@ -92,6 +88,7 @@ "sphinx.ext.coverage", "sphinx.ext.intersphinx", "sphinx_copybutton", + "sphinx_design", "sphinx_gallery.gen_gallery", "pyvista.ext.viewer_directive", ] @@ -114,7 +111,7 @@ "backreferences_dir": None, # Modules for which function level galleries are created. In "doc_module": "ansys-math-core", - "image_scrapers": ("pyvista", "matplotlib"), + "image_scrapers": (DynamicScraper(), "matplotlib"), "ignore_pattern": "flycheck*", "thumbnail_size": (350, 350), } diff --git a/pyproject.toml b/pyproject.toml index 0e4b582b..dcf16985 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,7 @@ doc = [ "sphinx-autobuild==2024.2.4", "sphinx-autodoc-typehints==2.0.0", "sphinx-copybutton==0.5.2", + "sphinx-design==0.5.0", "sphinx-notfound-page==1.0.0", "sphinx-gallery==0.15.0", "trame==3.5.2",