Skip to content

Commit

Permalink
Add warnings in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Nov 8, 2023
1 parent c4d8dc6 commit 5b34b5e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 8 additions & 1 deletion sphinx_needs/directives/needbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
9 changes: 8 additions & 1 deletion sphinx_needs/directives/needpie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down

0 comments on commit 5b34b5e

Please sign in to comment.