diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a5a8f4ab3..43aa9ef11 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -79,7 +79,7 @@ jobs: python -m pytest -v --ignore=tests/benchmarks -m "jstest" tests tests-no-mpl: - name: Docs no matplotlib + name: Test matplotlib uninstalled runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/noxfile.py b/noxfile.py index 94999fdbb..c4a8cb9ee 100644 --- a/noxfile.py +++ b/noxfile.py @@ -27,8 +27,7 @@ def tests_no_mpl(session): session.run("pip", "uninstall", "-y", "matplotlib", "numpy", silent=True) session.run("echo", "TEST FINAL PACKAGE LIST") session.run("pip", "freeze") - posargs = session.posargs or ["tests/no_mpl_tests.py"] - session.run("pytest", *posargs, external=True) + session.run("pytest", "tests/no_mpl_tests.py", *session.posargs, external=True) @session(python="3.10") diff --git a/sphinx_needs/directives/needbar.py b/sphinx_needs/directives/needbar.py index f4df2696d..1e048a3ce 100644 --- a/sphinx_needs/directives/needbar.py +++ b/sphinx_needs/directives/needbar.py @@ -184,13 +184,20 @@ def process_needbar(app: Sphinx, doctree: nodes.document, fromdocname: str, foun # NEEDFLOW # for node in doctree.findall(Needbar): for node in found_nodes: - if matplotlib is None or not needs_config.include_needs: + if not needs_config.include_needs: remove_node_from_tree(node) continue id = node.attributes["ids"][0] current_needbar = needs_data.get_or_create_bars()[id] + if matplotlib is None: + message = "Matplotlib missing for needbar plot" + if current_needbar["title"]: + message += f" {current_needbar['title']!r}" + node.replace_self(nodes.error("", nodes.paragraph(text=message))) + continue + # 1. define constants error_id = current_needbar["error_id"] diff --git a/sphinx_needs/directives/needpie.py b/sphinx_needs/directives/needpie.py index 5af415a1b..ab018ed8a 100644 --- a/sphinx_needs/directives/needpie.py +++ b/sphinx_needs/directives/needpie.py @@ -120,13 +120,20 @@ def process_needpie(app: Sphinx, doctree: nodes.document, fromdocname: str, foun # NEEDFLOW # for node in doctree.findall(Needpie): for node in found_nodes: - if matplotlib is None or not needs_config.include_needs: + if not needs_config.include_needs: remove_node_from_tree(node) continue id = node.attributes["ids"][0] current_needpie = needs_data.get_or_create_pies()[id] + if matplotlib is None: + message = "Matplotlib missing for needpie plot" + if current_needpie["title"]: + message += f" {current_needpie['title']!r}" + node.replace_self(nodes.error("", nodes.paragraph(text=message))) + continue + # Set matplotlib style style_previous_to_script_execution = matplotlib.rcParams if current_needpie["style"]: