Skip to content
25 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Docs know what code they describe; a project's docs folder in Docs; Docs events; files on any S3 store1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { isRepoDoc, pickRepoDocs, repoDocTitle } from "./repo-docs.ts";
5
6test("a project's docs are Markdown under docs/ and the README at the root", () => {
7 assert.ok(isRepoDoc("README.md"));
8 assert.ok(isRepoDoc("docs/guide/setup.md"));
9 assert.ok(isRepoDoc("docs/a.mdx"));
10 assert.ok(!isRepoDoc("src/README.md"));
11 assert.ok(!isRepoDoc("docs/logo.png"));
12 assert.ok(!isRepoDoc("documentation/a.md"));
13 assert.deepEqual(
14 pickRepoDocs([{ path: "docs/b.md" }, { path: "src/x.ts" }, { path: "docs/a.md" }, { path: "README.md" }]).map((f) => f.path),
15 ["README.md", "docs/a.md", "docs/b.md"],
16 );
17});
18
19test("a file's title is its front matter's, its first heading, or its name", () => {
20 assert.equal(repoDocTitle("docs/a.md", "---\ntitle: \"Setting up\"\n---\n# Other"), "Setting up");
21 assert.equal(repoDocTitle("docs/a.md", "Intro\n\n# The **real** title\n"), "The real title");
22 assert.equal(repoDocTitle("docs/getting-started.md", "no heading"), "Getting started");
23 assert.equal(repoDocTitle("README.md", "text"), "README");
24 assert.equal(repoDocTitle("docs/deploy/README.md", "text"), "deploy");
25});