@@ -63,22 +63,21 @@ def collect_specification_linked_resources(specification, specification_heading,
6363def collect_linked_resources_in_section (
6464 section , linked_resources_list , specifications_list , include_acceptance_tests , frid = Optional [str ]
6565):
66- # When should we collect resources in the current section (should_collect_resources_in_current_section) :
66+ # When should we collect specification headings in the current section. Either when one of the following holds true :
6767 # - frid wasn't specified
68- # - section has no ID <==> it's the root section
68+ # - section has no ID (and that's exactly when it's the root section)
6969 # - section has ID, frid was specified and the specified frid inside the current section tree
70- should_collect_resources_in_current_section = frid is None or "ID" not in section or frid .startswith (section ["ID" ])
71- if not should_collect_resources_in_current_section :
72- return False
73-
74- specifications_to_collect = list (set ([DEFINITIONS , NON_FUNCTIONAL_REQUIREMENTS , TEST_REQUIREMENTS ]))
75- if specifications_list :
76- specifications_to_collect = list (set (specifications_to_collect ) & set (specifications_list ))
77-
78- for specification_heading in specifications_to_collect :
79- if specification_heading in section :
80- for requirement in section [specification_heading ]:
81- collect_specification_linked_resources (requirement , specification_heading , linked_resources_list )
70+ should_collect_specification_headings_in_current_section = (
71+ frid is None or "ID" not in section or frid .startswith (section ["ID" ])
72+ )
73+ if should_collect_specification_headings_in_current_section :
74+ specifications_to_collect = list (set ([DEFINITIONS , NON_FUNCTIONAL_REQUIREMENTS , TEST_REQUIREMENTS ]))
75+ if specifications_list :
76+ specifications_to_collect = list (set (specifications_to_collect ) & set (specifications_list ))
77+ for specification_heading in specifications_to_collect :
78+ if specification_heading in section :
79+ for requirement in section [specification_heading ]:
80+ collect_specification_linked_resources (requirement , specification_heading , linked_resources_list )
8281
8382 if FUNCTIONAL_REQUIREMENTS in section and (
8483 not specifications_list or FUNCTIONAL_REQUIREMENTS in specifications_list
@@ -97,7 +96,9 @@ def collect_linked_resources_in_section(
9796 acceptance_test , FUNCTIONAL_REQUIREMENTS , linked_resources_list
9897 )
9998
100- if current_frid == frid :
99+ if frid is not None and current_frid == frid :
100+ # here, we rely on the fact that FRIDs are incrementing. And if we have reached the current FRID, we should
101+ # not collect any FRIDs after the current one.
101102 return True
102103
103104 if "sections" in section :
0 commit comments