@@ -21,6 +21,18 @@ class UpdateFileContent:
2121 REPO_NAME = None
2222
2323 def __init__ (self , FILE_PATH , condition = None ):
24+ """
25+ Constructor method of UpdateFileContent class.
26+
27+ Parameters
28+ ----------
29+ FILE_PATH : str
30+ Path of the file to be updated.
31+ condition : callable, optional
32+ Condition to filter the contributors based on.
33+ Defaults to None, which means no filtering.
34+
35+ """
2436
2537 # Displaying starting Message
2638 print (f'\n --- Updating { FILE_PATH } ---\n ' )
@@ -40,6 +52,14 @@ def __init__(self, FILE_PATH, condition=None):
4052
4153
4254 def get_lines (self ):
55+ """
56+ Reads the lines from the file located at `self.FILE_PATH`.
57+
58+ Returns
59+ -------
60+ list
61+ List of lines read from the file.
62+ """
4363
4464 # Reading lines from the file
4565 with open (self .FILE_PATH , 'r' ) as file :
@@ -48,6 +68,17 @@ def get_lines(self):
4868 return lines
4969
5070 def write_lines_into_file (self ):
71+ """
72+ Writes the lines to the file located at `self.FILE_PATH`.
73+
74+ Parameters
75+ ----------
76+ None
77+
78+ Returns
79+ -------
80+ None
81+ """
5182
5283 # Updating the target file
5384 with open (self .FILE_PATH , 'w' ) as file :
@@ -57,6 +88,23 @@ def write_lines_into_file(self):
5788 print (f"Updated '{ self .FILE_PATH } ' Successfully" )
5889
5990 def find_table_points (self , search_type ):
91+ """
92+ Finds the starting and ending points of a table in the file located at
93+ `self.FILE_PATH` based on the `search_type`.
94+
95+ Parameters
96+ ----------
97+ search_type : str
98+ Valid values are 'contributors' and 'table-of-content'.
99+
100+ Returns
101+ -------
102+ tuple
103+ A tuple of `(table_starting_point, table_ending_point)` where
104+ `table_starting_point` is the index of the line where the table
105+ starts and `table_ending_point` is the index of the line where the
106+ table ends.
107+ """
60108
61109 # Setting default return values
62110 table_starting_point = None
@@ -97,6 +145,16 @@ def find_table_points(self, search_type):
97145 return (table_starting_point , table_ending_point )
98146
99147 def update_table_of_contributors (self , condition ):
148+ """
149+ Update the table of contributors based on the condition.
150+
151+ Parameters
152+ ----------
153+ condition : callable
154+ A function that takes one argument (i.e., the core contribution)
155+ and returns True if the contribution should be included in the table, or
156+ False otherwise. If None, then all core contributions are included.
157+ """
100158
101159 # Calculating stating and ending points of the targeted table
102160 table_of_contributors_start , table_of_contributors_end = self .find_table_points ('contributors' )
@@ -135,7 +193,7 @@ def update_table_of_contributors(self, condition):
135193 # Processing core contribution
136194 core_contribution = details ['core' ]
137195 if condition is None :
138- core_contribution_output = f'<a href="{ core_contribution } " title="goto { core_contribution } ">{ core_contribution } </a>'
196+ core_contribution_output = f'<a href="{ core_contribution } " title="goto { core_contribution } ">{ core_contribution } </a>' if core_contribution != 'Repo' else core_contribution
139197
140198 # Processing pull-requests
141199 pull_requests = details ['pull-request-number' ]
@@ -150,6 +208,12 @@ def update_table_of_contributors(self, condition):
150208 demo_path_output = f'<a href="{ demo_path } " title="view the result of { specificity } ">./{ core_contribution } /{ specificity } </a>'
151209 if title == 'root' or title == '{init}' :
152210 demo_path_output = f'<a href="{ demo_path } " title="view the result of { title } ">/{ self .REPO_NAME } /</a>'
211+ elif title == '{workflows}' :
212+ demo_path_output = f'<a href="{ demo_path } " title="view the result of { title } ">/{ self .REPO_NAME } /.github/workflows</a>'
213+ elif title == '{scripts}' :
214+ demo_path_output = f'<a href="{ demo_path } " title="view the result of { title } ">/{ self .REPO_NAME } /.github/scripts</a>'
215+ elif title == '{others}' :
216+ demo_path_output = f'<a href="{ demo_path } " title="view the result of { title } ">/{ self .REPO_NAME } /.github/others</a>'
153217
154218 # Appending all data together
155219 updated_lines .append ('\t <tr align="center">\n ' )
@@ -184,6 +248,22 @@ def update_table_of_contributors(self, condition):
184248 print ('Successfully updated the contributor details !!!...' )
185249
186250 def update_table_of_content (self , condition ):
251+ """
252+ Update the table of content in the markdown file based on the specified condition.
253+
254+ Args:
255+ condition (callable): A function that takes one argument (i.e., the core contribution)
256+ and returns True if the contribution should be included in the table, or
257+ False otherwise. If None, then all core contributions are included.
258+
259+ The method calculates the starting and ending points of the targeted table and
260+ initializes necessary variables to store the table of content. It processes the
261+ data from `self.DATA` to extract and organize the content by core and specificity.
262+ The extracted data is sorted and used to update the markdown file with a structured
263+ list of links representing the table of content. The links are formatted based on
264+ whether a condition is given. Finally, the method updates the markdown lines and
265+ prints a success message upon completion.
266+ """
187267
188268 # Calculating stating and ending points of the targeted table
189269 table_of_content_start , table_of_content_end = self .find_table_points ('table-of-content' )
@@ -248,6 +328,15 @@ def update_table_of_content(self, condition):
248328
249329
250330def main ():
331+ """
332+ The main function of the script is responsible for updating the root index file and the index files of `Theory` and `Solved-Problems` directories.
333+
334+ The function takes in environment variables `REPO_NAME` and uses it to fetch the required data from the contributors log file.
335+
336+ The function then updates the root index file and the index files of `Theory` and `Solved-Problems` directories using the fetched data.
337+
338+ The function also prints out a success message at the end.
339+ """
251340
252341 # Retrieving Environmental variables
253342 REPO_NAME = os .environ .get ('REPO_NAME' )
0 commit comments