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
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"test:integration": "vitest run src/__tests__",
"migrate-data": "node scripts/migrate-data.mjs",
"patch-content": "node scripts/patch-content.mjs",
"links": "lychee --config lychee.toml --root-dir \"$(pwd)/dist\" 'dist/**/*.html'"
"links": "lychee --config lychee.toml --root-dir \"$(pwd)/dist\" 'dist/**/*.html'",
"prebuild": "node scripts/fetch-api-reference.mjs",
"fetch:api": "node scripts/fetch-api-reference.mjs"
},
"dependencies": {
"@astrojs/mdx": "^7.0.2",
Expand Down Expand Up @@ -46,4 +48,4 @@
"typescript": "^6.0.3",
"vitest": "^4.1.10"
}
}
}
43 changes: 43 additions & 0 deletions scripts/fetch-api-reference.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node
// Fetches the generated API references from the pubid repos (pubid#577)
// into the content collection at build time, so the website assembles
// the library reference without committing generated files. Pinned to
// each repo's main; raw.githubusercontent serves the branch head.
import { writeFileSync, mkdirSync } from "node:fs";

const SOURCES = [
{
repo: "pubid/pubid",
file: "docs/api-reference.md",
out: "src/content/library/api-reference-ruby.md",
title: "API Reference — Ruby (pubid)",
description: "Generated from YARD over the pubid gem sources.",
},
{
repo: "pubid/pubid-ts",
file: "docs/api-reference.md",
out: "src/content/library/api-reference-ts.md",
title: "API Reference — TypeScript (pubid-ts)",
description: "Generated from TypeDoc over the pubid-ts sources.",
},
];

const frontmatter = (title, description) => `---
title: "${title}"
description: "${description}"
---

`;

mkdirSync("src/content/library", { recursive: true });
for (const { repo, file, out, title, description } of SOURCES) {
const url = `https://raw.githubusercontent.com/${repo}/main/${file}`;
const res = await fetch(url);
if (!res.ok) {
console.error(`${url}: ${res.status}`);
process.exit(1);
}
const body = await res.text();
writeFileSync(out, frontmatter(title, description) + body);
console.log(`${out}: ${body.split("\n").length} lines from ${repo}@main`);
}
18 changes: 6 additions & 12 deletions src/content/library/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,14 @@ For example, ISO has:
- `Pubid::Iso::Identifiers::Amendment`
- etc.

## Registry
## Full Reference (generated)

The `Pubid::IdentifierRegistry` provides lookup capabilities:
The complete, generated references — every public entry point with its
signature and docstring — are built from the sources themselves and
cannot drift from the code (CI regenerates them on every change):

```ruby
# Find by flavor and type
Pubid::IdentifierRegistry.find_by_type(:iso, :is)

# Get all identifiers for a flavor
Pubid::IdentifierRegistry.all_for_flavor(:iso)

# Export as JSON
Pubid::IdentifierRegistry.to_json
```
- [Ruby — the pubid gem (YARD)](/library/api-reference-ruby/)
- [TypeScript — pubid-ts (TypeDoc)](/library/api-reference-ts/)

## See Also

Expand Down
Loading