From 6b1a18b2469ecc2f5252f7753ae54c39b6457a3c Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Wed, 20 Sep 2023 21:26:13 +0200 Subject: [PATCH] sdoc/grammar: introduce REFS/RELATIONS/ROLES --- docs/strictdoc_20_requirements.sdoc | 66 +- docs/strictdoc_21_design.sdoc | 6 +- strictdoc/__init__.py | 2 +- .../excel/import_/excel_to_sdoc_converter.py | 42 +- .../reqif/p01_sdoc/reqif_to_sdoc_converter.py | 4 +- .../p11_polarion/reqif_to_sdoc_converter.py | 4 +- strictdoc/backend/reqif/sdoc_reqif_fields.py | 2 +- strictdoc/backend/sdoc/grammar/grammar.py | 22 + strictdoc/backend/sdoc/grammar/type_system.py | 2 +- strictdoc/backend/sdoc/models/constants.py | 6 + .../backend/sdoc/models/document_grammar.py | 53 +- strictdoc/backend/sdoc/models/reference.py | 10 +- strictdoc/backend/sdoc/models/type_system.py | 97 +- .../backend/sdoc/validations/requirement.py | 54 +- strictdoc/backend/sdoc/writer.py | 122 +- .../document_grammar_form_object.py | 2 +- .../frame_document_grammar_edit.jinja.html | 2 + strictdoc/server/routers/main_router.py | 2 +- .../__init__.py | 0 .../expected_output/Document_1.sdoc | 0 .../expected_output/dummy.txt | 0 .../expected_output/strictdoc.toml | 0 .../input/dummy.txt | 0 .../input/strictdoc.toml | 0 .../sample.reqif | 10 +- .../test_case.py} | 0 .../sample.reqif | 20 +- .../expected_output/document.sdoc | 5 +- .../expected_output/document.sdoc | 5 +- .../edit_grammar_add_new_field/__init__.py | 0 .../expected_output/document.sdoc | 5 +- .../input/document.sdoc | 0 .../test_case.py | 0 .../expected_output/document.sdoc | 5 +- .../expected_output/document.sdoc | 5 +- .../expected_output/document.sdoc | 5 +- .../expected_output/document.sdoc | 5 +- .../expected_output/document.sdoc | 2 + .../expected_output/document.sdoc | 6 +- .../expected_output/document.sdoc | 8 +- .../expected_output/document.sdoc | 6 +- .../input/document.sdoc | 6 +- .../input/document2.sdoc | 6 +- .../input/document.sdoc | 6 +- .../expected_output/document.sdoc | 6 +- .../input/document.sdoc | 6 +- .../expected/expected.sdoc | 7 +- .../p01_sdoc/end_to_end/13_refs/sample.sdoc | 2 +- .../end_to_end/30_custom_grammar/sample.sdoc | 2 + .../sample.sdoc | 2 + .../sample.sdoc | 2 + .../reqif/02_user_provided_example/script.py | 2 +- tests/unit/helpers/test_document_builder.py | 2 +- .../backend/sdoc/test_dsl_passthrough.py | 1105 +++------------- .../sdoc/test_dsl_passthrough_grammar.py | 1162 +++++++++++++++++ .../backend/sdoc/test_dsl_passthrough_refs.py | 226 ++++ 56 files changed, 1984 insertions(+), 1143 deletions(-) rename tests/end2end/{screens/document/edit_document_grammar/edit_grammar_add_field => project_index/import_document_from_reqif/import_document_default_import}/__init__.py (100%) rename tests/end2end/project_index/import_document_from_reqif/{UC55_T01_default_import => import_document_default_import}/expected_output/Document_1.sdoc (100%) rename tests/end2end/project_index/import_document_from_reqif/{UC55_T01_default_import => import_document_default_import}/expected_output/dummy.txt (100%) rename tests/end2end/project_index/import_document_from_reqif/{UC55_T01_default_import => import_document_default_import}/expected_output/strictdoc.toml (100%) rename tests/end2end/project_index/import_document_from_reqif/{UC55_T01_default_import => import_document_default_import}/input/dummy.txt (100%) rename tests/end2end/project_index/import_document_from_reqif/{UC55_T01_default_import => import_document_default_import}/input/strictdoc.toml (100%) rename tests/end2end/project_index/import_document_from_reqif/{UC55_T01_default_import => import_document_default_import}/sample.reqif (100%) rename tests/end2end/project_index/import_document_from_reqif/{UC55_T01_default_import/test_UC55_T01_default_import.py => import_document_default_import/test_case.py} (100%) create mode 100644 tests/end2end/screens/document/edit_document_grammar/edit_grammar_add_new_field/__init__.py rename tests/end2end/screens/document/edit_document_grammar/{edit_grammar_add_field => edit_grammar_add_new_field}/expected_output/document.sdoc (92%) rename tests/end2end/screens/document/edit_document_grammar/{edit_grammar_add_field => edit_grammar_add_new_field}/input/document.sdoc (100%) rename tests/end2end/screens/document/edit_document_grammar/{edit_grammar_add_field => edit_grammar_add_new_field}/test_case.py (100%) create mode 100644 tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough_grammar.py create mode 100644 tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough_refs.py diff --git a/docs/strictdoc_20_requirements.sdoc b/docs/strictdoc_20_requirements.sdoc index c8901651f..53eb90986 100644 --- a/docs/strictdoc_20_requirements.sdoc +++ b/docs/strictdoc_20_requirements.sdoc @@ -11,9 +11,6 @@ ELEMENTS: - TITLE: UID TYPE: String REQUIRED: False - - TITLE: REFS - TYPE: String - REQUIRED: False - TITLE: TITLE TYPE: String REQUIRED: True @@ -26,6 +23,9 @@ ELEMENTS: - TITLE: COMMENT TYPE: String REQUIRED: False + RELATIONS: + - TYPE: Parent + - TYPE: File [FREETEXT] This document is a collection of high-level requirements for StrictDoc as well as some of its middle-level requirements. The existing requirements set is pending a proper functional decomposition/partitioning following the creation of bidirectional traces between the requirements and StrictDoc's source code. @@ -36,13 +36,13 @@ TITLE: High-level requirements [REQUIREMENT] UID: SDOC-HIGH-REQS-MANAGEMENT -REFS: -- TYPE: Parent - VALUE: GOAL-1-TOOL-SUPPORT TITLE: Requirements management STATEMENT: >>> StrictDoc shall enable requirements management. <<< +REFS: +- TYPE: Parent + VALUE: GOAL-1-TOOL-SUPPORT [REQUIREMENT] UID: SDOC-HIGH-DATA-MODEL @@ -127,11 +127,6 @@ TITLE: Data model [REQUIREMENT] UID: SDOC-DM-MODEL -REFS: -- TYPE: Parent - VALUE: SDOC-HIGH-REQS-MANAGEMENT -- TYPE: Parent - VALUE: SDOC-HIGH-DATA-MODEL TITLE: Modeling capability STATEMENT: StrictDoc's Data Model shall accommodate for maximum possible standard requirement document formats. COMMENT: >>> @@ -140,6 +135,11 @@ Examples of standard requirements documents include but are not limited to: - Non-nested requirement lists split by categories (e.g., Functional Requirements, Interface Requirements, Performance Requirements, etc.) <<< +REFS: +- TYPE: Parent + VALUE: SDOC-HIGH-REQS-MANAGEMENT +- TYPE: Parent + VALUE: SDOC-HIGH-DATA-MODEL [SECTION] TITLE: Project @@ -281,24 +281,24 @@ TITLE: SDoc file format [REQUIREMENT] UID: SDOC-FMT-PRIMARY +TITLE: Primary text implementation +STATEMENT: The SDoc format shall support encoding the Strict Doc Data Model in a plain-text human readable form. REFS: - TYPE: Parent VALUE: SDOC-DM-MODEL -TITLE: Primary text implementation -STATEMENT: The SDoc format shall support encoding the Strict Doc Data Model in a plain-text human readable form. [SECTION] TITLE: Grammar [REQUIREMENT] UID: SDOC-FMT-GRAMMAR +TITLE: Grammar +STATEMENT: The SDoc format shall be based on a fixed grammar. REFS: - TYPE: Parent VALUE: SDOC-HIGH-DATA-MODEL - TYPE: File VALUE: strictdoc/backend/sdoc/grammar/grammar.py -TITLE: Grammar -STATEMENT: The SDoc format shall be based on a fixed grammar. [REQUIREMENT] TITLE: No indentation @@ -346,18 +346,18 @@ TITLE: Single document: Tabular form STATEMENT: StrictDoc shall export single document pages in a tabular form. [REQUIREMENT] +TITLE: Single document: 1-level traceability +STATEMENT: StrictDoc shall export 1-level traceability document. REFS: - TYPE: Parent VALUE: SDOC-HIGH-REQS-TRACEABILITY -TITLE: Single document: 1-level traceability -STATEMENT: StrictDoc shall export 1-level traceability document. [REQUIREMENT] +TITLE: Single document: Deep traceability +STATEMENT: StrictDoc shall export deep traceability document. REFS: - TYPE: Parent VALUE: SDOC-HIGH-REQS-TRACEABILITY -TITLE: Single document: Deep traceability -STATEMENT: StrictDoc shall export deep traceability document. [REQUIREMENT] TITLE: Left panel: Table of contents @@ -376,11 +376,11 @@ STATEMENT: StrictDoc shall support exporting documents to Sphinx/RST format. [REQUIREMENT] UID: SDOC-GEN-EXCEL-EXPORT +TITLE: Excel Export +STATEMENT: StrictDoc shall support exporting documents to Excel format. REFS: - TYPE: File VALUE: strictdoc/backend/excel/export/excel_generator.py -TITLE: Excel Export -STATEMENT: StrictDoc shall support exporting documents to Excel format. [REQUIREMENT] TITLE: ReqIF import/export @@ -393,15 +393,19 @@ TITLE: Validation [REQUIREMENT] UID: SDOC-VALIDATION-UNIQUE-UID -REFS: -- TYPE: Parent - VALUE: SDOC-HIGH-VALIDATION TITLE: Uniqueness of UID identifiers in a document tree STATEMENT: StrictDoc shall ensure that each UID used in a document tree is unique. COMMENT: This is implemented but the error message shall be made more readable. +REFS: +- TYPE: Parent + VALUE: SDOC-HIGH-VALIDATION [REQUIREMENT] UID: SDOC-VALIDATION-NO-CYCLES +TITLE: No cycles in a document tree +STATEMENT: >>> +StrictDoc shall ensure that no requirements in document tree reference each other. +<<< REFS: - TYPE: Parent VALUE: SDOC-HIGH-VALIDATION @@ -409,19 +413,15 @@ REFS: VALUE: strictdoc/core/tree_cycle_detector.py - TYPE: File VALUE: strictdoc/core/traceability_index_builder.py -TITLE: No cycles in a document tree -STATEMENT: >>> -StrictDoc shall ensure that no requirements in document tree reference each other. -<<< [REQUIREMENT] UID: SDOC-VALIDATION-VALID-HTML -REFS: -- TYPE: Parent - VALUE: SDOC-HIGH-VALIDATION TITLE: Valid HTML markup STATEMENT: StrictDoc's HTML export tests shall validate the generated HTML markup. COMMENT: First candidate: Table of contents and its nested ``