@diplodoc/ajv

中文文档
0.14.0发布于 2026/11/11MITTypeScriptCommonJS构建来源已验证近 30 天下载 1.2万

Diplodoc JSON schemas (toc, presets, frontmatter, page-constructor, and more) with editor enrichment

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. How schemas are maintained
  4. Development

english | русский


NPM version Quality Gate Status Coverage Maintainability Rating Reliability Rating Security Rating

@diplodoc/ajv

JSON schemas for Diplodoc configuration files (toc.yaml, presets.yaml, frontmatter, page-constructor, theme, redirects, leading pages, .yfm, .yfmlint). The schemas are enriched with editor metadata (markdownDescription, defaultSnippets, titles) so they power autocompletion and inline docs in editors such as the Diplodoc VS Code extension.

Install

npm install @diplodoc/ajv

Usage

import {schemas, tocSchema, type SchemaName} from '@diplodoc/ajv';

// the toc.yaml schema
console.log(tocSchema.title);

// or look one up by name
const name: SchemaName = 'presets-schema';
const schema = schemas[name];

The raw JSON files are also published and can be imported directly:

import tocSchema from '@diplodoc/ajv/schemas/toc-schema.json';

How schemas are maintained

  • Source of truth: src/yaml/*.yaml — full, ready-to-use schemas. Edit only the YAML.
  • Generated output: src/json/*.json — produced from the YAML by the build script. These are committed and shipped.

The build script does one thing: parse YAML and write JSON (formatted with Prettier). No overlays, no transformations.

npm run build:schemas          # regenerate src/json from src/yaml
# or, the exported CLI:
npx diplodoc-ajv-build-schemas

You never edit the JSON by hand. On every pull request the sync-schemas workflow regenerates the JSON from the YAML and commits the result back to the PR branch, so the JSON always matches the YAML.

Development

npm install
npm run build      # build:schemas + bundle + d.ts
npm test
npm run typecheck
npm run lint

版本与发布记录

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

版本发布日期距今
0.14.0latest2026/11/11今天
0.13.02026/11/101 天前
0.12.02026/11/057 天前
0.11.02026/10/1626 天前
0.10.02026/09/301 个月前
0.9.02026/09/241 个月前

关于 @diplodoc/ajv 的常见问题

@diplodoc/ajv 是什么?

Diplodoc JSON schemas (toc, presets, frontmatter, page-constructor, and more) with editor enrichment

如何安装 @diplodoc/ajv?

在项目目录运行 npm install @diplodoc/ajv,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 diplodoc-ajv-build-schemas,可以用 npx diplodoc-ajv-build-schemas 直接运行。

@diplodoc/ajv 支持 TypeScript 吗?

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

@diplodoc/ajv 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@diplodoc/ajv 可以商用吗?

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

@diplodoc/ajv 的下载量有多少?

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

@diplodoc/ajv 还在维护吗?

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