diff --git a/strictdoc/backend/excel/import_/excel_to_sdoc_converter.py b/strictdoc/backend/excel/import_/excel_to_sdoc_converter.py index df5a11331..a8fddd1c7 100644 --- a/strictdoc/backend/excel/import_/excel_to_sdoc_converter.py +++ b/strictdoc/backend/excel/import_/excel_to_sdoc_converter.py @@ -185,7 +185,7 @@ def create_requirement( template_requirement = SDocObjectFactory.create_requirement( document, - requirement_type="REQUIREMENT", + node_type="REQUIREMENT", title=title, uid=uid, level=None, @@ -214,7 +214,7 @@ def create_requirement( template_requirement.relations = [reference] requirement = SDocNode( parent=template_requirement.parent, - requirement_type=template_requirement.requirement_type, + node_type=template_requirement.node_type, fields=list(template_requirement.enumerate_fields()), relations=template_requirement.relations, ) diff --git a/strictdoc/backend/reqif/p01_sdoc/reqif_to_sdoc_converter.py b/strictdoc/backend/reqif/p01_sdoc/reqif_to_sdoc_converter.py index 8d0b559db..eb667aa50 100644 --- a/strictdoc/backend/reqif/p01_sdoc/reqif_to_sdoc_converter.py +++ b/strictdoc/backend/reqif/p01_sdoc/reqif_to_sdoc_converter.py @@ -404,7 +404,7 @@ def create_section_from_spec_object( ) node: SDocNode = SDocNode( parent=section, - requirement_type="TEXT", + node_type="TEXT", fields=[node_field], relations=[], ) @@ -533,7 +533,7 @@ def create_requirement_from_spec_object( ) requirement = SDocNode( parent=parent_section, - requirement_type=grammar_element.tag, + node_type=grammar_element.tag, fields=fields, relations=[], ) diff --git a/strictdoc/backend/reqif/p01_sdoc/sdoc_to_reqif_converter.py b/strictdoc/backend/reqif/p01_sdoc/sdoc_to_reqif_converter.py index f34b7a28f..c1d97ddad 100644 --- a/strictdoc/backend/reqif/p01_sdoc/sdoc_to_reqif_converter.py +++ b/strictdoc/backend/reqif/p01_sdoc/sdoc_to_reqif_converter.py @@ -485,7 +485,7 @@ def _convert_requirement_to_spec_object( else: requirement_identifier = generate_unique_identifier("REQUIREMENT") - grammar_element = grammar.elements_by_type[requirement.requirement_type] + grammar_element = grammar.elements_by_type[requirement.node_type] attributes: List[SpecObjectAttribute] = [] for field in requirement.fields_as_parsed: @@ -574,7 +574,7 @@ def _convert_requirement_to_spec_object( spec_object_type: ReqIFSpecObjectType = ( context.map_grammar_node_tags_to_spec_object_type[ requirement.document - ][requirement.requirement_type] + ][requirement.node_type] ) spec_object = ReqIFSpecObject.create( identifier=requirement_identifier, diff --git a/strictdoc/backend/sdoc/error_handling.py b/strictdoc/backend/sdoc/error_handling.py index 4fafe50dd..fc090cfbd 100644 --- a/strictdoc/backend/sdoc/error_handling.py +++ b/strictdoc/backend/sdoc/error_handling.py @@ -36,9 +36,9 @@ def __init__( self.file_path = filename @staticmethod - def unknown_requirement_type(node: SDocNode, path_to_sdoc_file: str): + def unknown_node_type(node: SDocNode, path_to_sdoc_file: str): return StrictDocSemanticError( - title=f"Invalid requirement type: {node.requirement_type}.", + title=f"Invalid node type: {node.node_type}.", hint=None, example=None, line=node.ng_line_start, @@ -54,14 +54,12 @@ def unregistered_field( document_grammar: DocumentGrammar, path_to_sdoc_file: str, ): - grammar_dump = document_grammar.dump_fields( - requirement.requirement_type - ) + grammar_dump = document_grammar.dump_fields(requirement.node_type) return StrictDocSemanticError( title=f"Invalid requirement field: {field_name}", hint=( f"Compare with the document grammar: [{grammar_dump}] " - f"for type: {requirement.requirement_type}." + f"for type: {requirement.node_type}." ), example=None, line=requirement.ng_line_start, @@ -76,7 +74,7 @@ def missing_required_field( document_grammar: DocumentGrammar, path_to_sdoc_file: str, ): - grammar_fields = document_grammar.dump_fields(node.requirement_type) + grammar_fields = document_grammar.dump_fields(node.node_type) return StrictDocSemanticError( title=( f"Requirement is missing a field that is required by " @@ -99,7 +97,7 @@ def unexpected_field_outside_grammar( document_grammar: DocumentGrammar, path_to_sdoc_file: str, ): - grammar_fields = document_grammar.dump_fields(node.requirement_type) + grammar_fields = document_grammar.dump_fields(node.node_type) return StrictDocSemanticError( title=( f"Unexpected field outside grammar: " @@ -126,13 +124,13 @@ def wrong_field_order( problematic_field, SDocNodeField ), f"{problematic_field}" requirement_dump = node.dump_fields_as_parsed() - grammar_dump = document_grammar.dump_fields(node.requirement_type) + grammar_dump = document_grammar.dump_fields(node.node_type) return StrictDocSemanticError( title=f"Wrong field order for requirement: [{requirement_dump}].", hint=( f"Problematic field: {problematic_field.field_name}. " f"Compare with the document grammar: [{grammar_dump}] " - f"for type: {node.requirement_type}." + f"for type: {node.node_type}." ), example=None, line=node.ng_line_start, @@ -156,9 +154,9 @@ def invalid_choice_field( f"Problematic field: {requirement_field.field_name}. " f"Compare with the document grammar: " f"[" - f"{document_grammar.dump_fields(node.requirement_type)}" + f"{document_grammar.dump_fields(node.node_type)}" f"] " - f"for type: {node.requirement_type}." + f"for type: {node.node_type}." ), example=None, line=node.ng_line_start, @@ -182,9 +180,9 @@ def invalid_multiple_choice_field( f"Problematic field: {requirement_field.field_name}. " f"Compare with the document grammar: " f"[" - f"{document_grammar.dump_fields(node.requirement_type)}" + f"{document_grammar.dump_fields(node.node_type)}" f"] " - f"for type: {node.requirement_type}." + f"for type: {node.node_type}." ), example=None, line=node.ng_line_start, diff --git a/strictdoc/backend/sdoc/grammar/grammar.py b/strictdoc/backend/sdoc/grammar/grammar.py index 201b7265b..7865e40a4 100644 --- a/strictdoc/backend/sdoc/grammar/grammar.py +++ b/strictdoc/backend/sdoc/grammar/grammar.py @@ -174,7 +174,7 @@ ; SDocNode[noskipws]: - '[' !'SECTION' !SDocCompositeNodeTagName requirement_type = RequirementType ']' '\n' + '[' !'SECTION' !SDocCompositeNodeTagName node_type = RequirementType ']' '\n' fields *= SDocNodeField ( 'RELATIONS:' '\n' @@ -210,7 +210,7 @@ ; SDocCompositeNode[noskipws]: - '[COMPOSITE_' requirement_type = RequirementType ']' '\n' + '[COMPOSITE_' node_type = RequirementType ']' '\n' fields *= SDocNodeField ( diff --git a/strictdoc/backend/sdoc/models/document.py b/strictdoc/backend/sdoc/models/document.py index d952842a3..15c6ef45d 100644 --- a/strictdoc/backend/sdoc/models/document.py +++ b/strictdoc/backend/sdoc/models/document.py @@ -151,7 +151,7 @@ def has_any_requirements(self) -> bool: return True continue if section_or_requirement.is_requirement: - if section_or_requirement.requirement_type == "TEXT": + if section_or_requirement.node_type == "TEXT": continue return True assert section_or_requirement.is_section, section_or_requirement diff --git a/strictdoc/backend/sdoc/models/document_grammar.py b/strictdoc/backend/sdoc/models/document_grammar.py index c36a30b64..7903e7f8d 100644 --- a/strictdoc/backend/sdoc/models/document_grammar.py +++ b/strictdoc/backend/sdoc/models/document_grammar.py @@ -294,12 +294,12 @@ def get_element_by_mid(self, element_mid: str): f"Could not find a grammar element with MID: {element_mid}" ) - def dump_fields(self, requirement_type) -> str: + def dump_fields(self, node_type) -> str: return ", ".join( list( map( lambda g: g.title, - self.elements_by_type[requirement_type].fields, + self.elements_by_type[node_type].fields, ) ) ) diff --git a/strictdoc/backend/sdoc/models/document_view.py b/strictdoc/backend/sdoc/models/document_view.py index c0d44870a..86b228852 100644 --- a/strictdoc/backend/sdoc/models/document_view.py +++ b/strictdoc/backend/sdoc/models/document_view.py @@ -25,9 +25,9 @@ def __init__( self.hidden_tags: Optional[List[ViewElementHiddenTag]] = hidden_tags self.name: Optional[str] = name - def includes_field(self, requirement_type: str, field_name: str) -> bool: + def includes_field(self, node_type: str, field_name: str) -> bool: for tag_ in self.tags: - if tag_.object_type == requirement_type: + if tag_.object_type == node_type: field_: ViewElementField for field_ in tag_.visible_fields: if field_.name == field_name: @@ -43,7 +43,7 @@ class DefaultViewElement(ViewElement): works fine for now. """ - def includes_field(self, requirement_type: str, field_name: str) -> bool: # noqa: ARG002 + def includes_field(self, node_type: str, field_name: str) -> bool: # noqa: ARG002 return True diff --git a/strictdoc/backend/sdoc/models/node.py b/strictdoc/backend/sdoc/models/node.py index dd77427c7..13d407437 100644 --- a/strictdoc/backend/sdoc/models/node.py +++ b/strictdoc/backend/sdoc/models/node.py @@ -97,21 +97,21 @@ class SDocNode(SDocObject): def __init__( self, parent: Union[SDocDocument, SDocSection, "SDocCompositeNode"], - requirement_type: str, + node_type: str, fields: List[SDocNodeField], relations: List[Reference], requirements: Optional[List["SDocNode"]] = None, basic_free_text: bool = False, ) -> None: assert parent - assert isinstance(requirement_type, str) + assert isinstance(node_type, str) assert isinstance(relations, list), relations self.parent: Union[SDocDocument, SDocSection, SDocCompositeNode] = ( parent ) - self.requirement_type: str = requirement_type + self.node_type: str = node_type ordered_fields_lookup: OrderedDict[str, List[SDocNodeField]] = ( OrderedDict() @@ -178,17 +178,17 @@ def get_type_string() -> str: return "requirement" def get_node_type_string(self) -> Optional[str]: - return self.requirement_type + return self.node_type def get_node_type_string_lower(self) -> Optional[str]: - return self.requirement_type.lower() + return self.node_type.lower() def get_display_title(self) -> str: if self.reserved_title is not None: return self.reserved_title if self.reserved_uid is not None: return self.reserved_uid - return f"{self.requirement_type} with no title/UID" + return f"{self.node_type} with no title/UID" @property def is_root_included_document(self) -> bool: @@ -233,14 +233,14 @@ def reserved_title(self) -> Optional[str]: def has_reserved_statement(self) -> bool: element: GrammarElement = self.document.grammar.elements_by_type[ - self.requirement_type + self.node_type ] return element.content_field[0] in self.ordered_fields_lookup @property def reserved_statement(self) -> Optional[str]: element: GrammarElement = self.document.grammar.elements_by_type[ - self.requirement_type + self.node_type ] return self._get_cached_field( element.content_field[0], singleline_only=False @@ -259,7 +259,7 @@ def is_requirement(self) -> bool: return True def is_text_node(self) -> bool: - return self.requirement_type == "TEXT" + return self.node_type == "TEXT" # FIXME: Remove @property. @property @@ -335,13 +335,13 @@ def get_requirement_style_mode(self) -> str: def get_content_field_name(self) -> str: element: GrammarElement = self.document.grammar.elements_by_type[ - self.requirement_type + self.node_type ] return element.content_field[0] def get_content_field(self) -> SDocNodeField: element: GrammarElement = self.document.grammar.elements_by_type[ - self.requirement_type + self.node_type ] return self.ordered_fields_lookup[element.content_field[0]][0] @@ -456,7 +456,7 @@ def enumerate_meta_fields( self, skip_single_lines: bool = False, skip_multi_lines: bool = False ) -> Generator[Tuple[str, SDocNodeField], None, None]: element: GrammarElement = self.document.grammar.elements_by_type[ - self.requirement_type + self.node_type ] grammar_field_titles = list(map(lambda f: f.title, element.fields)) statement_field_index: int = element.content_field[1] @@ -489,14 +489,14 @@ def get_meta_field_value_by_title(self, field_title: str) -> Optional[str]: def get_field_human_title(self, field_name: str) -> str: element: GrammarElement = self.document.grammar.elements_by_type[ - self.requirement_type + self.node_type ] field_human_title = element.fields_map[field_name] return field_human_title.get_field_human_name() def get_field_human_title_for_statement(self) -> str: element: GrammarElement = self.document.grammar.elements_by_type[ - self.requirement_type + self.node_type ] field_human_title = element.fields_map[element.content_field[0]] return field_human_title.get_field_human_name() @@ -567,9 +567,7 @@ def set_field_value( assert grammar_or_none is not None grammar: DocumentGrammar = grammar_or_none - element: GrammarElement = grammar.elements_by_type[ - self.requirement_type - ] + element: GrammarElement = grammar.elements_by_type[self.node_type] grammar_field_titles = list(map(lambda f: f.title, element.fields)) field_index = grammar_field_titles.index(field_name) diff --git a/strictdoc/backend/sdoc/models/object_factory.py b/strictdoc/backend/sdoc/models/object_factory.py index 136039cf8..d0ed1aa5e 100644 --- a/strictdoc/backend/sdoc/models/object_factory.py +++ b/strictdoc/backend/sdoc/models/object_factory.py @@ -23,7 +23,7 @@ def create_document(title: Optional[str]): @staticmethod def create_requirement( parent, - requirement_type: Optional[str] = "REQUIREMENT", + node_type: Optional[str] = "REQUIREMENT", uid: Optional[str] = None, level: Optional[str] = None, title: Optional[str] = None, @@ -127,7 +127,7 @@ def create_requirement( ) requirement = SDocNode( parent=parent, - requirement_type=requirement_type, + node_type=node_type, fields=fields, relations=[], ) @@ -175,7 +175,7 @@ def create_requirement_from_dict(requirement_dict, parent, level): requirement = SDocObjectFactory.create_requirement( parent=parent, - requirement_type="REQUIREMENT", + node_type="REQUIREMENT", uid=uid, level=None, title=title, diff --git a/strictdoc/backend/sdoc/processor.py b/strictdoc/backend/sdoc/processor.py index 2cc91c614..cc5c7be7e 100644 --- a/strictdoc/backend/sdoc/processor.py +++ b/strictdoc/backend/sdoc/processor.py @@ -71,7 +71,7 @@ def rewrite_free_text_to_text_node_if_needed( ] text_node = SDocNode( parent=parent_node, - requirement_type="TEXT", + node_type="TEXT", fields=fields, relations=[], requirements=None, diff --git a/strictdoc/backend/sdoc/validations/sdoc_validator.py b/strictdoc/backend/sdoc/validations/sdoc_validator.py index 299331d9a..5fb8bdf95 100644 --- a/strictdoc/backend/sdoc/validations/sdoc_validator.py +++ b/strictdoc/backend/sdoc/validations/sdoc_validator.py @@ -158,16 +158,13 @@ def validate_node( path_to_sdoc_file: str, auto_uid_mode: bool = True, ): - if ( - requirement.requirement_type - not in document_grammar.registered_elements - ): - raise StrictDocSemanticError.unknown_requirement_type( + if requirement.node_type not in document_grammar.registered_elements: + raise StrictDocSemanticError.unknown_node_type( requirement, path_to_sdoc_file ) grammar_element = document_grammar.elements_by_type[ - requirement.requirement_type + requirement.node_type ] registered_fields: Set[str] = set(grammar_element.get_field_titles()) @@ -181,7 +178,7 @@ def validate_node( ) grammar_element: GrammarElement = document_grammar.elements_by_type[ - requirement.requirement_type + requirement.node_type ] grammar_fields_iterator: Iterator[GrammarElementField] = iter( grammar_element.fields diff --git a/strictdoc/backend/sdoc/writer.py b/strictdoc/backend/sdoc/writer.py index 43292c723..a07f05575 100644 --- a/strictdoc/backend/sdoc/writer.py +++ b/strictdoc/backend/sdoc/writer.py @@ -294,7 +294,7 @@ def _print_node( # Special case for backward compatibility. if ( not convert_free_text_to_text - and root_node.requirement_type == "TEXT" + and root_node.node_type == "TEXT" and root_node.basic_free_text ): output += self._print_free_text(root_node) @@ -302,11 +302,11 @@ def _print_node( return output if isinstance(root_node, SDocCompositeNode): output += "[COMPOSITE_" - output += root_node.requirement_type + output += root_node.node_type output += "]\n" else: output += "[" - output += root_node.requirement_type + output += root_node.node_type output += "]\n" output += self._print_requirement_fields( @@ -323,7 +323,7 @@ def _print_node( ) output += "[/COMPOSITE_" - output += root_node.requirement_type + output += root_node.node_type output += "]\n" output += "\n" @@ -401,9 +401,7 @@ def _print_requirement_fields( current_view: ViewElement = document.view.get_current_view( self.project_config.view ) - element = document.grammar.elements_by_type[ - section_content.requirement_type - ] + element = document.grammar.elements_by_type[section_content.node_type] for element_field in element.fields: field_name = element_field.title @@ -414,7 +412,7 @@ def _print_requirement_fields( output += "\n" continue if not current_view.includes_field( - section_content.requirement_type, field_name + section_content.node_type, field_name ): continue fields = section_content.ordered_fields_lookup[field_name] diff --git a/strictdoc/core/analyzers/document_uid_analyzer.py b/strictdoc/core/analyzers/document_uid_analyzer.py index a9e22db72..f98098d8e 100644 --- a/strictdoc/core/analyzers/document_uid_analyzer.py +++ b/strictdoc/core/analyzers/document_uid_analyzer.py @@ -69,7 +69,7 @@ def analyze_document( continue if not isinstance(node, SDocNode): continue - if node.requirement_type == "TEXT": + if node.node_type == "TEXT": continue requirement: SDocNode = node requirement_parent_prefix: str = ( diff --git a/strictdoc/core/document_iterator.py b/strictdoc/core/document_iterator.py index 6ff0d6ad8..4c78f36a2 100644 --- a/strictdoc/core/document_iterator.py +++ b/strictdoc/core/document_iterator.py @@ -61,7 +61,7 @@ def _all_content( def get_level_string_( node_: Union[SDocSection, SDocNode, SDocCompositeNode], ) -> str: - if isinstance(node_, SDocNode) and node_.requirement_type == "TEXT": + if isinstance(node_, SDocNode) and node_.node_type == "TEXT": return "" if node_.ng_resolved_custom_level == "None": @@ -92,7 +92,7 @@ def get_level_string_( for subnode_ in node.section_contents: if subnode_.ng_resolved_custom_level is None and not ( isinstance(subnode_, SDocNode) - and subnode_.requirement_type == "TEXT" + and subnode_.node_type == "TEXT" ): current_number += 1 @@ -133,7 +133,7 @@ def get_level_string_( for subnode_ in node.requirements: if subnode_.ng_resolved_custom_level is None and not ( isinstance(subnode_, SDocNode) - and subnode_.requirement_type == "TEXT" + and subnode_.node_type == "TEXT" ): current_number += 1 @@ -176,7 +176,7 @@ def get_level_string_( for subnode_ in node.section_contents: if subnode_.ng_resolved_custom_level is None and not ( isinstance(subnode_, SDocNode) - and subnode_.requirement_type == "TEXT" + and subnode_.node_type == "TEXT" ): current_number += 1 yield from self._all_content( diff --git a/strictdoc/core/query_engine/query_object.py b/strictdoc/core/query_engine/query_object.py index 78dea9f4a..5a197b9e8 100644 --- a/strictdoc/core/query_engine/query_object.py +++ b/strictdoc/core/query_engine/query_object.py @@ -144,8 +144,7 @@ def _evaluate(self, node, expression) -> bool: return self._evaluate_node_has_child_requirements(node) if isinstance(expression, NodeIsRequirementExpression): return ( - isinstance(node, SDocNode) - and node.requirement_type == "REQUIREMENT" + isinstance(node, SDocNode) and node.node_type == "REQUIREMENT" ) if isinstance(expression, NodeIsSectionExpression): return isinstance(node, SDocSection) @@ -204,7 +203,7 @@ def _evaluate_node_field_expression( requirement: SDocNode = assert_cast(node, SDocNode) element: GrammarElement = ( requirement.document.grammar.elements_by_type[ - requirement.requirement_type + requirement.node_type ] ) grammar_field_titles = list(map(lambda f: f.title, element.fields)) diff --git a/strictdoc/core/transforms/create_requirement.py b/strictdoc/core/transforms/create_requirement.py index 3774716ac..43d2c3710 100644 --- a/strictdoc/core/transforms/create_requirement.py +++ b/strictdoc/core/transforms/create_requirement.py @@ -198,7 +198,7 @@ def perform(self): # FIXME: It is better to have a general create_node method because # we are dealing with arbitrary nodes, not only Requirement. requirement = SDocObjectFactory.create_requirement( - parent=parent, requirement_type=form_object.element_type + parent=parent, node_type=form_object.element_type ) # FIXME: Leave only one method based on set_field_value(). diff --git a/strictdoc/core/transforms/update_grammar_element.py b/strictdoc/core/transforms/update_grammar_element.py index 5d91b75e1..629b2ac3c 100644 --- a/strictdoc/core/transforms/update_grammar_element.py +++ b/strictdoc/core/transforms/update_grammar_element.py @@ -88,7 +88,7 @@ def perform(self) -> bool: continue requirement: SDocNode = assert_cast(node, SDocNode) - if requirement.requirement_type != updated_element.tag: + if requirement.node_type != updated_element.tag: continue requirement_field_names = list( diff --git a/strictdoc/core/transforms/update_requirement.py b/strictdoc/core/transforms/update_requirement.py index 712cf8d4e..c29d1279c 100644 --- a/strictdoc/core/transforms/update_requirement.py +++ b/strictdoc/core/transforms/update_requirement.py @@ -255,7 +255,7 @@ def perform(self): # FIXME: It is better to have a general create_node method because # we are dealing with arbitrary nodes, not only Requirement. requirement = SDocObjectFactory.create_requirement( - parent=parent, requirement_type=form_object.element_type + parent=parent, node_type=form_object.element_type ) requirement.reserved_mid = MID(form_object.requirement_mid) if document.config.enable_mid: diff --git a/strictdoc/export/html/form_objects/requirement_form_object.py b/strictdoc/export/html/form_objects/requirement_form_object.py index c79678d42..e5c753004 100644 --- a/strictdoc/export/html/form_objects/requirement_form_object.py +++ b/strictdoc/export/html/form_objects/requirement_form_object.py @@ -400,7 +400,7 @@ def create_from_requirement( assert document.grammar is not None grammar: DocumentGrammar = document.grammar element: GrammarElement = grammar.elements_by_type[ - requirement.requirement_type + requirement.node_type ] grammar_element_relations = element.get_relation_types() @@ -467,7 +467,7 @@ def create_from_requirement( form_refs_fields.append(form_ref_field) return RequirementFormObject( is_new=False, - element_type=requirement.requirement_type, + element_type=requirement.node_type, requirement_mid=requirement.reserved_mid, document_mid=document.reserved_mid, context_document_mid=context_document_mid, diff --git a/strictdoc/export/html/templates/components/node_field/comments/index.jinja b/strictdoc/export/html/templates/components/node_field/comments/index.jinja index d47cb479f..9bf860fbf 100644 --- a/strictdoc/export/html/templates/components/node_field/comments/index.jinja +++ b/strictdoc/export/html/templates/components/node_field/comments/index.jinja @@ -1,7 +1,7 @@ {# comments #} {# needs sdoc_entity, see README.txt #} -{% if view_object.current_view.includes_field(sdoc_entity.requirement_type, "COMMENT") %} +{% if view_object.current_view.includes_field(sdoc_entity.node_type, "COMMENT") %} {%- for comment_field_ in sdoc_entity.get_comment_fields() %} {{ sdoc_entity.get_field_human_title("COMMENT") }}: {{ meta_field[0] }}: {{ meta_field[0] }}: {{ sdoc_entity.get_field_human_title("RATIONALE") }}: diff --git a/strictdoc/export/json/json_generator.py b/strictdoc/export/json/json_generator.py index bc20ddd15..fb0418e57 100644 --- a/strictdoc/export/json/json_generator.py +++ b/strictdoc/export/json/json_generator.py @@ -282,13 +282,13 @@ def _write_requirement( ) -> Dict: node_dict: Dict[str, Any] = { "_TOC": level_string, - "TYPE": node.requirement_type, + "TYPE": node.node_type, } if node.mid_permanent or document.config.enable_mid: node_dict["MID"] = node.reserved_mid - element = document.grammar.elements_by_type[node.requirement_type] + element = document.grammar.elements_by_type[node.node_type] for element_field in element.fields: field_name = element_field.title diff --git a/strictdoc/export/rst/writer.py b/strictdoc/export/rst/writer.py index 0df752267..d04bb1688 100644 --- a/strictdoc/export/rst/writer.py +++ b/strictdoc/export/rst/writer.py @@ -47,7 +47,7 @@ def write(self, document: SDocDocument, single_document: bool) -> str: elif isinstance(content_node, SDocNode): if ( - content_node.requirement_type == "TEXT" + content_node.node_type == "TEXT" and content_node.basic_free_text ): output += self._print_text(content_node) diff --git a/strictdoc/export/spdx/spdx_to_sdoc_converter.py b/strictdoc/export/spdx/spdx_to_sdoc_converter.py index f12123a50..feb90ed47 100644 --- a/strictdoc/export/spdx/spdx_to_sdoc_converter.py +++ b/strictdoc/export/spdx/spdx_to_sdoc_converter.py @@ -179,7 +179,7 @@ def convert(spdx_container: SPDXSDocContainer) -> SDocDocument: def _convert_document(document: SpdxDocument, sdoc_document, sdoc_parent): requirement = SDocNode( parent=sdoc_parent, - requirement_type="SPDX_PACKAGE", + node_type="SPDX_PACKAGE", fields=[], relations=[], requirements=None, @@ -209,7 +209,7 @@ def _convert_package( ) -> SDocNode: requirement = SDocNode( parent=sdoc_parent, - requirement_type="SPDX_PACKAGE", + node_type="SPDX_PACKAGE", fields=[], relations=[], requirements=None, @@ -249,7 +249,7 @@ def _convert_file( fields = [] requirement = SDocNode( parent=sdoc_parent, - requirement_type="SPDX_FILE", + node_type="SPDX_FILE", fields=fields, relations=[], requirements=None, @@ -299,7 +299,7 @@ def _convert_snippet( fields = [] requirement = SDocNode( parent=sdoc_parent, - requirement_type="SPDX_SNIPPET", + node_type="SPDX_SNIPPET", fields=fields, relations=[], requirements=None, diff --git a/tests/integration/features/document_grammar/validation/01_unknown_requirement_type/test.itest b/tests/integration/features/document_grammar/validation/01_unknown_requirement_type/test.itest index bcf67b9db..80f5da47a 100644 --- a/tests/integration/features/document_grammar/validation/01_unknown_requirement_type/test.itest +++ b/tests/integration/features/document_grammar/validation/01_unknown_requirement_type/test.itest @@ -1,5 +1,5 @@ RUN: %expect_exit 1 %strictdoc export %S --output-dir Output/ | filecheck %s --dump-input=fail CHECK: error: could not parse file: {{.*}}input.sdoc. -CHECK: Semantic error: Invalid requirement type: UNKNOWN_REQUIREMENT. +CHECK: Semantic error: Invalid node type: UNKNOWN_REQUIREMENT. CHECK: Location: {{.*}}input.sdoc:15:1 diff --git a/tests/integration/scripting_examples/reqif/02_user_provided_example/script.py b/tests/integration/scripting_examples/reqif/02_user_provided_example/script.py index 06612bcce..460a3204d 100644 --- a/tests/integration/scripting_examples/reqif/02_user_provided_example/script.py +++ b/tests/integration/scripting_examples/reqif/02_user_provided_example/script.py @@ -489,7 +489,7 @@ def create_requirement_from_spec_object( ) ) requirement = SDocNode( - parent=parent_section, requirement_type="REQUIREMENT", fields=fields, relations=[] + parent=parent_section, node_type="REQUIREMENT", fields=fields, relations=[] ) if foreign_key_id_or_none is not None: diff --git a/tests/unit/helpers/test_document_builder.py b/tests/unit/helpers/test_document_builder.py index 546c9e483..72905e8c8 100644 --- a/tests/unit/helpers/test_document_builder.py +++ b/tests/unit/helpers/test_document_builder.py @@ -31,7 +31,7 @@ def add_requirement(self, uid): requirement = SDocObjectFactory.create_requirement( parent=parent, - requirement_type="REQUIREMENT", + node_type="REQUIREMENT", uid=uid, level=None, title=title, diff --git a/tests/unit/strictdoc/backend/sdoc/models/test_requirement.py b/tests/unit/strictdoc/backend/sdoc/models/test_requirement.py index 398682196..1c71409d5 100644 --- a/tests/unit/strictdoc/backend/sdoc/models/test_requirement.py +++ b/tests/unit/strictdoc/backend/sdoc/models/test_requirement.py @@ -83,7 +83,7 @@ def test_04_meta_multilines_not_nones(): requirement = SDocObjectFactory.create_requirement( document, - requirement_type="REQUIREMENT", + node_type="REQUIREMENT", title=None, uid="A-1", level=None, diff --git a/tools/confluence_html_table_import.py b/tools/confluence_html_table_import.py index cd20dfce5..79a274a98 100644 --- a/tools/confluence_html_table_import.py +++ b/tools/confluence_html_table_import.py @@ -70,7 +70,7 @@ def import_from_file(path_to_html): comment = req["COMMENT"] sreq = SDocObjectFactory.create_requirement( parent=section, - requirement_type="REQUIREMENT", + node_type="REQUIREMENT", uid=uid, level=None, title=title,