diff --git a/.gitignore b/.gitignore index f427fdd20..c2fa78c12 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ eclipse run libs media +__pycache__ +*.pyc classes/ .architectury-transformer/ fabric/fabricloader.log diff --git a/scripts/gen-markdown-patchlist.py b/scripts/gen-markdown-patchlist.py index 37ac1e0b2..28b862996 100644 --- a/scripts/gen-markdown-patchlist.py +++ b/scripts/gen-markdown-patchlist.py @@ -1,22 +1,30 @@ #!/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}`") @@ -24,3 +32,15 @@ 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}") \ No newline at end of file diff --git a/scripts/modernfixlib.py b/scripts/modernfixlib.py new file mode 100644 index 000000000..032aacd72 --- /dev/null +++ b/scripts/modernfixlib.py @@ -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 \ No newline at end of file