Files
Neo-DesktopandClaude Opus 5.5 3cf239ff20 Make go3270 a support library: free the Purple Book
go3270 is a support library of bbs, not a core repository. Remove it from
pages/suite.yml (the bar and the home page cards), REPOS in tools/gen.py,
the suite CSS and the suite table. Remove its banner and social preview.
Purple (DDCD) is now a free Book.

brand_ref.py now lists the free Books from the Books that REPOS does not
use. docs/sites.md tells how to remove a core repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRh4dhs1LGg2Sj8h67
Signed-off-by: Neo-Desktop <321592+Neo-Desktop@users.noreply.github.com>
2026-11-28 06:37:17 +00:00

139 lines
5.7 KiB
Python

#!/usr/bin/env python3
"""docs/reference.md from the code: each repository's Book, colour, icon and
taglines (REPOS in tools/gen.py), the palette, and tools/art.py's command
line. It also checks that the list of the suite's core repositories
(pages/suite.yml, which the sites' theme uses) gives each repository the
colour gen.py does, and that each of them is in gen.py.
python3 tools/brand_ref.py writes the page
python3 tools/brand_ref.py --check exit 1 if it is out of date, or the theme disagrees
"""
import argparse
import os
import re
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import art # noqa: E402
import gen # noqa: E402
OUT = os.path.join(gen.ROOT, "docs", "reference.md")
SUITE = os.path.join(gen.ROOT, "pages", "suite.yml")
def cell(s):
s = s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
return " ".join(s.replace("|", "\\|").split())
def swatch(color):
return '<span class="suite-swatch" style="background:%s"></span> `%s`' % (color, color)
# Return the problems of pages/suite.yml: a core repository that is not in
# REPOS of tools/gen.py, or that has a different colour there.
def theme_problems():
sys.path.insert(0, os.path.join(gen.ROOT, "pages"))
import suite # noqa: E402
out = []
for r in suite.load(SUITE):
name = r["name"]
if name not in gen.REPOS:
out.append("pages/suite.yml has %s, tools/gen.py REPOS does not" % name)
elif gen.REPOS[name]["color"].lower() != r["colour"].lower():
out.append("pages/suite.yml gives %s %s, tools/gen.py %s"
% (name, r["colour"], gen.REPOS[name]["color"]))
return out
# Return the Books that no repository in REPOS of tools/gen.py uses, as
# (name, colour) pairs: the Rainbow Books first, then the other free Books.
def free_books():
used = {r["book"] for r in gen.REPOS.values()}
books = [(n, c) for n, _, c in gen.BOOKS] + list(art.FREE.items())
return [(n, c) for n, c in books if n not in used]
def usage():
rows = []
for a in art.parser()._actions:
if isinstance(a, argparse._HelpAction):
continue
if a.option_strings:
name = ", ".join("`%s`" % o for o in a.option_strings)
arg = "" if a.nargs == 0 else (a.metavar or a.dest.upper())
else:
name, arg = "`%s`" % a.dest, "..." if a.nargs == "*" else ""
choices = ", ".join("`%s`" % c for c in a.choices) if a.choices else ""
help_text = a.help or ""
help_text = help_text[0].upper() + help_text[1:]
if choices:
help_text += " (%s)" % choices
rows.append("| %s | %s | %s |\n" % (name, cell(arg), cell(help_text)))
return rows
def page():
b = ["<!-- Made by tools/brand_ref.py from tools/gen.py and tools/art.py: "
"change the code (or the script), not this page. -->\n\n",
"# Reference\n\n",
"This page gives the colours of the suite and the art of each "
"repository, as `tools/gen.py` draws them. It also gives the command "
"line of `tools/art.py`. "
"[Palette, type and the app icon](palette.md) tells why they are so. "
"[Assets](assets.md) tells how to make the images.\n\n",
"## Repositories\n\n",
"The Rainbow Book of each repository is its accent: on its banner, "
"its social preview and its site.\n\n",
"| repository | Book | colour | icon | tagline | second line | tags |\n",
"|---|---|---|---|---|---|---|\n"]
for name, r in list(gen.REPOS.items()) + [("suite", gen.SUITE)]:
fmt = gen.BOOK.get(r["book"], (None,))[0]
book = r["book"] + (" (%s)" % fmt if fmt else "")
b.append("| `%s` | %s | %s | `%s` | %s | %s | %s |\n" % (
name, book, swatch(r["color"]), r["icon"], cell(r["tag"]), cell(r["sub"]),
", ".join(r.get("chips", []))))
b += ["\n`suite` is the banner and social preview of the organization (for "
"its profile and website), with the mark in all six Books.\n\n",
"## Palette\n\n",
"### Rainbow Books\n\n",
"| Book | format | colour |\n|---|---|---|\n"]
for n, fmt, c in gen.BOOKS:
b.append("| %s | %s | %s |\n" % (n, fmt, swatch(c)))
b += ["\nThe free Books, for a repository that does not have a Book yet "
"(`tools/art.py --book`):\n\n",
"| Book | colour |\n|---|---|\n"]
for n, c in free_books():
b.append("| %s | %s |\n" % (n, swatch(c)))
b += ["\n### The other colours\n\n", "| name | colour | use |\n|---|---|---|\n"]
for n, use in (("BG", "background"), ("BG2", "the second shade of the background"),
("INK", "text"), ("DIM", "muted text"), ("GREEN", "the carrier, and the accent of the suite")):
b.append("| `%s` | %s | %s |\n" % (n, swatch(getattr(gen, n)), use))
b += ["\nType: %s.\n\n" % cell(gen.FONT.replace("'", "")),
"## tools/art.py\n\n",
"Makes the banner and social preview of a repository, and puts the "
"banner in its checkout.\n\n",
" python3 tools/art.py [names...] [options]\n\n",
"| argument | value | what it does |\n|---|---|---|\n"]
b += usage()
return "".join(b)
def main():
problems = theme_problems()
text = page()
old = open(OUT, encoding="utf-8").read() if os.path.exists(OUT) else None
if "--check" in sys.argv[1:]:
if old != text:
problems.append("docs/reference.md is out of date: run python3 tools/brand_ref.py")
elif old != text:
with open(OUT, "w", encoding="utf-8") as f:
f.write(text)
for p in problems:
print("brand_ref: " + p, file=sys.stderr)
return 1 if problems else 0
if __name__ == "__main__":
sys.exit(main())