-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧪 Add test for
needreport
directive (#1105)
Currently there is no test for this directive, this PR adds one. This PR also fixes the directive: - Make the options flags - Change errors in the directive to emit warnings, rather than excepting the whole build - Allow for `template` to be specified as a directive option - Allow the the `dropdown` directive used in the default template, which requires an external sphinx extension, to be overriden using `needs_render_context = {"report_directive": "admonition"}` (I left the default as `dropdown`, so as not to introduce a breaking change)
- Loading branch information
1 parent
73b961e
commit 6abd389
Showing
7 changed files
with
91 additions
and
87 deletions.
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
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
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,5 @@ | ||
extensions = ["sphinx_needs"] | ||
needs_extra_options = ["other"] | ||
needs_render_context = { | ||
"report_directive": "admonition", | ||
} |
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,17 @@ | ||
Needs Report | ||
============ | ||
|
||
.. req:: Requirement 1 | ||
|
||
.. needreport:: | ||
|
||
.. needreport:: | ||
:types: | ||
:template: unknown.rst | ||
|
||
.. needreport:: | ||
:types: | ||
:links: | ||
:options: | ||
:usage: | ||
|
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,18 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("test_app", [{"buildername": "html", "srcdir": "doc_test/doc_needreport"}], indirect=True) | ||
def test_doc_needarch(test_app): | ||
app = test_app | ||
app.build() | ||
# check for warning about missing options | ||
warnings = app._warning.getvalue() | ||
assert "index.rst:6: WARNING: No options specified to generate need report [needs.report]" in warnings | ||
assert "index.rst:8: WARNING: Could not load needs report template file" in warnings | ||
html = Path(app.outdir, "index.html").read_text(encoding="utf8") | ||
assert "Need Types" in html | ||
assert "Need Extra Links" in html | ||
assert "Need Extra Options" in html | ||
assert "Need Metrics" in html |