diff --git a/documentation/LRM.md b/documentation/LRM.md index 0926ee2..085e812 100644 --- a/documentation/LRM.md +++ b/documentation/LRM.md @@ -1,5 +1,6 @@ # TRLC LRM +* [Version 3.0](https://bmw-software-engineering.github.io/trlc/lrm.html) (Development) * [Version 2.9](https://bmw-software-engineering.github.io/trlc/lrm-2.9.html) (Current Stable) * [Version 2.8](https://bmw-software-engineering.github.io/trlc/lrm-2.8.html) * [Version 2.7](https://bmw-software-engineering.github.io/trlc/lrm-2.7.html) diff --git a/index.rst b/index.rst index b4e286d..8d728f8 100644 --- a/index.rst +++ b/index.rst @@ -45,3 +45,8 @@ from this API. manual/infrastructure manual/errors manual/ast + +.. toctree:: + :caption: Iteration API by Section + + section_api diff --git a/section_api.rst b/section_api.rst new file mode 100644 index 0000000..5983f86 --- /dev/null +++ b/section_api.rst @@ -0,0 +1,38 @@ +TRLC Iteration API by Section +============================= + +This is description for the end-user facing TRLC Iteration API by Section + +Function iter_record_objects_by_section() will yield +all the information about record objects, sections and file locations:: + + def iter_record_objects_by_section(self): + +You need to input trlc files with requirements which contain +sections or nested sections with record objects:: + + # Iterates over each record object in the trlc files + # and yields the file location of trlc files + for record_object in self.iter_record_objects(): + file_name = record_object.location.file_name + if location not in self.trlc_files: + self.trlc_files.append(location) + yield location + + # This code block checks section, if present + # it will yield the section and level of section, + # record object and level of record object + if record_object.section: + object_level = len(record_object.section) - 1 + for level, section in enumerate(record_object.section): + if section not in self.section_names: + self.section_names.append(section) + yield section.name, level + yield record_object, object_level + + # If section is not present + # then it will yield the record object and level of record object + else: + object_level = 0 + yield record_object, object_level + diff --git a/trlc/ast.py b/trlc/ast.py index 1b68f02..8d8ed0b 100644 --- a/trlc/ast.py +++ b/trlc/ast.py @@ -3088,6 +3088,13 @@ def iter_record_objects_by_section(self): """API for users Retriving information about the section hierarchy for record objects +<<<<<<< HEAD +======= + Inputs: folder with trlc files where trlc files have sections, + sub sections and record objects + Output: Information about sections and level of sections, + record objects and levels of record object +>>>>>>> ce6c48c (Added the Iteration API by Section in toctree) """ for record_object in self.iter_record_objects(): location = record_object.location.file_name