Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/providers/clickhouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ is overridden, for the trailing-clause trap in [§3.8](#38-the-preparequery-over

### 2.4 Registration & lifecycle

The factory wires ClickHouse in via a dynamic import
([`factory.ts:87`](../../src/lib/db/factory.ts)):
The factory wires ClickHouse in via a dynamic import inside `createDatabaseProvider()`
([`factory.ts`](../../src/lib/db/factory.ts)):

```ts
case 'clickhouse': {
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/couchbase.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ a SQL dialect is expressed through `queryLanguage: "sql"`, not through the class

### 2.4 Registration & lifecycle

The factory wires Couchbase in via a dynamic import
([`factory.ts:93`](../../src/lib/db/factory.ts)):
The factory wires Couchbase in via a dynamic import inside `createDatabaseProvider()`
([`factory.ts`](../../src/lib/db/factory.ts)):

```ts
case 'couchbase': {
Expand Down
3 changes: 2 additions & 1 deletion docs/providers/druid.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ the case [`docs/ADDING_A_PROVIDER.md`](../ADDING_A_PROVIDER.md) names ClickHouse

### 2.4 Registration & lifecycle

The factory wires Druid in via a dynamic import ([`factory.ts:95`](../../src/lib/db/factory.ts)):
The factory wires Druid in via a dynamic import inside `createDatabaseProvider()`
([`factory.ts`](../../src/lib/db/factory.ts)):

```ts
case "druid": {
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ both exports honestly thin (each one names its product and nothing else).

### 2.4 Registration & lifecycle

The factory wires the type-id in via a dynamic import
([factory.ts:118](../../src/lib/db/factory.ts)):
The factory wires the type-id in via a dynamic import inside `createDatabaseProvider()`
([`factory.ts`](../../src/lib/db/factory.ts)):

```ts
case "elasticsearch": {
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/libredb.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ out in parallel.
### 2.4 Registration & lifecycle

The factory wires LibreDB in via a dynamic import so the `@libredb/libredb` driver is only loaded
when a LibreDB connection is actually opened
([`factory.ts:100`](../../src/lib/db/factory.ts)):
when a LibreDB connection is actually opened by `createDatabaseProvider()`
([`factory.ts`](../../src/lib/db/factory.ts)):

```ts
case 'libredb': {
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/opensearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ OpenSearchProvider (search/index.ts:967) ElasticsearchProvider (search/i

### 2.4 Registration & lifecycle

The factory wires the type-id in via a dynamic import
([factory.ts:123](../../src/lib/db/factory.ts)):
The factory wires the type-id in via a dynamic import inside `createDatabaseProvider()`
([`factory.ts`](../../src/lib/db/factory.ts)):

```ts
case "opensearch": {
Expand Down
3 changes: 2 additions & 1 deletion docs/providers/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ rather than reimplementing them:
### 2.3 Registration & lifecycle

The factory loads the provider via dynamic import so the `pg` driver is only pulled in when a
PostgreSQL connection is opened ([`factory.ts:62`](../../src/lib/db/factory.ts)):
PostgreSQL connection is opened by `createDatabaseProvider()`
([`factory.ts`](../../src/lib/db/factory.ts)):

```ts
case 'postgres': {
Expand Down
28 changes: 21 additions & 7 deletions tests/unit/provider-docs-monitoring-citations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
* same eight, and the docs in scope carry no `:<line>` suffix.
*
* SCOPE, deliberately narrow: the whole of every document in `NAMED_CITATIONS`, plus the
* monitoring seam of the two search docs. The rest of `docs/providers/` still cites code by line
* in quantity — a pre-existing backlog this round did not open — and the two search docs are
* guarded only inside their monitoring section. Nothing here asserts that the uncovered
* monitoring seam of the two search docs, plus one file across every provider doc: `factory.ts`
* is cited by its entry point and never by a line. The rest of `docs/providers/` still cites code
* by line in quantity — a pre-existing backlog this round did not open — and the two search docs
* are guarded only inside their monitoring section. Nothing here asserts that the uncovered
* citations are correct; they are simply not measured yet.
*/
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { readdirSync, readFileSync } from "node:fs";
import path from "node:path";

const ROOT = path.resolve(import.meta.dir, "../..");
Expand All @@ -43,6 +44,12 @@ const BASE_PROVIDER = "src/lib/db/base-provider.ts";
const MIGRATION_GENERATOR = "src/lib/schema-diff/migration-generator.ts";
const FACTORY = "src/lib/db/factory.ts";

/** Sorted: `readdirSync` returns filesystem order — green here, red on the next machine. */
const PROVIDER_DOCS = readdirSync(path.join(ROOT, "docs/providers"))
.filter((entry) => entry.endsWith(".md"))
.sort()
.map((entry) => `docs/providers/${entry}`);

/**
* The docs this round rewrote, the source their prose links to, and the method names that now
* stand where a line number used to. The list is the point: renaming any of these breaks the
Expand Down Expand Up @@ -238,13 +245,20 @@ describe("provider docs rewritten this round: code cited by name, whole file", (
}

test("provider docs name the factory's entry point rather than a line inside it", () => {
for (const { doc } of NAMED_CITATIONS.filter((citation) =>
read(citation.doc).includes("`createDatabaseProvider()`"),
)) {
// Selected on the entry point's NAME, not on the link: fourteen docs link `factory.ts`, and
// one of them (oracle.md) does so without naming the function — prose it does not owe.
const docs = PROVIDER_DOCS.filter((doc) => read(doc).includes("`createDatabaseProvider()`"));
// A derived population can derive to nothing, and a loop over nothing passes; renaming the
// phrase everywhere used to shed four assertions and stay green (#620).
expect(docs.length).toBeGreaterThan(0);
for (const doc of docs) {
expect(read(doc)).toMatch(
/`createDatabaseProvider\(\)`\s*\(\[`factory\.ts`\]\(\.\.\/\.\.\/src\/lib\/db\/factory\.ts\)\)/,
);
}
for (const doc of PROVIDER_DOCS) {
expect(read(doc), `${doc} cites a line inside factory.ts`).not.toMatch(/factory\.ts:\d/);
}
expect(read(FACTORY)).toMatch(/^export async function createDatabaseProvider\(/m);
});
});
Expand Down
Loading