diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0e89f30599..1800bed055 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,7 +35,7 @@ jobs: path: 'tfc' - name: Build run: | - python src/main.py --tfc-dir tfc --out-dir build --resource-pack-book --root-dir "${GITHUB_REPOSITORY#*/}" --use-mcmeta --use-addons --copy-existing-versions + python src/main.py --tfc-dir tfc --out-dir build --root-dir "${GITHUB_REPOSITORY#*/}" --use-mcmeta --use-addons --copy-existing-versions touch build/.nojekyll - name: Deploy uses: JamesIves/github-pages-deploy-action@v4 diff --git a/README.md b/README.md index 8628931323..b451bfcce9 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,11 @@ $ python src/main.py --tfc-dir /path/to/tfc [--debug] $ cd out $ python -m http.server 8000 -# New versions (1.20) require additional arguments: -$ python src/main.py ... --resource-pack-book --copy-existing-versions +# Include Minecraft data (stored locally in /.cache) and Addons (stored locally in /addons) +$ python src/main.py ... --use-mcmeta --use-addons + +# Include the old versions (stored in /assets/versions) +$ python src/main.py ... --copy-existing-versions # For 'old' local versions # When generating an old version to commit diff --git a/src/context.py b/src/context.py index 1c0542144e..3d00c42c8a 100644 --- a/src/context.py +++ b/src/context.py @@ -6,6 +6,7 @@ from i18n import I18n from components import text_formatter from loader import Loader +from versions import IS_RESOURCE_PACK import util import json @@ -17,7 +18,7 @@ class Context: - def __init__(self, tfc_dir: str, output_dir: str, root_dir: str, use_mcmeta: bool, use_addons: bool, debug_i18n: bool, resource_pack: bool): + def __init__(self, tfc_dir: str, output_dir: str, root_dir: str, use_mcmeta: bool, use_addons: bool, debug_i18n: bool): self.tfc_dir = tfc_dir self.output_root_dir = output_dir self.root_dir = root_dir @@ -25,7 +26,6 @@ def __init__(self, tfc_dir: str, output_dir: str, root_dir: str, use_mcmeta: boo self.loader: Loader = Loader(tfc_dir, output_dir, use_mcmeta, use_addons) self.last_context = None self.debug_i18n = debug_i18n - self.resource_pack = resource_pack self.categories: Dict[str, Category] = {} self.entries: Dict[str, Entry] = {} @@ -52,7 +52,7 @@ def __init__(self, tfc_dir: str, output_dir: str, root_dir: str, use_mcmeta: boo self.blocks_failed = 0 def resource_dir(self, path: str) -> str: - return util.path_join(self.tfc_dir, BOOK_DIR % ('assets' if self.resource_pack else 'data'), self.lang, path) + return util.path_join(self.tfc_dir, BOOK_DIR % ('assets' if IS_RESOURCE_PACK else 'data'), self.lang, path) def with_lang(self, lang: str): self.lang = lang diff --git a/src/main.py b/src/main.py index b4bb3e26dc..c7b959d201 100644 --- a/src/main.py +++ b/src/main.py @@ -30,7 +30,6 @@ def main(): # Version handling parser.add_argument('--old-version-key', type=str, dest='old_version_key', default=None, help='If present, the key of the old version to generate') parser.add_argument('--copy-existing-versions', action='store_true', dest='copy_existing_versions', default=False, help='If present, this will copy existing old versions from /assets/versions/ into the root output directory') - parser.add_argument('--resource-pack-book', action='store_true', dest='resource_pack_book', default=False, help='If the book is stored as a resource pack (core content in /assets/) vs. not (core content in /data/)') # External resources parser.add_argument('--use-mcmeta', action='store_true', dest='use_mcmeta', help='Download Minecraft and Forge source') @@ -86,7 +85,7 @@ def main(): LOG.info('Setting root output dir to "%s"' % root_dir) - context = Context(tfc_dir, out_dir, root_dir, use_mcmeta, use_addons, args.debug_i18n, args.resource_pack_book) + context = Context(tfc_dir, out_dir, root_dir, use_mcmeta, use_addons, args.debug_i18n) if use_mcmeta: mcmeta.load_cache() @@ -98,6 +97,10 @@ def main(): os.makedirs('addons/%s-%s' % (addon.mod_id, addon.version), exist_ok=True) subprocess.call('git clone -b %s https://github.com/%s/%s addons/%s-%s' % (addon.version, addon.user, addon.repo, addon.mod_id, addon.version), shell=True) + # This is a hack - we don't want git submodules or sub-repos to be present, but keep the cache around + # So just delete the /.git/ folder + shutil.rmtree('addons/%s-%s/.git' % (addon.mod_id, addon.version), True) + LOG.info('Generating docs...') LOG.debug('Running with:\n tfc_dir = %s\n out_dir = %s\n langs = %s\n version = %s' % ( tfc_dir, out_dir, versions.LANGUAGES, versions.VERSION @@ -130,7 +133,7 @@ def parse_book(context: Context, use_addons: bool): if use_addons: for addon in versions.ADDONS: - addon_dir = util.path_join(addon.book_dir(context.resource_pack), context.lang, 'categories') + addon_dir = util.path_join(addon.book_dir(versions.IS_RESOURCE_PACK), context.lang, 'categories') for category_file in util.walk(addon_dir): parse_category(context, addon_dir, category_file, is_addon=True) @@ -141,7 +144,7 @@ def parse_book(context: Context, use_addons: bool): if use_addons: for addon in versions.ADDONS: - addon_dir = util.path_join(addon.book_dir(context.resource_pack), context.lang, 'entries') + addon_dir = util.path_join(addon.book_dir(versions.IS_RESOURCE_PACK), context.lang, 'entries') for entry_file in util.walk(addon_dir): parse_entry(context, addon_dir, entry_file) diff --git a/src/versions.py b/src/versions.py index f4bd22ecfd..b9eaa78085 100644 --- a/src/versions.py +++ b/src/versions.py @@ -58,6 +58,8 @@ class OldVersion(NamedTuple): TFC_VERSION = '%s - %s' % (MC_VERSION, VERSION) +IS_RESOURCE_PACK = MC_VERSION != '1.18.2' + if __name__ == '__main__': print(VERSION)