name: shirushi description: 用于Git仓库的文档ID管理。验证、分配和跟踪Markdown/YAML文件中的不可变doc_id。在处理doc_id、文档ID、“@see docid”引用、文档完整性验证或shirushi命令时使用。
Shirushi - 文档ID管理器
Shirushi通过CI集成,确保Git仓库中一致、不可变的文档ID。
命令
| 命令 | 用途 |
|---|---|
shirushi lint |
验证doc_id和索引完整性 |
shirushi scan |
列出带有元数据的文档 |
shirushi show <id> |
通过doc_id获取文档信息 |
shirushi assign |
为新文档分配ID |
shirushi rehash |
重新计算内容哈希值 |
常见工作流
提交前验证
shirushi lint --base HEAD~1
通过ID查找文档
shirushi show PCE-SPEC-2025-0001-G
为新文档添加doc_id
shirushi assign docs/new-spec.md
列出所有文档
shirushi scan --format table
检查PR中的更改
shirushi lint --base origin/main --check-references
配置
配置定义在 .shirushi.yml 中:
id_format: "{COMP}-{KIND}-{YEAR4}-{SER4}-{CHK1}"
dimensions:
COMP:
type: enum
values: ["API", "UI", "DB"]
KIND:
type: enum_from_doc_type
mapping:
spec: SPEC
adr: ADR
YEAR4:
type: year
digits: 4
SER4:
type: serial
digits: 4
scope: ["COMP", "KIND", "YEAR4"]
CHK1:
type: checksum
algorithm: mod26AZ
digits: 1
文档格式
文档使用YAML前言:
---
doc_id: API-SPEC-2025-0001-G
title: API规范
doc_type: spec
---
# 内容在此...
@see docid 引用
在代码注释中引用文档:
// @see API-SPEC-2025-0001-G
function handleRequest() { ... }
Shirushi跟踪这些引用,并在引用的文档发生更改时发出警告。