build: single-file bundles build/Rosetta.luau + build/rosetta.lua (tools/bundle.py), terse README with generated format / codec tables
- tools/bundle.py: every module a function in __FILES with a cached __include; requires become __include calls, so only the API and its load-time requires run on require. Rosetta._internal(path) includes any module by its src path. --!native modules get @native on each function (NATIVE re-checked on the bundle); linemaps map bundle lines back to sources (--where). LuaJIT bundle inlines the compat prelude. - tools/build.py: the multi-file trees move to build/_modules (gitignored); each target also writes its bundle. - tools/test.sh: api + docs/example tests also run against both bundles; fails when build/ is stale. - default.project.json mounts build/Rosetta.luau; examples/love loads build/rosetta.lua. - README: one line, install, quick start, doc links, generated format table and codec list (tools/gen_registry.py), licence TODO. DOCS lint checks the generated sections and the links.
This commit is contained in:
1 parent
0bd7b87d2b
commit
bcf6d46fb7
16 files changed
+399611
-210
No files matched your search
+18
-19
@@ -20,9 +20,10 @@
|
||||
# DUP no copy-pasted code: a function body of DUP_LINES (12) or more code lines whose tokens (comments and
|
||||
# whitespace dropped, identifiers kept) equal another module's function body fails; move it down to a
|
||||
# shared module (core / codecs / containers) and call it from both.
|
||||
# DOCS the module lists in README.md's Layout block and docs/STYLE.md's layer block name every codec
|
||||
# (codecs/<domain>/<Name>), container and core module in the tree; README.md's format counts
|
||||
# ("images (25)", ...) match the registry (docs/FORMATS.md); docs/guide/README.md links every guide page.
|
||||
# DOCS docs/STYLE.md's layer block names every codec (codecs/<domain>/<Name>), container and core module in the
|
||||
# tree; README.md's generated format table and codec list (<!-- formats:begin --> ... <!-- codecs:end -->)
|
||||
# match tools/gen_registry.py's output; README.md links every docs/guide page, docs/API.md and
|
||||
# docs/STYLE.md; docs/guide/README.md links every guide page.
|
||||
import os, re, sys
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -347,7 +348,7 @@ for dom in sorted(os.listdir(os.path.join(SRC, "codecs"))):
|
||||
modules += ["codecs/%s/%s" % (dom, n) for n in sorted(module_names("codecs/" + dom))]
|
||||
modules += ["containers/" + n for n in sorted(module_names("containers"))]
|
||||
modules += ["core/" + n for n in sorted(module_names("core"))]
|
||||
for doc in ("README.md", os.path.join("docs", "STYLE.md")):
|
||||
for doc in (os.path.join("docs", "STYLE.md"),):
|
||||
path = os.path.join(ROOT, doc)
|
||||
ln, block = layout_block(path)
|
||||
if not block:
|
||||
@@ -357,23 +358,21 @@ for doc in ("README.md", os.path.join("docs", "STYLE.md")):
|
||||
if not re.search(r"(?<![\w/])" + re.escape(m.rsplit("/", 1)[1]) + r"\b", block):
|
||||
bad(path, ln, "DOCS: the layout block does not list %s" % m)
|
||||
|
||||
LABELS = {"image": "images", "audio": "audio", "video": "video", "model": "3D models", "cad": "CAD", "font": "fonts",
|
||||
"archive": "archives", "data": "data", "vector": "vector graphics and tile maps", "layered": "layered images",
|
||||
"subtitle": "subtitles", "music": "music", "playlist": "playlists"}
|
||||
counts = {}
|
||||
for line in open(os.path.join(ROOT, "docs", "FORMATS.md"), encoding="utf-8"):
|
||||
cells = [c.strip() for c in line.split("|")]
|
||||
if len(cells) > 3 and cells[1] in LABELS:
|
||||
counts[cells[1]] = counts.get(cells[1], 0) + 1
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import gen_registry
|
||||
readme = os.path.join(ROOT, "README.md")
|
||||
rtext = open(readme, encoding="utf-8").read()
|
||||
m = re.search(r"(\d+) formats:", rtext)
|
||||
if not m or int(m.group(1)) != sum(counts.values()):
|
||||
bad(readme, 1, "DOCS: README.md should say \"%d formats:\" (docs/FORMATS.md)" % sum(counts.values()))
|
||||
for cat, label in LABELS.items():
|
||||
m = re.search(r"\s+".join(map(re.escape, label.split())) + r"\s+\((\d+)\)", rtext)
|
||||
if not m or int(m.group(1)) != counts.get(cat, 0):
|
||||
bad(readme, 1, "DOCS: README.md should say \"%s (%d)\" (docs/FORMATS.md)" % (label, counts.get(cat, 0)))
|
||||
want = gen_registry.readme(gen_registry.scan(), readme)
|
||||
for tag in ("formats", "codecs"):
|
||||
begin, end = "<!-- %s:begin -->" % tag, "<!-- %s:end -->" % tag
|
||||
if begin not in rtext or end not in rtext:
|
||||
bad(readme, 1, "DOCS: README.md has no generated %s section (%s ... %s)" % (tag, begin, end))
|
||||
if rtext != want:
|
||||
bad(readme, 1, "DOCS: README.md's generated format / codec sections are out of date (python3 -I tools/gen_registry.py)")
|
||||
for link in ["docs/guide/" + n for n in sorted(os.listdir(os.path.join(ROOT, "docs", "guide"))) if n.endswith(".md")] + \
|
||||
["docs/API.md", "docs/STYLE.md"]:
|
||||
if "](%s)" % link not in rtext:
|
||||
bad(readme, 1, "DOCS: README.md does not link %s" % link)
|
||||
|
||||
guide = os.path.join(ROOT, "docs", "guide")
|
||||
gindex = open(os.path.join(guide, "README.md"), encoding="utf-8").read()
|
||||
|
||||
Reference in new issue
Block a user