Skip to content

Commit

Permalink
Add config option to include official monsters
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Oct 7, 2023
1 parent 0046bf0 commit 729a308
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions cbpickaxe_scripts/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@
@dataclass
class MonsterForms:
paths: List[str]
include_official: bool

@staticmethod
def from_dict(d: Dict[Any, Any]) -> "MonsterForms":
paths = d.get("paths", [])
include_official = d.get("include_official", False)

assert isinstance(include_official, bool)

assert isinstance(paths, list)
for p in paths:
assert isinstance(p, str)
paths = cast(List[str], paths)

return MonsterForms(paths)
return MonsterForms(paths=paths, include_official=include_official)


@dataclass
Expand Down Expand Up @@ -128,11 +132,12 @@ def main(argv: List[str]) -> int:
for name, root in config.roots.items():
hoylake.load_root(name, pathlib.Path(root))

monster_forms = {}
for monsters_path in OFFICIAL_MONSTER_FORM_PATHS + config.monster_forms.paths:
if monsters_path.endswith(".tres"):
monster_forms = {monsters_path: hoylake.load_monster_form(monsters_path)}
monster_forms[monsters_path] = hoylake.load_monster_form(monsters_path)
else:
monster_forms = hoylake.load_monster_forms(monsters_path)
monster_forms.update(hoylake.load_monster_forms(monsters_path))

for moves_path in OFFICIAL_MOVE_PATHS + config.moves.paths:
_ = hoylake.load_moves(moves_path)
Expand All @@ -143,20 +148,23 @@ def main(argv: List[str]) -> int:
monster_form_images_dir = monster_forms_dir / "sprites"
monster_form_images_dir.mkdir()

monster_path, (_, monster_form) = sorted(monster_forms.items())[0]
monster_page_filepath = monster_forms_dir / (
hoylake.translate(monster_form.name) + ".html"
)
with open(monster_page_filepath, "w", encoding="utf-8") as output_stream:
create_monster_form_page(
monster_path,
monster_form,
hoylake,
monster_form_template,
monster_forms_dir,
monster_form_images_dir,
output_stream,
for monster_path, (root_name, monster_form) in monster_forms.items():
if not config.monster_forms.include_official and root_name == "cassette_beasts":
continue

monster_page_filepath = monster_forms_dir / (
hoylake.translate(monster_form.name) + ".html"
)
with open(monster_page_filepath, "w", encoding="utf-8") as output_stream:
create_monster_form_page(
monster_path,
monster_form,
hoylake,
monster_form_template,
monster_forms_dir,
monster_form_images_dir,
output_stream,
)

return SUCCESS

Expand Down

0 comments on commit 729a308

Please sign in to comment.