Skip to content

Commit

Permalink
Added the Iteration API by Section in toctree
Browse files Browse the repository at this point in the history
Created a section_api.rst file for documenting Iteration API by Section
Added a link for Iteration API by Section documentation
Added comments for iter_record_objects_by_section() function
  • Loading branch information
mugdhadhole1 committed Aug 7, 2024
1 parent eaeb77d commit c3fa429
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions documentation/LRM.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 5 additions & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ from this API.
manual/infrastructure
manual/errors
manual/ast

.. toctree::
:caption: Iteration API by Section

section_api
38 changes: 38 additions & 0 deletions section_api.rst
Original file line number Diff line number Diff line change
@@ -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

7 changes: 7 additions & 0 deletions trlc/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3fa429

Please sign in to comment.