strictdoc icon indicating copy to clipboard operation
strictdoc copied to clipboard

Custom grammar without STATEMENT field causes exception

Open haxtibal opened this issue 1 year ago • 0 comments

StrictDocs custom grammar feature makes it quite versatile. One can not only document requirements, but also design elements, threats from threat modelling, test cases, and so on.

I defined a THREAT tag, notably without a STATEMENT field as it wouldn't have meaning in that context.

[GRAMMAR]
ELEMENTS:
- TAG: THREAT
  FIELDS:
  - TITLE: UID
    TYPE: String
    REQUIRED: TRUE
  - TITLE: TITLE
    TYPE: String
    REQUIRED: TRUE
  - TITLE: DESCRIPTION
    TYPE: String
    REQUIRED: False
  - TITLE: SEVERITY
    TYPE: SingleChoice(Low, Medium, High)
    REQUIRED: TRUE
  - TITLE: SCORE
    TYPE: String
    REQUIRED: False

With such a grammar strictdoc export (version 0.0.55) raises an exception

...
  File "/home/tdmg/.local/pipx/venvs/strictdoc/lib/python3.11/site-packages/strictdoc/backend/sdoc/models/node.py", line 459, in enumerate_meta_fields
    statement_field_index = grammar_field_titles.index(
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: 'STATEMENT' is not in list

because SDocNode.enumerate_meta_fields depends on the STATEMENT field to encode a convention that says "each field before STATEMENT is a single line field".

Would it be possible to find a different convention and remove that hard coded dependency on STATEMENT, to support use cases where STATEMENT doesn't make sense?

haxtibal avatar May 18 '24 21:05 haxtibal