Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/auto-assign-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Set to true to add reviewers to pull requests
addReviewers: true

# Set to true to add assignees to pull requests
addAssignees: author

# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- iamwatchdogs

# A number of reviewers added to the pull request
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 1

# A list of assignees, overrides reviewers if set
# assignees:
# - assigneeA

# A number of assignees to add to the pull request
# Set to 0 to add all of the assignees.
# Uses numberOfReviewers if unset.
# numberOfAssignees: 2

# A list of keywords to be skipped the process that add reviewers if pull requests include it
# skipKeywords:
# - wip
91 changes: 90 additions & 1 deletion .github/scripts/convert_to_html_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ class UpdateFileContent:
REPO_NAME = None

def __init__(self, FILE_PATH, condition=None):
"""
Constructor method of UpdateFileContent class.

Parameters
----------
FILE_PATH : str
Path of the file to be updated.
condition : callable, optional
Condition to filter the contributors based on.
Defaults to None, which means no filtering.

"""

# Displaying starting Message
print(f'\n--- Updating {FILE_PATH} ---\n')
Expand All @@ -40,6 +52,14 @@ def __init__(self, FILE_PATH, condition=None):


def get_lines(self):
"""
Reads the lines from the file located at `self.FILE_PATH`.

Returns
-------
list
List of lines read from the file.
"""

# Reading lines from the file
with open(self.FILE_PATH, 'r') as file:
Expand All @@ -48,6 +68,17 @@ def get_lines(self):
return lines

def write_lines_into_file(self):
"""
Writes the lines to the file located at `self.FILE_PATH`.

Parameters
----------
None

Returns
-------
None
"""

# Updating the target file
with open(self.FILE_PATH, 'w') as file:
Expand All @@ -57,6 +88,23 @@ def write_lines_into_file(self):
print(f"Updated '{self.FILE_PATH}' Successfully")

def find_table_points(self, search_type):
"""
Finds the starting and ending points of a table in the file located at
`self.FILE_PATH` based on the `search_type`.

Parameters
----------
search_type : str
Valid values are 'contributors' and 'table-of-content'.

Returns
-------
tuple
A tuple of `(table_starting_point, table_ending_point)` where
`table_starting_point` is the index of the line where the table
starts and `table_ending_point` is the index of the line where the
table ends.
"""

# Setting default return values
table_starting_point = None
Expand Down Expand Up @@ -97,6 +145,16 @@ def find_table_points(self, search_type):
return (table_starting_point, table_ending_point)

def update_table_of_contributors(self, condition):
"""
Update the table of contributors based on the condition.

Parameters
----------
condition : callable
A function that takes one argument (i.e., the core contribution)
and returns True if the contribution should be included in the table, or
False otherwise. If None, then all core contributions are included.
"""

# Calculating stating and ending points of the targeted table
table_of_contributors_start, table_of_contributors_end = self.find_table_points('contributors')
Expand Down Expand Up @@ -135,7 +193,7 @@ def update_table_of_contributors(self, condition):
# Processing core contribution
core_contribution = details['core']
if condition is None:
core_contribution_output = f'<a href="{core_contribution}" title="goto {core_contribution}">{core_contribution}</a>'
core_contribution_output = f'<a href="{core_contribution}" title="goto {core_contribution}">{core_contribution}</a>' if core_contribution != 'Repo' else core_contribution

# Processing pull-requests
pull_requests = details['pull-request-number']
Expand All @@ -150,6 +208,12 @@ def update_table_of_contributors(self, condition):
demo_path_output = f'<a href="{demo_path}" title="view the result of {specificity}">./{core_contribution}/{specificity}</a>'
if title == 'root' or title == '{init}':
demo_path_output = f'<a href="{demo_path}" title="view the result of {title}">/{self.REPO_NAME}/</a>'
elif title == '{workflows}':
demo_path_output = f'<a href="{demo_path}" title="view the result of {title}">/{self.REPO_NAME}/.github/workflows</a>'
elif title == '{scripts}':
demo_path_output = f'<a href="{demo_path}" title="view the result of {title}">/{self.REPO_NAME}/.github/scripts</a>'
elif title == '{others}':
demo_path_output = f'<a href="{demo_path}" title="view the result of {title}">/{self.REPO_NAME}/.github/others</a>'

# Appending all data together
updated_lines.append('\t<tr align="center">\n')
Expand Down Expand Up @@ -184,6 +248,22 @@ def update_table_of_contributors(self, condition):
print('Successfully updated the contributor details !!!...')

def update_table_of_content(self, condition):
"""
Update the table of content in the markdown file based on the specified condition.

Args:
condition (callable): A function that takes one argument (i.e., the core contribution)
and returns True if the contribution should be included in the table, or
False otherwise. If None, then all core contributions are included.

The method calculates the starting and ending points of the targeted table and
initializes necessary variables to store the table of content. It processes the
data from `self.DATA` to extract and organize the content by core and specificity.
The extracted data is sorted and used to update the markdown file with a structured
list of links representing the table of content. The links are formatted based on
whether a condition is given. Finally, the method updates the markdown lines and
prints a success message upon completion.
"""

# Calculating stating and ending points of the targeted table
table_of_content_start, table_of_content_end = self.find_table_points('table-of-content')
Expand Down Expand Up @@ -248,6 +328,15 @@ def update_table_of_content(self, condition):


def main():
"""
The main function of the script is responsible for updating the root index file and the index files of `Theory` and `Solved-Problems` directories.

The function takes in environment variables `REPO_NAME` and uses it to fetch the required data from the contributors log file.

The function then updates the root index file and the index files of `Theory` and `Solved-Problems` directories using the fetched data.

The function also prints out a success message at the end.
"""

# Retrieving Environmental variables
REPO_NAME = os.environ.get('REPO_NAME')
Expand Down
Loading
Loading