@doqs/analog

中文文档
0.15.0发布于 2026/11/02MITTypeScriptES Module构建来源已验证近 30 天下载 2677

Composable Markdown documentation UI for Analog.js

原始使用文档
文档目录12 节
  1. What it is
  2. Supported environment
  3. Installation
  4. First working example
  5. Deterministic Markdown (recommended)
  6. Content authoring (optional)
  7. Localization (0.12)
  8. Adopting it in an existing site (0.11)
  9. Command-line tools
  10. Public package surface
  11. Links
  12. Contributing
Doqs — Documentation that belongs in your app

@doqs/analog

Documentation that lives inside your Angular and Analog app. A Markdown-driven documentation region — routing, sidebar, table of contents, index, code blocks, optional static search live Angular components via ::demo[id] and interactive component playgrounds via ::playground[id] — while your header, footer, routes, theme and components stay yours.

npm License: MIT Repository

What it is

Doqs adds a documentation region to an Angular application that already uses Analog. Markdown files become routes, a grouped sidebar, a table of contents, previous/next links and a mobile drawer, prerendered as static HTML. Your header, footer, router, theme and components stay yours; Doqs sets no global html or body styles.

Optional, each off until you enable it: Pagefind full-text search, versioned documentation, API reference pages generated from your TypeScript, your own standalone Angular components placed in Markdown with ::demo[id], and interactive playgrounds (::playground[id]) that add controls for the component's inputs, an output inspector, preview widths, an expanded view (native modal by default; expandedPreview: 'overlay-compatible' for components whose overlays are mounted on <body>), reset and copyable usage code. Built in: callouts, accessible tabs, code groups, steps and titled code.

This README is deliberately short. The guides live in the official documentation, whose Markdown source is apps/site/src/content/docs; the site itself is a Doqs application.

Supported environment

RequirementRange
Node.js^20.19.0 || ^22.12.0 || >=24.0.0
Angular^21.2.2 || ^22.0.0
@analogjs/content^2.9.2
pagefind (search only, optional)^1.5.0
typescript (API generation only, optional)^5.5.0 || ^6.0.0

Verified: Angular 21.2 with TypeScript 5.9 and Angular 22.2 with TypeScript 6.0, both with Analog 2.9.2 and zoneless change detection. Production documentation pages hydrate their prerendered DOM in place; packed initialized consumers pass direct loads, navigation and Back/Forward on Angular 21 embedded, Angular 21 docs-first and Angular 22 embedded. doq doctor --build also detects a build whose scripts need the Angular JIT compiler, an intermittent upstream Analog build race described in the changelog. Zone.js: an Angular 21 application with zone.js and provideZoneChangeDetection() passes the consumer journey (not tested on Angular 22). Focused Linux Firefox/WebKit and Windows Chromium browser journeys pass in hosted CI (spec 0021). Screen-reader output and WCAG conformance are not verified. Peer ranges are not widened without testing; doq doctor checks the versions installed in your project against them.

Installation

pnpm add @doqs/analog @analogjs/content @analogjs/router prismjs

First working example

Run the integration helper from your application's root. It creates src/doq.paths.ts and two Markdown pages, never overwrites a file, and prints the exact snippets for what remains to connect (--dry-run previews it; --mode docs-first mounts the docs at /):

pnpm exec doq init
pnpm exec doq doctor

The connections are four small edits, shown in full on the Analog configuration page:

// src/doq.paths.ts (generated)
export const doqPaths = { contentDirectory: 'docs', basePath: '/docs' } as const;
// vite.config.ts
analog({
  ssr: true,
  static: true,
  content: { highlighter: 'prism' },
  prerender: { routes: async () => ['/', ...doqPrerenderRoutes(doqPaths)] },
}),
doqDeterministicMarkdown(), // from '@doqs/analog/vite'; recommended, see below
// src/app/app.config.ts
const doqConfig = defineDoqConfig({ ...doqPaths });
providers: [
  provideFileRouter(withExtraRoutes(doqRoutes(doqConfig))),
  provideContent(withMarkdownRenderer()),
  provideDoq(doqConfig),
];
/* src/styles.css */
@import '@doqs/analog/styles.css';

Add Markdown files with title, description, group and order frontmatter below src/content/docs, then pnpm build.

Analog renders Markdown files concurrently while heading ids come from a shared slugger, so with an asynchronous highlighter two files can swap duplicate-heading suffixes (usage-1/usage-2) and the build differs from run to run. doqDeterministicMarkdown() renders the files one at a time through Analog's own hook. It contains the upstream problem; it does not fix it. It is opt-in because Doqs cannot edit your Vite configuration, and doq init and doq doctor both point at it.

Content authoring (optional)

Keep examples connected to real source and stop copying text between pages. Author pages in their own directory, describe them in doq.content.json and let doq content generate write ordinary Markdown below your content directory:

::include{file="/_partials/prerequisites.md"}

::source{file="projects/lib/src/button.ts" region="usage" title="button.ts"}

See [[api:ButtonDirective]] for every input.
// projects/lib/src/button.ts
// #region doqs:usage
const config = provideButton({ size: 'md' });
// #endregion doqs:usage

Source files are read as text from the configured sourceRoots only, never executed, never fetched. Nothing is added to the browser bundle, and projects that do not use it need no configuration. See the guides Content authoring and Content tooling in the documentation.

Localization (0.12)

Configure independently authored Markdown directories for each locale with DoqPaths.i18n. The default locale keeps its existing URLs; other locales receive locale-prefixed routes. Provide a signal-backed DoqI18nAdapter through provideDoqI18n() to translate Doqs-owned interface text and connect the host's active locale. Set ownsRouting when the host owns localized route composition; adapter presence alone does not imply ownership. Playground controls and their validation, copy, dialog and announcement text use the same DOQ_DEFAULT_MESSAGES catalog. Localized Pagefind requests require locale metadata in the generated index and fail closed when it is missing. See the full Angular/Analog integration, archive composition, fallback, SSR/SSG and RTL example in the official Multilingual documentation guide. Verified in production builds (Showcase A: English, Spanish, Arabic; real Pagefind index; RTL; sticky TOC; Chromium, Firefox, WebKit). Limitations: live SSR answers HTTP 200 for a missing page because Analog 2.9 ignores RESPONSE_INIT (static hosting answers 404); screen readers and Windows browsers are untested. This is not a 1.0 readiness claim.

Adopting it in an existing site (0.11)

  • Import configuration from @doqs/analog/config (defineDoqConfig, provideDoq, doqPrerenderRoutes, the types): it imports only @angular/core, so it also loads in a vite.config.ts or a script, where the main entry does not.
  • landmark: 'host' when your shell already has a <main>; the default 'document' makes Doqs render it. Exactly one main either way.
  • unmatched: 'continue' lets host pages keep their URLs below the Doqs prefix, so pages migrate one at a time.

See the guide Adopting Doqs in an existing library site in the official documentation.

Command-line tools

BinaryPurpose
doqdoq init scaffolds; doq doctor diagnoses the integration (--json, --build, --strict)
doq-searchdoq-search index <siteDir> indexes prerendered output with Pagefind (after the build)
doq (content)doq content generate, check and watch resolve ::source{}, ::include{} and [[api:Name]] in authored pages into ordinary Markdown
doq-apidoq-api generate and doq-api check write and verify reference pages from a public TypeScript API

Public package surface

@doqs/analog (browser and server), @doqs/analog/config (configuration only, the preferred import for it), the Node-only @doqs/analog/vite, @doqs/analog/search-index, @doqs/analog/api-reference and @doqs/analog/content, and @doqs/analog/styles.css. The exports, their intended stability and the compatibility policy are on the Public API page and in docs/roadmap/1.0-readiness.md. CSS tokens are the --host-docs-* custom properties.

Contributing

Spec-driven; see CONTRIBUTING.md and AGENTS.md. MIT licensed.

版本与发布记录

@doqs/analog 共发布 12 个版本,首次发布于 2026/10/22;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.15.0latest2026/11/0211 天前
0.14.02026/11/0211 天前
0.13.02026/10/3014 天前
0.12.02026/10/2915 天前
0.11.02026/10/2519 天前
0.10.02026/10/2420 天前

关于 @doqs/analog 的常见问题

@doqs/analog 是什么?

Composable Markdown documentation UI for Analog.js

如何安装 @doqs/analog?

在项目目录运行 npm install @doqs/analog,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:rxjs(^7.8.0)、@angular/core(^21.2.2 || ^22.0.0)、@angular/common(^21.2.2 || ^22.0.0)、@angular/router(^21.2.2 || ^22.0.0)、@analogjs/content(^2.9.2)、@angular/platform-browser(^21.2.2 || ^22.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 doq、doq-api、doq-search,可以用 npx doq 直接运行。

@doqs/analog 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@doqs/analog 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@doqs/analog 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^20.19.0 || ^22.12.0 || >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@doqs/analog 可以商用吗?

@doqs/analog 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@doqs/analog 的下载量有多少?

根据 npm 官方下载统计,@doqs/analog 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,677 次,日均约 89 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@doqs/analog 还在维护吗?

最新版本 0.15.0 发布于 2026/11/02(11 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。