Say who each route author is, with a biography from the database
Mirror to forge / mirror (push) Canceled after 0s
Validate / validate (push) Canceled after 0s
Validate / history (push) Canceled after 0s
Validate / site (push) Canceled after 0s
Validate / deploy (push) Canceled after 0s

authors.toml gains a summary, a biography, the author's own site and
the pages each was read on, for people only. An author's page now
opens with the name and the summary, shows a joint credit only on the
route it applies to, and carries an About section after the routes.
People with three or more routes lead the authors page. Organisations
get no biography.

35 people have a summary and a biography and 4 a summary only, each
statement checked against the page it cites. Wilderness Mindset is
recorded as two people. The Sawtooth Wilderness High Route is credited
to Eric Poulin, who names himself as the author of Seeking Lost.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-17 12:09:34 -07:00
1 parent d7fb6483a2
commit f467fcb560
15 files changed
+1136 -123

No files matched your search

+87 -4
View File
@@ -3,11 +3,13 @@
glossary.toml [[term]] id, term, definition, optional source_url, see
collections.toml [[collection]] id, name, members, definition, source_url, source_publisher
[[list]] key, home (the lists the home page shows, and their order)
authors.toml [[author]] name, credits, optional kind
authors.toml [[author]] name, credits, optional kind, url, summary, bio, checked,
[[author.source]] (url, publisher)
Each function appends one message per problem to `errors`. Used by tools/validate.py, which passes
the records it has read. Python 3 standard library only. Fields are in docs/schema.md.
"""
import datetime
import os
import re
import sys
@@ -15,6 +17,17 @@ import tomllib
ID_RE = re.compile(r"[a-z0-9]+(-[a-z0-9]+)*")
DASH_RE = re.compile(r"[–—]| - ")
DATE_RE = re.compile(r"\d{4}-\d{2}-\d{2}")
# authors.toml: what an [[author]] entry may hold, and the limits on its words.
# person (the default): one named person. people: human, but not one full name (a pair credited
# together, or a person known by a blog's name). organisation: credited, but given nothing more.
AUTHOR_KINDS = ("person", "people", "organisation")
AUTHOR_ABOUT = ("summary", "bio", "checked", "source") # for people only; refused on an organisation
AUTHOR_KEYS = {"name", "credits", "kind", "url", "summary", "bio", "checked", "source"}
AUTHOR_SOURCE_KEYS = {"url", "publisher"}
SUMMARY_MAX = 160 # characters
BIO_WORDS = (40, 130)
def built_in_list_keys():
@@ -179,9 +192,9 @@ def check_author_entries(entries, routes, errors, where="authors.toml"):
errors.append(f"{where}: entry {i} must be a table ([[author]])")
continue
who = f"{where}: {a.get('name') or 'entry ' + str(i)}"
check_unknown(a, {"name", "credits", "kind"}, who, errors)
if a.get("kind", "person") not in ("person", "organisation"):
errors.append(f"{who} kind must be person or organisation")
check_unknown(a, AUTHOR_KEYS, who, errors)
if a.get("kind", "person") not in AUTHOR_KINDS:
errors.append(f"{who} kind must be one of {', '.join(AUTHOR_KINDS)}")
name = _text(a, "name", who, errors)
if name in seen_names:
errors.append(f"{who} duplicate name")
@@ -198,6 +211,76 @@ def check_author_entries(entries, routes, errors, where="authors.toml"):
seen_credits[c].append(name)
if name and name.lower() not in c.lower():
errors.append(f"{who} credit {c!r} does not contain the name")
if a.get("kind") == "organisation":
for k in AUTHOR_ABOUT:
if k in a:
errors.append(f"{who} is an organisation: {k} is for people only")
_url(a, "url", who, errors)
else:
check_author_about(a, name, who, errors)
def _date(value, where, field, errors):
"""A date written YYYY-MM-DD (a string, or a TOML date), real and not in the future."""
text = value.isoformat() if isinstance(value, datetime.date) and not isinstance(value, datetime.datetime) else value
if not isinstance(text, str) or not DATE_RE.fullmatch(text):
errors.append(f"{where} {field} must be a date (YYYY-MM-DD)")
return
try:
day = datetime.date.fromisoformat(text)
except ValueError:
errors.append(f"{where} {field} {text!r} is not a real date")
return
if day > datetime.date.today():
errors.append(f"{where} {field} {text} is in the future")
def check_author_about(a, name, who, errors):
"""The words about an author: url, summary, bio, checked and [[author.source]]."""
_url(a, "url", who, errors)
summary = _text(a, "summary", who, errors, required=False)
bio = _text(a, "bio", who, errors, required=False)
if summary:
if len(summary) > SUMMARY_MAX:
errors.append(f"{who} summary is {len(summary)} characters; at most {SUMMARY_MAX}")
if name and not summary.lower().startswith(name.lower()):
errors.append(f"{who} summary must begin with the name {name!r}")
if "\n" in summary or not summary.endswith("."):
errors.append(f"{who} summary must be one sentence on one line, ending with a full stop")
if DASH_RE.search(summary):
errors.append(f"{who} summary uses a dash as punctuation")
if bio:
n = len(bio.split())
if not BIO_WORDS[0] <= n <= BIO_WORDS[1]:
errors.append(f"{who} bio is {n} words; it must be {BIO_WORDS[0]} to {BIO_WORDS[1]}")
if "\n" in bio.strip():
errors.append(f"{who} bio must be one paragraph on one line")
if not bio.rstrip().endswith((".", "?", "!")):
errors.append(f"{who} bio must end with a full stop")
if DASH_RE.search(bio):
errors.append(f"{who} bio uses a dash as punctuation")
about = bool(summary or bio)
if "checked" in a:
_date(a["checked"], who, "checked", errors)
elif about:
errors.append(f"{who} has a summary or bio but no checked date")
sources = a.get("source")
if sources is None:
if about:
errors.append(f"{who} has a summary or bio but no [[author.source]]")
elif not isinstance(sources, list) or not sources or not all(isinstance(x, dict) for x in sources):
errors.append(f"{who} source must be one or more [[author.source]] tables")
else:
for i, src in enumerate(sources, 1):
where = f"{who} source {i}"
check_unknown(src, AUTHOR_SOURCE_KEYS, where, errors)
_url(src, "url", where, errors, required=True)
_text(src, "publisher", where, errors)
urls = [x.get("url") for x in sources]
if len(set(urls)) != len(urls):
errors.append(f"{who} lists a source twice")
if not about and ("checked" in a or sources is not None):
errors.append(f"{who} has checked or [[author.source]] but no summary or bio")
def check_datafiles(root, trails, errors):
+74 -1
View File
@@ -88,11 +88,84 @@ class AuthorTest(unittest.TestCase):
self.assertEqual(run(C.check_author_entries, [dict(AUTHOR, credits=["Jo Walker"])], self.ROUTES), [])
self.assertTrue(run(C.check_author_entries, [dict(AUTHOR, credits=[])], self.ROUTES))
def test_kind_is_a_person_or_an_organisation(self):
def test_kind_is_a_person_people_or_an_organisation(self):
self.assertEqual(run(C.check_author_entries, [dict(AUTHOR, kind="organisation")], self.ROUTES), [])
self.assertEqual(run(C.check_author_entries, [dict(AUTHOR, kind="people")], self.ROUTES), [])
self.assertTrue(any("kind" in e for e in run(C.check_author_entries, [dict(AUTHOR, kind="other")], self.ROUTES)))
self.assertTrue(any("kind" in e for e in run(C.check_author_entries, [dict(AUTHOR, kind="band")], self.ROUTES)))
BIO = " ".join(["Jo Walker worked out a long route across the hills and wrote a guide to it."] * 4)
ABOUT = dict(AUTHOR, url="https://jowalker.example/", summary="Jo Walker is a hiker who works out long routes.",
bio=BIO, checked="2026-11-17", source=[{"url": "https://jowalker.example/about/", "publisher": "Jo Walker"}])
class AuthorAboutTest(unittest.TestCase):
ROUTES = AuthorTest.ROUTES
def errs(self, **changes):
entry = dict(ABOUT, **changes)
for k in [k for k, v in changes.items() if v is None]:
del entry[k]
return run(C.check_author_entries, [entry], self.ROUTES)
def has(self, text, **changes):
errs = self.errs(**changes)
self.assertTrue(any(text in e for e in errs), errs)
def test_a_full_entry_passes_and_the_fields_are_optional(self):
self.assertEqual(self.errs(), [])
self.assertEqual(run(C.check_author_entries, [AUTHOR], self.ROUTES), [])
self.assertEqual(self.errs(bio=None), []) # a summary alone, with its source and date
self.assertEqual(self.errs(summary=None), []) # a bio alone
self.assertEqual(self.errs(checked=__import__("datetime").date(2026, 11, 17)), []) # a TOML date
def test_summary_length_and_name(self):
self.has("at most 160", summary="Jo Walker " + "walks far. " * 20)
self.assertEqual(self.errs(summary="Jo Walker " + "x" * (160 - len("Jo Walker ") - 1) + "."), [])
self.has("must begin with the name", summary="A hiker, Jo Walker, works out routes.")
self.has("one sentence", summary="Jo Walker works out routes")
self.has("dash", summary="Jo Walker — a hiker.")
def test_bio_length(self):
self.has("words", bio="Jo Walker hikes.")
self.has("words", bio=" ".join(["word"] * 131) + ".")
self.assertEqual(self.errs(bio=" ".join(["word"] * 130) + "."), [])
self.assertEqual(self.errs(bio=" ".join(["word"] * 40) + "."), [])
self.has("one paragraph", bio=BIO + "\n\n" + BIO[:40] + ".")
def test_sources_and_date_are_required_with_words(self):
self.has("no [[author.source]]", source=None)
self.has("source must be", source=[])
self.has("no checked date", checked=None)
self.has("must be a date", checked="17 November 2026")
self.has("not a real date", checked="2026-02-30")
self.has("in the future", checked="2999-01-01")
self.has("source 1 is missing required field publisher", source=[{"url": "https://x.example/"}])
self.has("http", source=[{"url": "x.example", "publisher": "X"}])
self.has("source twice", source=ABOUT["source"] * 2)
self.has("but no summary or bio", summary=None, bio=None)
def test_a_pair_of_people_may_carry_the_words(self):
pair = dict(ABOUT, name="Jo and Sam", credits=["Jo and Sam"], kind="people",
summary="Jo and Sam are a couple who hike long routes together.")
self.assertEqual(run(C.check_author_entries, [pair], [("r3", "Jo and Sam")]), [])
def test_nothing_biographical_on_an_organisation(self):
org = dict(ABOUT, kind="organisation")
errs = run(C.check_author_entries, [org], self.ROUTES)
for k in ("summary", "bio", "checked", "source"):
self.assertTrue(any(f"organisation: {k} is for people only" in e for e in errs), (k, errs))
self.assertEqual(run(C.check_author_entries, [dict(AUTHOR, kind="organisation", url="https://club.example/")], self.ROUTES), [])
self.assertTrue(run(C.check_author_entries, [dict(AUTHOR, kind="organisation", url="club.example")], self.ROUTES))
self.assertTrue(run(C.check_author_entries, [dict(AUTHOR, kind="organisation", motto="x")], self.ROUTES))
def test_urls_and_unknown_keys(self):
self.has("url must be an http(s) address", url="jowalker.example")
self.has("unknown field", nickname="Jo")
self.has("unknown field", source=[{"url": "https://x.example/", "publisher": "X", "note": "n"}])
class RealFilesTest(unittest.TestCase):
def test_the_repository_files_pass(self):
import validate as V