Update LDoc helper scripts for separating armor into mods (#80)

This commit is contained in:
Jordan Irwin 2022-09-07 12:58:12 -07:00 committed by GitHub
parent 9444afd722
commit c7ee559a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 49 deletions

39
.ldoc/crafting.luadoc Normal file
View File

@ -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 │ │
-- └───┴───┴───┘ └───┴───┴───┘

View File

@ -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

View File

@ -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))