-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade markdown generation script, can now detect missing descriptio…
…ns outside game
- Loading branch information
Showing
3 changed files
with
50 additions
and
6 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 |
---|---|---|
|
@@ -2,6 +2,8 @@ eclipse | |
run | ||
libs | ||
media | ||
__pycache__ | ||
*.pyc | ||
classes/ | ||
.architectury-transformer/ | ||
fabric/fabricloader.log | ||
|
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 |
---|---|---|
@@ -1,26 +1,46 @@ | ||
#!/usr/bin/python3 | ||
|
||
import json | ||
import subprocess | ||
import json, os, subprocess, sys | ||
# to import other scripts in same folder | ||
sys.path.append(os.path.dirname(os.path.realpath(__file__))) | ||
|
||
from contextlib import redirect_stdout | ||
from modernfixlib import get_valid_mixin_options | ||
|
||
branch_name = subprocess.check_output(['git', 'branch', '--show-current']).decode("utf-8").strip() | ||
|
||
with open('doc/generated/' + branch_name + '-Summary-of-Patches.md', 'w') as output_file: | ||
all_current_mixin_options = get_valid_mixin_options() | ||
options_missing_descriptions = set() | ||
with redirect_stdout(output_file): | ||
with open('common/src/main/resources/assets/modernfix/lang/en_us.json') as lang_json: | ||
lang_obj = json.loads(lang_json.read()) | ||
option_names = [] | ||
option_names = set() | ||
for key, value in lang_obj.items(): | ||
if key.startswith("modernfix.option.mixin."): | ||
option_names.append(key.replace("modernfix.option.", "")) | ||
option_names.sort() | ||
option_names.add(key.replace("modernfix.option.", "")) | ||
option_names_sorted = list(option_names) | ||
option_names_sorted.sort() | ||
print() | ||
for option in option_names: | ||
for option in option_names_sorted: | ||
if option not in all_current_mixin_options: | ||
continue | ||
option_description = lang_obj.get("modernfix.option." + option) | ||
option_friendly_name = lang_obj.get("modernfix.option.name." + option) | ||
print(f"### `{option}`") | ||
print() | ||
if option_description is not None: | ||
print(option_description) | ||
print("") | ||
else: | ||
options_missing_descriptions.add(option) | ||
options_missing_descriptions.update(all_current_mixin_options.difference(option_names)) | ||
|
||
# sort the list of missing descriptions and print them out if there are any | ||
missing_descriptions_list = list(options_missing_descriptions) | ||
missing_descriptions_list.sort() | ||
num_missing = len(missing_descriptions_list) | ||
if num_missing > 0: | ||
print(f"Missing {num_missing} descriptions:") | ||
for option in missing_descriptions_list: | ||
print(f" - {option}") |
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,22 @@ | ||
|
||
import os | ||
import re | ||
|
||
def get_valid_mixin_options(): | ||
all_mixin_options = set() | ||
# gather all mixins in mixin folders | ||
for platform in [ "common", "fabric", "forge" ]: | ||
base_path = f"{platform}/src/main/java/org/embeddedt/modernfix/{platform}/mixin" | ||
for root, dirs, files in os.walk(base_path): | ||
for file in files: | ||
if file.endswith(".java"): | ||
mixin_name = root.replace(base_path, "").replace(os.path.sep, ".") | ||
if mixin_name.startswith("."): | ||
mixin_name = mixin_name[1:] | ||
all_mixin_options.add("mixin." + mixin_name) | ||
# gather any mixin strings referenced in ModernFixEarlyConfig | ||
with open('common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java') as config_java: | ||
config_str = config_java.read() | ||
for option in re.findall(r"\"(mixin(?:\.[a-z_]+)+)\"", config_str): | ||
all_mixin_options.add(option) | ||
return all_mixin_options |