Files

22 lines
1.1 KiB
Python

# Docs inputs for the Source engine sections of the scene page (tools/fixtures.py; tools/docs_check.py explains the
# inputs): the CS:GO-style VBSP of tools/fixtures/vbsp.py (srctools-saved, static props v11) and the Hammer VMF of
# tools/fixtures/vmf.py.
# tests/gen/docs_source.luau { files = { [name] = bytes }, vars = { vbspBytes = "room.bsp", vmfText = "room.vmf" } }
import importlib.util, json, os
INPUTS = ["tools/docs_check.py", "tools/fixtures/vbsp.py", "tools/fixtures/vmf.py"]
def mod(ctx, name):
spec = importlib.util.spec_from_file_location("fx_" + name, os.path.join(ctx.root, "tools", name + ".py") if name == "docs_check" else os.path.join(ctx.root, "tools", "fixtures", name + ".py"))
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
def generate(ctx):
res = json.loads(ctx.python(["srctools"], mod(ctx, "vbsp").CODE))
files = {"room.bsp": next(bytes.fromhex(c["data"]) for c in res["cases"] if c["name"] == "csgo")}
files["room.vmf"] = mod(ctx, "vmf").room().encode()
mod(ctx, "docs_check").emit_inputs(ctx, files, {"vbspBytes": "room.bsp", "vmfText": "room.vmf"})