mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Streamline dependencies extraction tool (#4268)
* Streamline dependencies extraction tool for new wiki location, Update dependencies list * Use LF strictly
This commit is contained in:
parent
9599ab9bd9
commit
d1d23c55bc
File diff suppressed because one or more lines are too long
@ -1,17 +1,14 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Author: Jonpas
|
# Author: Jonpas
|
||||||
# Extracts dependencies to a file (defined in globals) for use with Jekyll include statement.
|
# Extracts dependencies to "docs/_includes/dependencies_list.md" for use with Jekyll include statement.
|
||||||
# Place generated file to "_includes/" folder on gh-pages branch and use the following line to add dependencies to a feature page:
|
# Use the following line to add dependencies to a feature page:
|
||||||
# {% include dependencies_list.md component="<component>" %}
|
# {% include dependencies_list.md component="<component>" %}
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
######## GLOBALS #########
|
|
||||||
FILE_EXTRACTED = "temp\\dependencies_list.md"
|
|
||||||
##########################
|
|
||||||
|
|
||||||
def get_dependencies(line):
|
def get_dependencies(line):
|
||||||
dependencies = re.findall(r'"(.*?)"', line)
|
dependencies = re.findall(r'"(.*?)"', line)
|
||||||
@ -29,15 +26,22 @@ def main():
|
|||||||
scriptpath = os.path.realpath(__file__)
|
scriptpath = os.path.realpath(__file__)
|
||||||
projectpath = os.path.dirname(os.path.dirname(scriptpath))
|
projectpath = os.path.dirname(os.path.dirname(scriptpath))
|
||||||
addonspath = os.path.join(projectpath, "addons")
|
addonspath = os.path.join(projectpath, "addons")
|
||||||
|
includepath = os.path.join(projectpath, "docs", "_includes")
|
||||||
|
dependenciespath = os.path.join(includepath, "dependencies_list.md")
|
||||||
|
|
||||||
# Prepare directory and file
|
# Prepare directory and file
|
||||||
if not os.path.exists("temp"):
|
if not os.path.exists(includepath):
|
||||||
os.makedirs("temp")
|
print("Jekyll documentation not found!")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
open(FILE_EXTRACTED, "w").close()
|
open(dependenciespath, "w", newline="\n").close()
|
||||||
|
|
||||||
# Iterate through folders in the addons directory
|
# Iterate through folders in the addons directory
|
||||||
for folder in next(os.walk(addonspath))[1]:
|
for folder in next(os.walk(addonspath))[1]:
|
||||||
|
# Ignore "main" component
|
||||||
|
if folder == "main":
|
||||||
|
continue
|
||||||
|
|
||||||
# Open config.cpp file and extract dependencies
|
# Open config.cpp file and extract dependencies
|
||||||
data = []
|
data = []
|
||||||
with open(os.path.join(addonspath, folder, "config.cpp")) as file:
|
with open(os.path.join(addonspath, folder, "config.cpp")) as file:
|
||||||
@ -68,15 +72,13 @@ def main():
|
|||||||
data = "`{}`".format(data)
|
data = "`{}`".format(data)
|
||||||
print("{}: {}".format(folder,data))
|
print("{}: {}".format(folder,data))
|
||||||
|
|
||||||
with open(FILE_EXTRACTED, "a") as file:
|
with open(dependenciespath, "a", newline="\n") as file:
|
||||||
file.writelines([
|
file.writelines([
|
||||||
"{% if include.component == \"" + folder + "\" %}\n",
|
"{% if include.component == \"" + folder + "\" %}\n",
|
||||||
"{}\n".format(data),
|
"{}\n".format(data),
|
||||||
"{% endif %}\n",
|
"{% endif %}\n\n",
|
||||||
])
|
])
|
||||||
|
|
||||||
print("\nCopy 'temp\dependencies_list.md' to '_includes/' folder on 'gh-pages' branch.")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user