From c7ee559a4c6c56a367616293c195380249f04802 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Wed, 7 Sep 2022 12:58:12 -0700 Subject: [PATCH] Update LDoc helper scripts for separating armor into mods (#80) --- .ldoc/crafting.luadoc | 39 ++++++++++++++++++++++++++++++++++++ .ldoc/gendoc.sh | 6 +++--- .ldoc/parse_crafts.py | 46 ------------------------------------------- 3 files changed, 42 insertions(+), 49 deletions(-) create mode 100644 .ldoc/crafting.luadoc delete mode 100755 .ldoc/parse_crafts.py diff --git a/.ldoc/crafting.luadoc b/.ldoc/crafting.luadoc new file mode 100644 index 0000000..7f24674 --- /dev/null +++ b/.ldoc/crafting.luadoc @@ -0,0 +1,39 @@ + +--- 3D Armor Crafting +-- +-- @topic crafting + + +--- Craft recipes for helmets, chestplates, leggings, boots, & shields. +-- +-- @craft armor +-- @usage +-- Key: +-- - m: material +-- - wood: group:wood +-- - cactus: default:cactus +-- - steel: default:steel_ingot +-- - bronze: default:bronze_ingot +-- - diamond: default:diamond +-- - gold: default:gold_ingot +-- - mithril: moreores:mithril_ingot +-- - crystal: ethereal:crystal_ingot +-- - nether: nether:nether_ingot +-- +-- helmet: chestplate: leggings: +-- ┌───┬───┬───┐ ┌───┬───┬───┐ ┌───┬───┬───┐ +-- │ m │ m │ m │ │ m │ │ m │ │ m │ m │ m │ +-- ├───┼───┼───┤ ├───┼───┼───┤ ├───┼───┼───┤ +-- │ m │ │ m │ │ m │ m │ m │ │ m │ │ m │ +-- ├───┼───┼───┤ ├───┼───┼───┤ ├───┼───┼───┤ +-- │ │ │ │ │ m │ m │ m │ │ m │ │ m │ +-- └───┴───┴───┘ └───┴───┴───┘ └───┴───┴───┘ +-- +-- boots: shield: +-- ┌───┬───┬───┐ ┌───┬───┬───┐ +-- │ │ │ │ │ m │ m │ m │ +-- ├───┼───┼───┤ ├───┼───┼───┤ +-- │ m │ │ m │ │ m │ m │ m │ +-- ├───┼───┼───┤ ├───┼───┼───┤ +-- │ m │ │ m │ │ │ m │ │ +-- └───┴───┴───┘ └───┴───┴───┘ diff --git a/.ldoc/gendoc.sh b/.ldoc/gendoc.sh index df70dc8..886137b 100755 --- a/.ldoc/gendoc.sh +++ b/.ldoc/gendoc.sh @@ -31,7 +31,7 @@ rm -rf "${d_export}" # generate items, settings, & crafts topics temp files echo -e "\ngenerating temp files ..." -for script in "src" "settings" "crafts"; do +for script in src settings; do script="${d_ldoc}/parse_${script}.py" if test ! -f "${script}"; then echo "ERROR: script doesn't exist: ${script}" @@ -57,7 +57,7 @@ if test ${retval} -ne 0; then fi echo -e "\ncleaning temp files ..." -rm -vf "${d_ldoc}/"*.luadoc +find "${d_ldoc}" -type f -name "*.luadoc" ! -name "crafting.luadoc" -exec rm -vf {} + # HACK: ldoc does not seem to like the "shields:" prefix echo -e "\ncompensating for LDoc's issue with \"shields:\" prefix ..." @@ -72,7 +72,7 @@ sed -i \ printf "\ncopying textures ..." mkdir -p "${d_data}" texture_count=0 -for d_mod in "3d_armor" "shields"; do +for d_mod in armor_* shields; do printf "\rcopying textures from ${d_mod} ...\n" for png in $(find "${d_root}/${d_mod}/textures" -maxdepth 1 -type f -name "*.png"); do if test -f "${d_data}/$(basename ${png})"; then diff --git a/.ldoc/parse_crafts.py b/.ldoc/parse_crafts.py deleted file mode 100755 index ea0af47..0000000 --- a/.ldoc/parse_crafts.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -# This script will parse source files for craft recipes. - -import sys, os, codecs, errno - - -path = os.path.realpath(__file__) -script = os.path.basename(path) -d_root = os.path.dirname(os.path.dirname(path)) -d_ldoc = os.path.join(d_root, ".ldoc") - -craftfile = os.path.realpath(os.path.join(d_root, "3d_armor/armor.lua")) -if not os.path.isfile(craftfile): - print("ERROR: craft file does not exist for parsing: {}".format(craftfile)) - sys.exit(errnor.ENOENT) - -buffer = codecs.open(craftfile, "r", "utf-8") -if not buffer: - print("ERROR: could not open file for reading: {}".format(craftfile)) - sys.exit(errno.EIO) - -data_in = buffer.read() -buffer.close() - -craft = "" - -data_in = data_in.replace("\r\n", "\n").replace("\r", "\n") -for sect in data_in.split("\n---"): - if "@craft armor" in sect: - sect = "---{}".format(sect) - for li in sect.split("\n"): - if li.startswith("--"): - craft = "{}\n{}".format(craft, li) - -outfile = os.path.join(d_ldoc, "crafting.luadoc") - -buffer = codecs.open(outfile, "w", "utf-8") -if not buffer: - print("ERROR: could not open file for writing: {}".format(outfile)) - sys.exit(errno.EIO) - -buffer.write("\n--- 3D Armor Crafting\n--\n-- @topic crafting\n\n{}\n".format(craft)) -buffer.close() - -print("crafts exported to\t{}".format(outfile))