-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR - Add 'hide' support and a new meta-data option to List2need directive #1345
Open
christopheseyler
wants to merge
8
commits into
useblocks:master
Choose a base branch
from
christopheseyler:list2need-add-support-for-hide-and-new-meta-data
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f9580db
add hide and meta-data options
christopheseyler 8add581
Add documentation about bith new options
christopheseyler 9f0939a
Remove forgotten log message
christopheseyler 0079b81
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f4ec1a9
Rename meta-data to list_global_options and remove unneeded code
a82427d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 44dfc2b
Fix some bugs and add tests
a25760e
add a test description
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,7 +2,7 @@ | |||||
name = "sphinx-needs" | ||||||
|
||||||
# !! Don't miss updates in sphinx_needs.__version__, changelog.rst, and .github/workflows/docker !!! | ||||||
version = "4.1.0" | ||||||
version = "4.2.0" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
you don't need to change the version in a PR |
||||||
|
||||||
description = "Sphinx needs extension for managing needs/requirements and specifications" | ||||||
authors = ["team useblocks <[email protected]>"] | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
extensions = ["sphinx_needs"] | ||
project = "test for list2need hide" | ||
author = 'Christophe SEYLER' | ||
|
||
needs_table_style = "TABLE" | ||
|
||
needs_id_regex = "^[A-Za-z0-9_]" | ||
|
||
needs_types = [ | ||
{ | ||
"directive": "story", | ||
"title": "User Story", | ||
"prefix": "US_", | ||
"color": "#BFD8D2", | ||
"style": "node", | ||
}, | ||
{ | ||
"directive": "spec", | ||
"title": "Specification", | ||
"prefix": "SP_", | ||
"color": "#FEDCD2", | ||
"style": "node", | ||
}, | ||
{ | ||
"directive": "impl", | ||
"title": "Implementation", | ||
"prefix": "IM_", | ||
"color": "#DF744A", | ||
"style": "node", | ||
}, | ||
{ | ||
"directive": "test", | ||
"title": "Test Case", | ||
"prefix": "TC_", | ||
"color": "#DCB239", | ||
"style": "node", | ||
}, | ||
] | ||
|
||
needs_extra_links = [ | ||
{"option": "checks", "incoming": "is checked by", "outgoing": "checks"}, | ||
{"option": "triggers", "incoming": "is triggered by", "outgoing": "triggers"}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
TEST DOCUMENT LIST2NEED | ||
======================= | ||
|
||
|
||
.. list2need:: | ||
:types: spec, spec | ||
:tags: tag1 | ||
:hide: | ||
|
||
* (NEED-A) Need example on level 1. fsdfsdf. ((status="closed",tags="tag2")) | ||
* (NEED-B) Link example ((status="closed",tags="tag2")) | ||
* (NEED-B-1) Need example on level 2 | ||
* (NEED-C) New line example. ((status="closed",tags="tag2")) | ||
With some content in the next line. | ||
|
||
|
||
|
||
List | ||
==== | ||
|
||
.. needtable:: Example table | ||
:tags: tag1 | ||
:style: table | ||
:columns: id | ||
:show_filters: | ||
|
||
|
||
.. _test: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
extensions = ["sphinx_needs", "sphinxcontrib.plantuml"] | ||
project = "test for list2need list_global_options" | ||
author = 'Christophe SEYLER' | ||
|
||
needs_table_style = "TABLE" | ||
|
||
needs_id_regex = "^[A-Za-z0-9_]" | ||
|
||
needs_types = [ | ||
{ | ||
"directive": "story", | ||
"title": "User Story", | ||
"prefix": "US_", | ||
"color": "#BFD8D2", | ||
"style": "node", | ||
}, | ||
{ | ||
"directive": "spec", | ||
"title": "Specification", | ||
"prefix": "SP_", | ||
"color": "#FEDCD2", | ||
"style": "node", | ||
}, | ||
{ | ||
"directive": "impl", | ||
"title": "Implementation", | ||
"prefix": "IM_", | ||
"color": "#DF744A", | ||
"style": "node", | ||
}, | ||
{ | ||
"directive": "test", | ||
"title": "Test Case", | ||
"prefix": "TC_", | ||
"color": "#DCB239", | ||
"style": "node", | ||
}, | ||
] | ||
|
||
needs_extra_links = [ | ||
{"option": "checks", "incoming": "is checked by", "outgoing": "checks"}, | ||
{"option": "triggers", "incoming": "is triggered by", "outgoing": "triggers"}, | ||
] | ||
needs_extra_options = [ | ||
"aggregateoption" | ||
] |
16 changes: 16 additions & 0 deletions
16
tests/doc_test/doc_list2need_list_global_options/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
TEST DOCUMENT LIST2NEED | ||
======================= | ||
|
||
|
||
.. list2need:: | ||
:types: spec, spec | ||
:list_global_options: status="open", aggregateoption="SomeValue" | ||
|
||
* (NEED-A) Need example on level 1 | ||
* (NEED-B) Need example on level 1 | ||
* (NEED-C) Link example | ||
* (NEED-C-1) Need example on level 2 | ||
* (NEED-D) New line example. ((aggregateoption="OtherValue")) | ||
With some content in the next line. | ||
|
||
.. _test: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
import json | ||
|
||
from sphinx_needs.api import get_needs_view | ||
|
||
|
||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_app", | ||
[{"buildername": "html", "srcdir": "doc_test/doc_list2need_hide"}], | ||
indirect=True, | ||
) | ||
def test_doc_list2need_hide(test_app, snapshot): | ||
""" | ||
The test validates the list2need directive with the hide option. | ||
The needs must be valid, but the rendered output must not contain the need content. | ||
|
||
To validate that the needs are valid, the needs are rendered using a needtable directive. | ||
""" | ||
app = test_app | ||
app.build() | ||
|
||
|
||
|
||
index_html = Path(app.outdir, "index.html").read_text() | ||
assert '<tr class="need row-even"><td class="needs_id"><p><a class="reference internal" href="#NEED-A">NEED-A</a></p></td>' in index_html | ||
assert '<tr class="need row-odd"><td class="needs_id"><p><a class="reference internal" href="#NEED-B">NEED-B</a></p></td>' in index_html | ||
assert '<tr class="need row-even"><td class="needs_id"><p><a class="reference internal" href="#NEED-C">NEED-C</a></p></td>' in index_html | ||
|
||
|
||
assert 'class="need_container docutils container"' not in index_html | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
import json | ||
|
||
from sphinx_needs.api import get_needs_view | ||
|
||
|
||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_app", | ||
[ | ||
{ | ||
"buildername": "needs", | ||
"srcdir": "doc_test/doc_list2need_list_global_options", | ||
"confoverrides": {"needs_reproducible_json": True}, | ||
} | ||
], | ||
indirect=True, | ||
) | ||
def test_doc_list2need_list_global_options(test_app, snapshot): | ||
app = test_app | ||
app.build() | ||
|
||
needs_list = json.loads(Path(app.outdir, "needs.json").read_text()) | ||
|
||
needs = needs_list["versions"][""]["needs"] | ||
|
||
# Check that all entries have a status item equal to "open" | ||
for need_id, need in needs.items(): | ||
assert need.get("status") == "open", f"Need {need_id} does not have status 'open'" | ||
assert "SomeValue" in need.get("aggregateoption", ""), f"Need {need_id} does not have 'SomeValue' in aggregateoption" | ||
|
||
# Check that NEED-D has "OtherValue" in its aggregateoption | ||
need_d = needs.get("NEED-D") | ||
assert need_d is not None, "NEED-D is missing" | ||
assert "OtherValue" in need_d.get("aggregateoption", ""), "NEED-D does not have 'OtherValue' in aggregateoption" | ||
|
||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should rename
meta-data
to something withglobal
oroption
in the name because we already haveneeds_global_options
as a config parameter, which does something similar: setting values globally for specific needs.That's the same here.
So, what about naming the parameter just
global
?`There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to stay in the same mind, I've renamed to list_global_options