@@ -25,6 +25,7 @@ def __init__(
2525 parent : Optional ["DocumentGrammar" ],
2626 tag : str ,
2727 property_is_composite : str ,
28+ property_view_style : str ,
2829 fields : List [
2930 Union [
3031 GrammarElementFieldString ,
@@ -43,6 +44,20 @@ def __init__(
4344 if property_is_composite == ""
4445 else (property_is_composite == "True" )
4546 )
47+
48+ assert property_view_style in (
49+ "" ,
50+ "Plain" ,
51+ "Narrative" ,
52+ "Simple" ,
53+ "Inline" ,
54+ "Table" ,
55+ "Zebra" ,
56+ )
57+ self .property_view_style : Optional [str ] = (
58+ property_view_style .lower () if property_view_style != "" else None
59+ )
60+
4661 self .fields : List [
4762 Union [
4863 GrammarElementFieldString ,
@@ -76,9 +91,31 @@ def __init__(
7691 else :
7792 pass
7893 self .fields_map : Dict [str , GrammarElementField ] = fields_map
94+
95+ self .field_titles : List [str ] = list (
96+ map (lambda field__ : field__ .title , self .fields )
97+ )
98+
7999 self .content_field : Tuple [str , int ] = (
80100 statement_field or description_field or content_field or ("" , - 1 )
81101 )
102+
103+ # Some nodes have the content field, e.g., STATEMENT or DESCRIPTION,
104+ # some don't. For those that don't, use TITLE as a boundary between
105+ # the single-line and multiline.
106+ multiline_field_index = self .content_field [1 ]
107+ if multiline_field_index == - 1 :
108+ try :
109+ multiline_field_index = self .get_field_titles ().index ("TITLE" )
110+ except ValueError as value_error_ :
111+ raise RuntimeError (
112+ (
113+ f"The grammar element { self .tag } must have at least one of the "
114+ f"following fields: TITLE, STATEMENT, DESCRIPTION, CONTENT."
115+ ),
116+ ) from value_error_
117+ self .multiline_field_index : int = multiline_field_index
118+
82119 self .mid : MID = MID .create ()
83120 self .ng_line_start : Optional [int ] = None
84121 self .ng_col_start : Optional [int ] = None
@@ -89,6 +126,7 @@ def create_default(tag: str) -> "GrammarElement":
89126 parent = None ,
90127 tag = tag ,
91128 property_is_composite = "" ,
129+ property_view_style = "" ,
92130 fields = [
93131 GrammarElementFieldString (
94132 parent = None ,
@@ -135,18 +173,29 @@ def create_default_relations(
135173 ),
136174 ]
137175
176+ def is_field_multiline (self , field_name : str ) -> bool :
177+ field_index = self .field_titles .index (field_name )
178+ try :
179+ title_field_index = self .field_titles .index ("TITLE" )
180+ if field_index <= title_field_index :
181+ return False
182+ except ValueError :
183+ pass
184+ return field_index >= self .content_field [1 ]
185+
138186 def get_multiline_field_index (self ) -> int :
139- multiline_field_index = self .content_field [1 ]
140- assert multiline_field_index != - 1
141- return multiline_field_index
187+ return self .multiline_field_index
188+
189+ def get_view_style (self ) -> Optional [str ]:
190+ return self .property_view_style
142191
143192 def get_relation_types (self ) -> List [str ]:
144193 return list (
145194 map (lambda relation_ : relation_ .relation_type , self .relations )
146195 )
147196
148197 def get_field_titles (self ) -> List [str ]:
149- return list ( map ( lambda field_ : field_ . title , self .fields ))
198+ return self .field_titles
150199
151200 def get_tag_lower (self ) -> str :
152201 return self .tag .lower ()
@@ -284,6 +333,7 @@ def create_default(parent: Optional[SDocDocumentIF]) -> "DocumentGrammar":
284333 parent = None ,
285334 tag = "REQUIREMENT" ,
286335 property_is_composite = "" ,
336+ property_view_style = "" ,
287337 fields = fields ,
288338 relations = [],
289339 )
@@ -344,13 +394,13 @@ def create_for_test_report(parent: SDocDocumentIF) -> "DocumentGrammar":
344394 parent = None ,
345395 title = RequirementFieldName .STATUS ,
346396 human_title = None ,
347- required = "False " ,
397+ required = "True " ,
348398 ),
349399 GrammarElementFieldString (
350400 parent = None ,
351401 title = RequirementFieldName .TITLE ,
352402 human_title = None ,
353- required = "False " ,
403+ required = "True " ,
354404 ),
355405 GrammarElementFieldString (
356406 parent = None ,
@@ -363,6 +413,7 @@ def create_for_test_report(parent: SDocDocumentIF) -> "DocumentGrammar":
363413 parent = None ,
364414 tag = "TEST_RESULT" ,
365415 property_is_composite = "" ,
416+ property_view_style = "" ,
366417 fields = fields ,
367418 relations = [],
368419 )
@@ -463,6 +514,7 @@ def create_default_text_element(
463514 parent = parent ,
464515 tag = "TEXT" ,
465516 property_is_composite = "" ,
517+ property_view_style = "" ,
466518 fields = fields ,
467519 relations = [],
468520 )
0 commit comments