@zudojs/docs
v1.1.0
Published
Documentation infrastructure with structured document model, registry, validation, navigation, and generation.
Downloads
108
Maintainers
Readme
@zudojs/docs
Documentation infrastructure with structured document model, registry, validation, navigation, frontmatter parsing, and markdown/JSON generation.
Documentation: zudojs.oyinlola.site/docs/packages-docs · For AI agents: Markdown version, llms.txt
Installation
npm install @zudojs/docsQuick Start
import {
createDocumentRegistry,
createMarkdownDocument,
validateAll,
generateIndex,
} from "@zudojs/docs";
const registry = createDocumentRegistry();
registry.register(
createMarkdownDocument(
"getting-started",
"Getting Started",
"# Getting Started\n\nWelcome to Zudojs...",
{ category: "introduction", tags: ["intro"] },
),
);
// Or build the document object yourself
registry.register({
id: "guides.http.routing",
title: "HTTP Routing",
content: { type: "markdown", value: "# Routing\n\n..." },
});
const result = validateAll(registry.getAll());
if (!result.valid) {
console.error(result.issues);
}
const index = generateIndex(registry.getAll()); // SERVER-only docs excludedFeatures
- Document model with frontmatter (
parseFrontmatter/serializeFrontmatterround-trip safely;tagsalways parses to a string array, and the body keeps its indentation) - Document registry and discovery (
DuplicateDocumentErroron duplicate IDs, deep-frozen copies) - Navigation tree helpers (breadcrumbs, siblings, previous/next, cycle-safe walkers)
- Markdown and JSON generation with escaping for untrusted content: structured text is HTML-escaped and links are limited to http, https, mailto, tel, ftp and ftps (others are written as plain text)
- Fail-closed
visibilityfiltering: only an unset or exactly"CLIENT"visibility reaches a client index stripMarkdownand link validation run in linear time on untrusted input- Document, link and navigation validation with a single
validrule (errors only);javascript:and other non-allow-listed link schemes areUNSAFE_LINKerrors in every link form — inline[x](…)(including targets with parentheses or a title), reference definitions[x]: …, raw<a href="…">and<scheme:…>autolinks BROKEN_LINKandNAVIGATION_ORPHAN_DOCUMENTare warnings by default; pass{ brokenLinkSeverity: "error", orphanSeverity: "error" }tovalidateAll(orbrokenLinkSeveritytovalidateLinks) to fail on dead links or unreachable documentscreateDocument({ …, strict: true })rejects an unknowncategory,statusorvisibilityat creation instead of leaving it tovalidateDocument; documents never carry explicitundefinedkeysgetAdjacent(id, nav, { scope: "tree" })walks previous/next across section boundaries in reading order (the default stays within one level)- Documentation error classes re-exported from
@zudojs/errors
Use Cases
- API documentation
- User guides
- Knowledge bases
- Documentation sites
