-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,380 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "sema-toolchain/sema_scdg/requirement.txt" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "docker" # See documentation for possible values | ||
directory: "sema-toolchain/sema_scdg/Dockerfile." # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "sema-toolchain/sema_classifier/requirement.txt" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "docker" # See documentation for possible values | ||
directory: "sema-toolchain/sema_classifier/Dockerfile." # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Documentation Generation | ||
on: | ||
pull_request: | ||
branches: | ||
- "production" | ||
paths: | ||
- "**.py" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
doc-generation: | ||
name: Documentation Generation | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: "Checkout code" | ||
uses: "actions/checkout@v3" | ||
- name: "Generate docs" | ||
run: | | ||
pip install -r requirements.txt | ||
make gen-docs | ||
mkdocs gh-deploy --force --clean | ||
mv sources docs | ||
- name: "Commit generated documentation" | ||
uses: "stefanzweifel/git-auto-commit-action@v4" | ||
with: | ||
commit_message: "Updating documentation" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
gen-docs: | ||
python3 ./doc/generate_doc.py | ||
gendocs --config doc/mkgendocs.yaml | ||
|
||
mkdocs: | ||
make gen-docs | ||
mkdocs serve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/usr/bin/env python3 | ||
"""Generate mkgendocs.yaml from python files by iterating over files and functions.""" | ||
|
||
import os | ||
|
||
import yaml | ||
import re | ||
|
||
|
||
def get_mkgendocs_config(): | ||
""" | ||
Get the mkgendocs configuration file. | ||
Raises: | ||
FileNotFoundError: If mkgendocs.yaml is not found | ||
YAMLError: If there is an error parsing mkgendocs.yaml | ||
Returns: | ||
mkgendocs configuration | ||
""" | ||
try: | ||
with open("doc/mkgendocs.yaml", encoding="UTF-8") as mkgendocs_config: | ||
return yaml.safe_load(mkgendocs_config) | ||
except FileNotFoundError as error_message: | ||
print("mkgendocs.yaml not found") | ||
raise FileNotFoundError from error_message | ||
except yaml.YAMLError as error_message: | ||
raise yaml.YAMLError() from error_message | ||
|
||
|
||
# Function to get a list of python files in a directory | ||
def get_python_files(directory): | ||
""" | ||
Get a list of python files in a directory. | ||
Args: | ||
directory: Directory to search | ||
Returns: | ||
List of python files | ||
""" | ||
python_files = [] | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
if file.endswith(".py") and ( | ||
not root.startswith("./tests") | ||
and not file.startswith("_") | ||
and not root.startswith("./build") | ||
): | ||
python_files.append(os.path.join(root, file)) | ||
return python_files | ||
|
||
|
||
def get_file_functions(filename): | ||
""" | ||
Get the functions in a file. | ||
Args: | ||
filename: The name of the file to parse for functions. | ||
Returns: | ||
List of functions | ||
""" | ||
if "ivy" in filename: | ||
print("No ivy documentation generated") | ||
return [] | ||
if "submodules" in filename: | ||
print("No submodules documentation generated") | ||
return [] | ||
with open(filename, encoding="UTF-8") as file: | ||
content = file.read() | ||
if "print " in content: | ||
print(f"Python 2 {filename} skipping") | ||
return [] | ||
with open(filename, encoding="UTF-8") as file: | ||
lines = file.readlines() | ||
functions = [] | ||
# TODO fix | ||
# for line in lines: | ||
# if re.match(r"^\s*def\s+\w+\s*\(", line): | ||
# function_name = re.search(r"def\s+(\w+)\s*\(", line).group(1) | ||
# functions.append(function_name) | ||
for line in lines: | ||
if line.startswith("def"): | ||
functions.append(line.split(" ")[1].split("(")[0]) | ||
return functions | ||
|
||
def main(): | ||
"""Generate configuration for mkgendocs to build documentation.""" | ||
print("Starting doc generation") | ||
mkgendocs_config = get_mkgendocs_config() | ||
new_pages = [] | ||
|
||
print("Getting a list of functions in python files..") | ||
python_files = get_python_files(".") | ||
for python_file in python_files: | ||
functions = get_file_functions(python_file) | ||
if len(functions) > 0: | ||
print("Functions found, adding " + python_file) | ||
new_pages.append( | ||
{ | ||
"page": python_file.replace(".py", ".md").replace("./", ""), | ||
"source": python_file, | ||
"functions": functions, | ||
} | ||
) | ||
else: | ||
print("No functions found, skipping " + python_file) | ||
|
||
mkgendocs_config["pages"] = new_pages | ||
|
||
with open("doc/mkgendocs.yaml", "w", encoding="UTF-8") as mkgendocs_config_file: | ||
yaml.dump(mkgendocs_config, mkgendocs_config_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.