Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

docs: the docs recipe links a new device note from examples/README.md

xbsheng1e5fa3b6ab84
diff --git a/docs/workflows/docs-notes.md b/docs/workflows/docs-notes.md
index 615588026..a97b7a8ea 100644
--- a/docs/workflows/docs-notes.md
+++ b/docs/workflows/docs-notes.md
@@ -8,6 +8,10 @@
- A fix for something your agent got stuck on usually belongs in `PROMPT.md` as one extra sentence, kept
brand-neutral. Brand-specific knowledge goes in `examples/` or `docs/devices/`. Changes to the safety rules
themselves go to the maintainer.
+- A note in `docs/devices/` is linked from a page a reader comes through: the row for its folder in
+ `examples/README.md` when the model has a list of its own, and the "Notes for models that have no tested list
+ yet" section of that page when it has not. `tests/test_device_notes_index.py` fails on a note nothing links,
+ which is how three of them were found sitting unread.
- Several tests pin facts in `docs/devices/` notes, `PROMPT.md` and `docs/TROUBLESHOOTING.md` (the
`tests/test_*_note.py` files). If you reword one of those passages, run the suite and keep the fact.
- Docs and the README stay in step: a new list gets its `tv.json` (the TV tables are generated from it), and a
diff --git a/tests/test_docs_notes_recipe_index.py b/tests/test_docs_notes_recipe_index.py
new file mode 100644
index 000000000..0e83f4d07
--- /dev/null
+++ b/tests/test_docs_notes_recipe_index.py
@@ -0,0 +1,154 @@
+"""The docs recipe asks for the link that keeps a new docs/devices/ note findable.
+
+`docs/workflows/docs-notes.md` is the page AGENTS.md's workflow list and CONTRIBUTING's routing table
+send a contributor to for "a troubleshooting entry, a fix to PROMPT.md, or any other docs change", and
+its own second bullet is what sends brand-specific knowledge into `docs/devices/`. The page said what
+a note holds and that several tests pin facts inside one, but not the one thing
+`tests/test_device_notes_index.py` refuses a note without: a link from a page a reader comes through -
+the row of its folder in `examples/README.md` when the model has a list of its own, or that page's
+"Notes for models that have no tested list yet" section when it has not. A note written from the page
+as it read left the suite red: `docs/devices/<name>.md : notes nothing links to (add them to
+examples/README.md, either to the row of their list or to the notes index)`.
+
+Nothing here copies the rule: the section heading the index is read by, the row rule and the
+repo-wide sweep all come from `tests/test_device_notes_index.py`, and two tests below run that
+checker over a tree written here - a note nothing links has to be reported, and the same note linked
+from `examples/README.md` has to be quiet - so a checker that stops enforcing fails this pair instead
+of letting the page pass silently.
+
+Run from the repository root: python3 -m unittest discover -s tests -v
+"""
+import re
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+from test_device_notes_index import ( # noqa: E402
+ NOTE_INDEX_HEADING,
+ index_notes,
+ unlinked_notes,
+)
+
+ROOT = Path(__file__).resolve().parents[1]
+PAGE = ROOT / "docs" / "workflows" / "docs-notes.md"
+
+BULLET = re.compile(r"^-\s+(.*)$")
+CHECK = "tests/test_device_notes_index.py"
+
+
+def bullets(text):
+ """The page's top-level bullets, each joined across the lines it is wrapped over."""
+ out, current = [], None
+ for line in text.split("\n"):
+ match = BULLET.match(line)
+ if match:
+ if current is not None:
+ out.append(current)
+ current = match.group(1).strip()
+ continue
+ if current is None:
+ continue
+ if not line.strip():
+ out.append(current)
+ current = None
+ elif line[:1] in (" ", "\t"):
+ current = f"{current} {line.strip()}"
+ else:
+ out.append(current)
+ current = None
+ if current is not None:
+ out.append(current)
+ return out
+
+
+def index_bullets(text):
+ """The bullets that send a new docs/devices note to examples/README.md."""
+ return [b for b in bullets(text) if "docs/devices" in b and "examples/README.md" in b]
+
+
+def page_text():
+ return PAGE.read_text(encoding="utf-8")
+
+
+class RecipeSendsANoteToTheIndexTest(unittest.TestCase):
+ def test_one_bullet_sends_a_new_note_to_the_index(self):
+ found = index_bullets(page_text())
+ named_elsewhere = [b for b in bullets(page_text()) if "docs/devices" in b]
+ self.assertEqual(
+ len(found), 1,
+ f"{PAGE.name} has {len(found)} bullets naming both docs/devices/ and examples/README.md: the "
+ f"bullet that sends a note into docs/devices/ has to say where it is linked from, or a note "
+ f"written from the page fails {CHECK}. Bullets naming docs/devices/ today: {named_elsewhere}",
+ )
+
+ def test_the_bullet_names_where_in_the_index(self):
+ bullet = index_bullets(page_text())[0]
+ self.assertIn(NOTE_INDEX_HEADING, bullet,
+ f"the bullet has to name the section a list-less note is filed under, the heading "
+ f"{CHECK} reads it by")
+ self.assertIn("row", bullet.lower(),
+ "the bullet has to name the examples/README.md row a note with a list of its own goes in")
+
+ def test_the_bullet_names_the_check(self):
+ self.assertIn(CHECK, index_bullets(page_text())[0],
+ "the bullet has to name the check, so a reader who skips it knows which test failed")
+
+
+class TheCheckerStillBitesTest(unittest.TestCase):
+ def note_tree(self, index_body):
+ """A tree with one device note and an examples/README.md whose notes section is `index_body`."""
+ tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(tmp.cleanup)
+ root = Path(tmp.name)
+ (root / "docs" / "devices").mkdir(parents=True)
+ (root / "docs" / "devices" / "lonely.md").write_text("# A device note\n", encoding="utf-8")
+ (root / "examples").mkdir()
+ (root / "examples" / "README.md").write_text(
+ f"# Lists\n\n| Folder | Model |\n|---|---|\n\n## {NOTE_INDEX_HEADING}\n\n{index_body}\n",
+ encoding="utf-8",
+ )
+ return root
+
+ def test_a_note_nothing_links_is_reported(self):
+ root = self.note_tree("")
+ self.assertEqual(unlinked_notes(root), ["docs/devices/lonely.md"])
+
+ def test_the_same_note_linked_from_the_index_is_quiet(self):
+ root = self.note_tree("- [A note](../docs/devices/lonely.md), Android 9: what it shows.")
+ self.assertEqual(unlinked_notes(root), [])
+ self.assertEqual(index_notes(root), ["lonely.md"])
+
+ def test_a_link_outside_the_index_section_is_still_a_link(self):
+ root = self.note_tree("")
+ (root / "examples" / "README.md").write_text(
+ f"# Lists\n\nSee [the note](../docs/devices/lonely.md) from its row instead.\n\n"
+ f"## {NOTE_INDEX_HEADING}\n\n",
+ encoding="utf-8",
+ )
+ self.assertEqual(unlinked_notes(root), [])
+ self.assertEqual(index_notes(root), [], "a link outside the section is not an index entry")
+
+
+class TheBulletReaderTest(unittest.TestCase):
+ def test_a_wrapped_bullet_is_one_bullet(self):
+ text = (f"- A note in `docs/devices/` is linked from `examples/README.md`, under the\n"
+ f" \"{NOTE_INDEX_HEADING}\" heading.\n")
+ self.assertEqual(len(index_bullets(text)), 1)
+ self.assertIn(NOTE_INDEX_HEADING, index_bullets(text)[0])
+
+ def test_a_mention_outside_a_bullet_is_not_a_bullet(self):
+ text = ("A note in `docs/devices/` is linked from `examples/README.md`, and that is all this line says.\n")
+ self.assertEqual(index_bullets(text), [])
+
+ def test_a_page_without_such_a_bullet_reads_as_empty(self):
+ text = ("- Brand-specific knowledge goes in `examples/` or `docs/devices/`.\n"
+ "- Docs and the README stay in step.\n")
+ self.assertEqual([b for b in bullets(text) if "docs/devices" in b],
+ ["Brand-specific knowledge goes in `examples/` or `docs/devices/`."])
+ self.assertEqual(index_bullets(text), [])
+
+
+if __name__ == "__main__":
+ unittest.main()