Skip to content

Commit

Permalink
Merge branch 'master' into rel_json_path
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Jan 6, 2025
2 parents 6ebf4e6 + 9c5a6db commit df74963
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/layout_styles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ By setting a style to ``None``, no style is set and the normal Sphinx-Needs styl
Own style configuration
~~~~~~~~~~~~~~~~~~~~~~~~

If you need to customize the css definitions, there are twi ways of doing it:
If you need to customize the css definitions, there are two ways of doing it:

* Provide a css file by using :ref:`needs_css`
* Set own css on sphinx level
Expand Down Expand Up @@ -588,7 +588,7 @@ HTML output
For **html output** the used layout and style names are added as css-class to the need table object.
Beside this also the used grid system is added::

<table class="need needs_grid_simple needs_layout_complex needes_style_blue docutils" id="SPEC_1">
<table class="need needs_grid_simple needs_layout_complex needs_style_blue docutils" id="SPEC_1">

The above line contains the following css classes:

Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def check_and_get_external_filter_func(
return None

try:
filter_module, filter_function = filter_func_ref.rsplit(".")
filter_module, filter_function = filter_func_ref.rsplit(".", 1)
except ValueError:
raise NeedsInvalidFilter("does not contain a dot")

Expand Down
17 changes: 17 additions & 0 deletions tests/doc_test/doc_needs_filter_data/filter_code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Filter code test cases
:labels: project_x, project_y
:filter-func: filter_code_func.my_pie_filter_code

.. needtable:: Filter code func table with multiple dots filter function path
:style: table
:filter-func: module.filter_code_func.own_filter_code


.. needpie:: Filter code func pie with multiple dots filter function path
:labels: project_x, project_y
:filter-func: module.filter_code_func.my_pie_filter_code

.. needtable:: Malformed filter func table
:style: table
Expand All @@ -31,3 +39,12 @@ Filter code test cases
.. needpie:: Malformed filter func pie
:labels: project_x, project_y
:filter-func: filter_code_func.my_pie_filter_code(

.. needtable:: Malformed filter func table with multiple dots filter function path
:style: table
:filter-func: module.filter_code_func.own_filter_code(


.. needpie:: Malformed filter func pie with multiple dots filter function path
:labels: project_x, project_y
:filter-func: module.filter_code_func.my_pie_filter_code(
34 changes: 34 additions & 0 deletions tests/doc_test/doc_needs_filter_data/module/filter_code_func.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
def own_filter_code(needs, results):
for need in needs:
if need["type"] == "test":
results.append(need)


def own_filter_code_args(needs, results, **kwargs):
for need in needs:
if need["status"] == kwargs["arg1"]:
results.append(need)


def my_pie_filter_code(needs, results):
cnt_x = 0
cnt_y = 0
for need in needs:
if need["variant"] == "project_x":
cnt_x += 1
if need["variant"] == "project_y":
cnt_y += 1
results.append(cnt_x)
results.append(cnt_y)


def my_pie_filter_code_args(needs, results, **kwargs):
cnt_x = 0
cnt_y = 0
for need in needs:
if need["status"] == kwargs["arg1"]:
cnt_x += 1
if need["status"] == kwargs["arg2"]:
cnt_y += 1
results.append(cnt_x)
results.append(cnt_y)
20 changes: 17 additions & 3 deletions tests/test_needs_filter_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ def test_doc_needs_filter_data_html(test_app):
).splitlines()
print(warnings)
assert warnings == [
"srcdir/filter_code.rst:26: WARNING: malformed function signature: 'own_filter_code(' [needs.filter_func]",
"srcdir/filter_code.rst:31: WARNING: malformed function signature: 'my_pie_filter_code(' [needs.filter_func]",
"srcdir/filter_code.rst:34: WARNING: malformed function signature: 'own_filter_code(' [needs.filter_func]",
"srcdir/filter_code.rst:43: WARNING: malformed function signature: 'own_filter_code(' [needs.filter_func]",
"srcdir/filter_code.rst:39: WARNING: malformed function signature: 'my_pie_filter_code(' [needs.filter_func]",
"srcdir/filter_code.rst:48: WARNING: malformed function signature: 'my_pie_filter_code(' [needs.filter_func]",
"WARNING: variant_not_equal_current_variant: failed",
"\t\tfailed needs: 1 (extern_filter_story_002)",
"\t\tused filter: variant != current_variant [needs.warnings]",
]

index_html = Path(app.outdir, "index.html").read_text()
filter_code = Path(app.outdir, "filter_code.html").read_text()

# Check need_count works
assert "The amount of needs that belong to current variants: 6" in index_html
Expand All @@ -45,6 +48,10 @@ def test_doc_needs_filter_data_html(test_app):
'<td class="needs_tags"><p>my_tag<em>; </em>current_variant</p></td>'
in index_html
)
assert (
'<span class="caption-text">Filter code func table with multiple dots filter function path</span>'
in filter_code
)

# check needflow works
if int(doc_ver.split(".")[1]) >= 18:
Expand All @@ -58,7 +65,14 @@ def test_doc_needs_filter_data_html(test_app):

# check needpie works
assert '<img alt="_images/need_pie_dba00.svg" id="needpie-index-0"' in index_html

assert (
'<img alt="_images/need_pie_446e9.svg" id="needpie-filter_code-0"'
in filter_code
)
assert (
'<img alt="_images/need_pie_fac86.svg" id="needpie-filter_code-1"'
in filter_code
)
# check needextend works
assert (
'<span class="needs_tags"><span class="needs_label">tags: </span>'
Expand Down

0 comments on commit df74963

Please sign in to comment.