Elixir Documentation Review
Quick Reference
references/spec-coverage.md |
Review Checklist
Module Documentation
- - [ ] All public modules have @moduledoc
- [ ] First-line summary is concise (one line, used by tools as summary)
- [ ] @moduledoc includes ## Examples where appropriate
- [ ] @moduledoc false only on internal/implementation modules
Function Documentation
- - [ ] All public functions have @doc
- [ ] All public functions have @spec
- [ ] @doc describes return values clearly
- [ ] Multi-clause functions documented before first clause
- [ ] Function head declared when arg names need clarification
Doctests
- - [ ] Doctests present for pure, deterministic functions
- [ ] No doctests for side-effectful operations (DB, HTTP, etc.)
- [ ] Doctests actually run (module included in test file)
Cross-References
- - [ ] Module references use backtick auto-linking (
MyModule) - [ ] Function refs use proper arity format (
function/2) - [ ] Type refs use t: prefix (
t:typename/0) - [ ] No plain-text references where auto-links are possible
Metadata
- - [ ] @since annotations on new public API additions
- [ ] @deprecated with migration guidance where appropriate
Valid Patterns (Do NOT Flag)
- - @doc false on callback implementations - Documented at behaviour level
- @doc false on protocol implementations - Protocol docs cover the intent
- Missing @spec on private functions - @spec optional for internals
- Short @moduledoc without ## Examples on simple utility modules - Not every module needs examples
- Using @impl true without separate @doc - Inherits documentation from behaviour
Context-Sensitive Rules
| Issue | Flag ONLY IF |
|---|
| Missing @moduledoc | Module is public AND not a protocol impl |
| Missing @spec |
Function is public AND exported |
| Missing doctests | Function is pure AND deterministic |
| Generic @doc | Doc restates function name without adding value |
When to Load References
- - Reviewing @moduledoc or @doc quality, seeing anti-patterns -> doc-quality.md
- Reviewing @spec, @type, or @typedoc coverage -> spec-coverage.md
Before Submitting Findings
Load and follow review-verification-protocol before reporting any issue.
Elixir 文档审查
快速参考
references/spec-coverage.md |
审查清单
模块文档
- - [ ] 所有公开模块均包含 @moduledoc
- [ ] 首行摘要简洁明了(单行,供工具用作摘要)
- [ ] @moduledoc 在适当情况下包含 ## 示例
- [ ] 仅在内部/实现模块中使用 @moduledoc false
函数文档
- - [ ] 所有公开函数均包含 @doc
- [ ] 所有公开函数均包含 @spec
- [ ] @doc 清晰描述返回值
- [ ] 多子句函数在第一个子句前编写文档
- [ ] 当参数名称需要澄清时声明函数头
文档测试
- - [ ] 对纯函数、确定性函数编写文档测试
- [ ] 不针对有副作用的操作(数据库、HTTP 等)编写文档测试
- [ ] 文档测试实际可运行(模块已包含在测试文件中)
交叉引用
- - [ ] 模块引用使用反引号自动链接(MyModule)
- [ ] 函数引用使用正确的参数数量格式(function/2)
- [ ] 类型引用使用 t: 前缀(t:typename/0)
- [ ] 在可能使用自动链接的情况下不使用纯文本引用
元数据
- - [ ] 新增公开 API 添加 @since 注解
- [ ] 在适当情况下使用 @deprecated 并附迁移指南
有效模式(请勿标记)
- - 回调实现上的 @doc false - 已在行为层面编写文档
- 协议实现上的 @doc false - 协议文档已涵盖意图
- 私有函数缺少 @spec - 内部函数可选择性使用 @spec
- 简单工具模块的简短 @moduledoc 不包含 ## 示例 - 并非每个模块都需要示例
- 使用 @impl true 而不单独编写 @doc - 从行为继承文档
上下文相关规则
| 问题 | 仅在以下情况标记 |
|---|
| 缺少 @moduledoc | 模块是公开的且非协议实现 |
| 缺少 @spec |
函数是公开的且已导出 |
| 缺少文档测试 | 函数是纯函数且确定性的 |
| 泛泛的 @doc | 文档仅重复函数名称而无实际价值 |
何时加载参考文档
- - 审查 @moduledoc 或 @doc 质量,发现反模式 -> doc-quality.md
- 审查 @spec、@type 或 @typedoc 覆盖率 -> spec-coverage.md
提交发现前
在报告任何问题前,请加载并遵循 审查验证协议。