diff --git a/sphinx_needs/builder.py b/sphinx_needs/builder.py index e8e7ea21c..35158d0b3 100644 --- a/sphinx_needs/builder.py +++ b/sphinx_needs/builder.py @@ -117,12 +117,7 @@ def build_needs_json(app: Sphinx, _exception: Exception) -> None: if isinstance(app.builder, NeedsBuilder): return - try: - needs_builder = NeedsBuilder(app, env) - except TypeError: - needs_builder = NeedsBuilder(app) - needs_builder.set_environment(env) - + needs_builder = NeedsBuilder(app, env) needs_builder.finish() @@ -196,12 +191,8 @@ def build_needs_id_json(app: Sphinx, _exception: Exception) -> None: # Do not create an additional needs_json for every needs_id, if builder is already "needs_id". if isinstance(app.builder, NeedsIdBuilder): return - try: - needs_id_builder = NeedsIdBuilder(app, env) - except TypeError: - needs_id_builder = NeedsIdBuilder(app) - needs_id_builder.set_environment(env) + needs_id_builder = NeedsIdBuilder(app, env) needs_id_builder.finish() diff --git a/sphinx_needs/needsfile.json b/sphinx_needs/needsfile.json index a65453e4e..512c5026c 100644 --- a/sphinx_needs/needsfile.json +++ b/sphinx_needs/needsfile.json @@ -14,8 +14,7 @@ "type": "object", "properties": { "created": {"type": "string"}, - "filters": {"type": "object"}, - "filters_amount": {"type": "number"}, + "creator": {"type": "object"}, "needs": { "patternProperties": { "^.*$": { diff --git a/sphinx_needs/needsfile.py b/sphinx_needs/needsfile.py index c2d9a92c7..c3e65f986 100644 --- a/sphinx_needs/needsfile.py +++ b/sphinx_needs/needsfile.py @@ -129,12 +129,16 @@ def __init__( ) def update_or_add_version(self, version: str) -> None: + from sphinx_needs.needs import __version__ + if version not in self.needs_list["versions"].keys(): self.needs_list["versions"][version] = { "needs_amount": 0, "needs": {}, - "filters_amount": 0, - "filters": {}, + "creator": { + "program": "sphinx_needs", + "version": __version__, + }, } if self._schema: self.needs_list["versions"][version]["needs_schema"] = self._schema diff --git a/tests/__snapshots__/test_basic_doc.ambr b/tests/__snapshots__/test_basic_doc.ambr index 543c737ea..48b1eefa1 100644 --- a/tests/__snapshots__/test_basic_doc.ambr +++ b/tests/__snapshots__/test_basic_doc.ambr @@ -3,9 +3,6 @@ 'current_version': '0.1.0', 'versions': dict({ '0.1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'ST_001': dict({ 'arch': dict({ diff --git a/tests/__snapshots__/test_external.ambr b/tests/__snapshots__/test_external.ambr index 942552071..5a0034cec 100644 --- a/tests/__snapshots__/test_external.ambr +++ b/tests/__snapshots__/test_external.ambr @@ -3,9 +3,6 @@ 'current_version': '1.3', 'versions': dict({ '1.3': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'EXT_REQ_01': dict({ 'description': '', @@ -473,9 +470,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'EXT_TEST_01': dict({ 'arch': dict({ diff --git a/tests/__snapshots__/test_need_constraints.ambr b/tests/__snapshots__/test_need_constraints.ambr index b63a694b1..05ea8d5bb 100644 --- a/tests/__snapshots__/test_need_constraints.ambr +++ b/tests/__snapshots__/test_need_constraints.ambr @@ -3,9 +3,6 @@ 'current_version': '', 'versions': dict({ '': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'SECURITY_REQ': dict({ 'arch': dict({ diff --git a/tests/__snapshots__/test_needextend.ambr b/tests/__snapshots__/test_needextend.ambr index 40a4cd7c3..86924f063 100644 --- a/tests/__snapshots__/test_needextend.ambr +++ b/tests/__snapshots__/test_needextend.ambr @@ -3,9 +3,6 @@ 'current_version': '', 'versions': dict({ '': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'REQ_1': dict({ 'arch': dict({ @@ -795,9 +792,6 @@ 'current_version': '', 'versions': dict({ '': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'extend_test_003': dict({ 'arch': dict({ diff --git a/tests/__snapshots__/test_needimport.ambr b/tests/__snapshots__/test_needimport.ambr index 7e2e5e47b..5a94e8b8e 100644 --- a/tests/__snapshots__/test_needimport.ambr +++ b/tests/__snapshots__/test_needimport.ambr @@ -3,9 +3,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'IMPL_01': dict({ 'description': 'Incoming links of this spec: :need_incoming:`IMPL_01`.', diff --git a/tests/__snapshots__/test_needs_builder.ambr b/tests/__snapshots__/test_needs_builder.ambr index 4bc9fdaf7..1adc9d5b0 100644 --- a/tests/__snapshots__/test_needs_builder.ambr +++ b/tests/__snapshots__/test_needs_builder.ambr @@ -3,9 +3,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'TC_001': dict({ 'arch': dict({ @@ -816,9 +813,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'TC_001': dict({ 'description': '', @@ -1473,9 +1467,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'TC_001': dict({ 'arch': dict({ diff --git a/tests/__snapshots__/test_needs_id_builder.ambr b/tests/__snapshots__/test_needs_id_builder.ambr index 55c14b278..4e339064e 100644 --- a/tests/__snapshots__/test_needs_id_builder.ambr +++ b/tests/__snapshots__/test_needs_id_builder.ambr @@ -4,9 +4,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'TC_001': dict({ 'arch': dict({ @@ -87,9 +84,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'TC_NEG_001': dict({ 'arch': dict({ @@ -170,9 +164,6 @@ 'current_version': '1.0', 'versions': dict({ '1.0': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'US_63252': dict({ 'arch': dict({ diff --git a/tests/__snapshots__/test_service_github.ambr b/tests/__snapshots__/test_service_github.ambr index 4999d8f94..6ec204420 100644 --- a/tests/__snapshots__/test_service_github.ambr +++ b/tests/__snapshots__/test_service_github.ambr @@ -3,9 +3,6 @@ 'current_version': '1', 'versions': dict({ '1': dict({ - 'filters': dict({ - }), - 'filters_amount': 0, 'needs': dict({ 'GITHUB_050bec': dict({ 'arch': dict({ diff --git a/tests/test_basic_doc.py b/tests/test_basic_doc.py index 7cf49a715..81d5a81e3 100644 --- a/tests/test_basic_doc.py +++ b/tests/test_basic_doc.py @@ -149,7 +149,7 @@ def test_build_needs(test_app: SphinxTestApp, snapshot): json_text = Path(app.outdir, "needs.json").read_text() needs_data = json.loads(json_text) - assert needs_data == snapshot(exclude=props("created", "project")) + assert needs_data == snapshot(exclude=props("created", "project", "creator")) # Test with needs_id_required=True and missing ids in docs. diff --git a/tests/test_external.py b/tests/test_external.py index 5a5438fce..37e40ed9a 100644 --- a/tests/test_external.py +++ b/tests/test_external.py @@ -47,7 +47,7 @@ def test_external_json(test_app: SphinxTestApp, snapshot): app.build() json_data = Path(app.outdir, "needs.json").read_text() needs = json.loads(json_data) - assert needs == snapshot(exclude=props("created", "project")) + assert needs == snapshot(exclude=props("created", "project", "creator")) def test_export_import_round_trip(tmp_path: Path, snapshot): @@ -136,4 +136,4 @@ def test_export_import_round_trip(tmp_path: Path, snapshot): json_data = json.loads(Path(str(app.outdir), "needs.json").read_text("utf8")) - assert json_data == snapshot(exclude=props("created", "project")) + assert json_data == snapshot(exclude=props("created", "project", "creator")) diff --git a/tests/test_need_constraints.py b/tests/test_need_constraints.py index 31004c2c0..febf8760f 100644 --- a/tests/test_need_constraints.py +++ b/tests/test_need_constraints.py @@ -19,7 +19,7 @@ def test_need_constraints(test_app, snapshot): json_text = Path(app.outdir, "needs.json").read_text() needs_data = json.loads(json_text) - assert needs_data == snapshot(exclude=props("created", "project")) + assert needs_data == snapshot(exclude=props("created", "project", "creator")) srcdir = Path(app.srcdir) out_dir = srcdir / "_build" diff --git a/tests/test_needextend.py b/tests/test_needextend.py index c81134260..630f40d32 100644 --- a/tests/test_needextend.py +++ b/tests/test_needextend.py @@ -19,7 +19,7 @@ def test_doc_needextend_html(test_app: Sphinx, snapshot): app.build() needs_data = json.loads(Path(app.outdir, "needs.json").read_text()) - assert needs_data == snapshot(exclude=props("created", "project")) + assert needs_data == snapshot(exclude=props("created", "project", "creator")) index_html = Path(app.outdir, "index.html").read_text() assert "extend_test_003" in index_html @@ -102,4 +102,4 @@ def test_doc_needextend_dynamic(test_app, snapshot): # assert app._warning.getvalue() == "" needs_data = json.loads(Path(app.outdir, "needs.json").read_text()) - assert needs_data == snapshot(exclude=props("created", "project")) + assert needs_data == snapshot(exclude=props("created", "project", "creator")) diff --git a/tests/test_needimport.py b/tests/test_needimport.py index bd0649a4f..8a0cd5fb5 100644 --- a/tests/test_needimport.py +++ b/tests/test_needimport.py @@ -141,7 +141,7 @@ def test_import_builder(test_app, snapshot): app.build() needs_text = Path(app.outdir, "needs.json").read_text() needs = json.loads(needs_text) - assert needs == snapshot(exclude=props("created", "project")) + assert needs == snapshot(exclude=props("created", "project", "creator")) @pytest.mark.parametrize( diff --git a/tests/test_needs_builder.py b/tests/test_needs_builder.py index 0de74900e..e0e9aaf54 100644 --- a/tests/test_needs_builder.py +++ b/tests/test_needs_builder.py @@ -17,7 +17,7 @@ def test_doc_needs_builder(test_app, snapshot): app.build() needs_list = json.loads(Path(app.outdir, "needs.json").read_text()) - assert needs_list == snapshot(exclude=props("created", "project")) + assert needs_list == snapshot(exclude=props("created", "project", "creator")) @pytest.mark.parametrize( @@ -36,7 +36,7 @@ def test_doc_needs_builder_reproducible(test_app, snapshot): app.build() needs_list = json.loads(Path(app.outdir, "needs.json").read_text()) - assert needs_list == snapshot(exclude=props("project")) + assert needs_list == snapshot(exclude=props("project", "creator")) @pytest.mark.parametrize( @@ -55,7 +55,7 @@ def test_doc_needs_builder_remove_defaults(test_app, snapshot): app.build() needs_list = json.loads(Path(app.outdir, "needs.json").read_text()) - assert needs_list == snapshot(exclude=props("created", "project")) + assert needs_list == snapshot(exclude=props("created", "project", "creator")) @pytest.mark.parametrize( diff --git a/tests/test_needs_id_builder.py b/tests/test_needs_id_builder.py index 7cf7d6972..5ae01a950 100644 --- a/tests/test_needs_id_builder.py +++ b/tests/test_needs_id_builder.py @@ -22,4 +22,4 @@ def test_doc_needs_id_builder(test_app, snapshot): data = { path.name: json.loads(path.read_text()) for path in needs_id_path.glob("*.json") } - assert data == snapshot(exclude=props("created", "project")) + assert data == snapshot(exclude=props("created", "project", "creator")) diff --git a/tests/test_service_github.py b/tests/test_service_github.py index 8055f8648..17b0539b0 100644 --- a/tests/test_service_github.py +++ b/tests/test_service_github.py @@ -97,7 +97,9 @@ def test_build(test_app, snapshot): assert warnings.splitlines() == expected_warnings needs_data = json.loads((Path(app.outdir) / "needs.json").read_text("utf8")) - assert needs_data == snapshot(exclude=props("created", "project", "avatar")) + assert needs_data == snapshot( + exclude=props("created", "project", "avatar", "creator") + ) ISSUE_RESPONSE = {