📝 Updated docs [skip ci]

This commit is contained in:
Nikhil Badyal
2023-08-22 17:02:57 +05:30
parent f1873a2f85
commit 74f6a9e7c1
4 changed files with 303 additions and 46 deletions
+105 -13
View File
@@ -26,14 +26,44 @@ bs4_parser = "html.parser"
def update_changelog(name: str, response: Dict[str, str]) -> None:
"""Updated Changelog."""
"""The function `update_changelog` updates the changelog file with the
provided name and response.
Parameters
----------
name : str
A string representing the name of the change or update.
response : Dict[str, str]
The `response` parameter is a dictionary that contains information about the changes made. The keys
in the dictionary represent the type of change (e.g., "bug fix", "feature", "documentation"), and
the values represent the specific changes made for each type.
"""
parent_repo = get_parent_repo()
change_log = format_changelog(name, response, parent_repo)
write_to_file(change_log)
def format_changelog(name: str, response: Dict[str, str], parent_repo: str) -> str:
"""Format changelog."""
"""The `format_changelog` function takes in a name, a response dictionary,
and a parent repository, and returns a formatted changelog string.
Parameters
----------
name : str
The `name` parameter is a string that represents the name of the changelog. It is used to create a
collapsible section in the formatted changelog.
response : Dict[str, str]
The `response` parameter is a dictionary that contains information about a release. It has the
following keys:
parent_repo : str
The `parent_repo` parameter is a string that represents the URL or name of the parent repository.
It is used to generate a footer in the formatted changelog, indicating that the changelogs were
generated by a specific tool or script.
Returns
-------
a formatted changelog as a string.
"""
collapse_start = f"\n<details> <summary>👀 {name} </summary>\n\n"
release_version = (
f"**Release Version** - [{response['tag_name']}]({response['html_url']})<br>"
@@ -57,25 +87,59 @@ def format_changelog(name: str, response: Dict[str, str], parent_repo: str) -> s
def write_to_file(change_log: str) -> None:
"""Write changelog to file."""
"""The function `write_to_file` writes a given changelog string to a file
named "changelog.md".
Parameters
----------
change_log : str
A string representing the changelog that you want to write to the file.
"""
with open("changelog.md", "w", encoding="utf_8") as file1:
file1.write(change_log)
def get_parent_repo() -> str:
"""Get parent repository URL from configuration file."""
"""The function `get_parent_repo()` returns the URL of the parent
repository.
Returns
-------
the URL of the parent repository, which is "https://github.com/nikhilbadyal/docker-py-revanced".
"""
return "https://github.com/nikhilbadyal/docker-py-revanced"
def handle_request_response(response: Response) -> None:
"""Handle Get Request Response."""
"""The function handles the response of a GET request and raises an
exception if the response code is not 200.
Parameters
----------
response : Response
The parameter `response` is of type `Response`, which is likely referring to a response object from
an HTTP request. This object typically contains information about the response received from the
server, such as the status code, headers, and response body.
"""
response_code = response.status_code
if response_code != 200:
raise DownloadFailure(f"Unable to downloaded assets. Reason - {response.text}")
def slugify(string: str) -> str:
"""Converts a string to a slug format."""
"""The `slugify` function converts a string to a slug format by converting
it to lowercase, removing special characters, replacing spaces with dashes,
removing consecutive dashes, and removing leading and trailing dashes.
Parameters
----------
string : str
The `string` parameter is a string that you want to convert to a slug format.
Returns
-------
The function `slugify` returns a modified version of the input string in slug format.
"""
# Convert to lowercase
modified_string = string.lower()
@@ -95,7 +159,21 @@ def slugify(string: str) -> str:
def check_java(dry_run: bool) -> None:
"""Check if Java>=17 is installed."""
"""The function `check_java` checks if Java version 17 or higher is
installed and logs an error message if it is not.
Parameters
----------
dry_run : bool
The `dry_run` parameter is a boolean flag that determines whether the function should actually
check if Java is installed or just simulate the check. If `dry_run` is `True`, the function will
return without performing the check. If `dry_run` is `False`, the function will execute the
Returns
-------
The function `check_java` does not return any value. It has a return type annotation of `None`,
indicating that it does not return anything.
"""
try:
if dry_run:
return
@@ -114,7 +192,15 @@ def check_java(dry_run: bool) -> None:
def extra_downloads(config: RevancedConfig) -> None:
"""Download extra files."""
"""The function `extra_downloads` downloads extra files specified in the
`config` object using the `APP.download` method.
Parameters
----------
config : RevancedConfig
The `config` parameter is an instance of the `RevancedConfig` class. It is used to provide
configuration settings for the download process.
"""
from src.app import APP
try:
@@ -135,13 +221,19 @@ def extra_downloads(config: RevancedConfig) -> None:
def apkmirror_status_check(package_name: str) -> Any:
"""Check if app exists on APKMirror.
"""The `apkmirror_status_check` function checks if an app exists on
APKMirror by making a POST request to the APKMirror API with the package
name as a parameter.
Args:
package_name (str): The name of the package to check.
Parameters
----------
package_name : str
The `package_name` parameter is a string that represents the name of the app package to check on
APKMirror.
Returns:
dict: The response from APKMirror API as a JSON object.
Returns
-------
the response from the APKMirror API as a JSON object.
"""
api_url = f"{apk_mirror_base_url}/wp-json/apkm/v1/app_exists/"
body = {"pnames": [package_name]}