git 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -0
- data/CONTRIBUTING.md +185 -165
- data/LICENSE +1 -1
- data/README.md +151 -151
- data/git.gemspec +35 -3
- data/lib/git/command_line/base.rb +1 -2
- data/lib/git/commands/base.rb +1 -1
- data/lib/git/commands/cat_file/raw.rb +8 -7
- data/lib/git/repository/branching.rb +79 -5
- data/lib/git/version.rb +1 -1
- metadata +5 -94
- data/.claude/commands/address-copilot-reviews.md +0 -14
- data/.claude/settings.json +0 -16
- data/.claude/skills +0 -1
- data/.commitlintrc.yml +0 -38
- data/.dockerignore +0 -27
- data/.github/copilot-instructions.md +0 -30
- data/.github/hooks/bin-setup-on-worktree.json +0 -11
- data/.github/hooks/run-bin-setup-once.sh +0 -20
- data/.github/issue_template.md +0 -15
- data/.github/prompts/iteratively-address-copilot-reviews.prompt.md +0 -188
- data/.github/pull_request_template.md +0 -21
- data/.github/skills/breaking-change-analysis/SKILL.md +0 -99
- data/.github/skills/ci-cd-troubleshooting/SKILL.md +0 -264
- data/.github/skills/command-implementation/REFERENCE.md +0 -994
- data/.github/skills/command-implementation/SKILL.md +0 -230
- data/.github/skills/command-test-conventions/SKILL.md +0 -664
- data/.github/skills/command-yard-documentation/SKILL.md +0 -434
- data/.github/skills/dependency-management/SKILL.md +0 -72
- data/.github/skills/development-workflow/SKILL.md +0 -512
- data/.github/skills/facade-implementation/REFERENCE.md +0 -837
- data/.github/skills/facade-implementation/SKILL.md +0 -269
- data/.github/skills/facade-test-conventions/SKILL.md +0 -391
- data/.github/skills/facade-yard-documentation/SKILL.md +0 -435
- data/.github/skills/make-skill-template/SKILL.md +0 -226
- data/.github/skills/pr-readiness-review/SKILL.md +0 -205
- data/.github/skills/project-context/SKILL.md +0 -306
- data/.github/skills/pull-request-review/SKILL.md +0 -168
- data/.github/skills/rebase/SKILL.md +0 -148
- data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +0 -131
- data/.github/skills/release-management/SKILL.md +0 -125
- data/.github/skills/resolve-feedback/SKILL.md +0 -288
- data/.github/skills/review-arguments-dsl/CHECKLIST.md +0 -788
- data/.github/skills/review-arguments-dsl/SKILL.md +0 -214
- data/.github/skills/review-cross-command-consistency/SKILL.md +0 -139
- data/.github/skills/reviewing-skills/SKILL.md +0 -214
- data/.github/skills/rspec-unit-testing-standards/SKILL.md +0 -685
- data/.github/skills/tdd-refactor-step/SKILL.md +0 -236
- data/.github/skills/test-debugging/SKILL.md +0 -161
- data/.github/skills/yard-documentation/SKILL.md +0 -981
- data/.github/skills/yard-documentation/element-rules.md +0 -162
- data/.github/skills-deprecated/README.md +0 -21
- data/.github/skills-deprecated/extract-command-from-lib/SKILL.md +0 -487
- data/.github/skills-deprecated/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -22
- data/.github/skills-deprecated/extract-facade-from-base-lib/SKILL.md +0 -600
- data/.github/skills-deprecated/review-backward-compatibility/SKILL.md +0 -275
- data/.github/workflows/continuous_integration.yml +0 -358
- data/.github/workflows/enforce_conventional_commits.yml +0 -35
- data/.github/workflows/experimental_continuous_integration.yml +0 -59
- data/.github/workflows/release.yml +0 -52
- data/.github/workflows/warm_bundler_caches.yml +0 -82
- data/.gitignore +0 -30
- data/.husky/commit-msg +0 -1
- data/.husky/pre-commit +0 -13
- data/.release-please-config.json +0 -36
- data/.release-please-manifest.json +0 -3
- data/.rspec +0 -2
- data/.rubocop.yml +0 -44
- data/.rubocop_todo.yml +0 -30
- data/.yard-lint.yml +0 -75
- data/CLAUDE.md +0 -11
- data/Gemfile +0 -22
- data/Rakefile +0 -41
- data/docker/test/Dockerfile +0 -32
- data/docker/test/docker-compose.yml +0 -0
- data/package.json +0 -10
- data/redesign/1_architecture_existing.md +0 -102
- data/redesign/2_architecture_redesign.md +0 -449
- data/redesign/3_architecture_implementation.md +0 -1623
- data/redesign/Phase 4 - Step A.md +0 -366
- data/redesign/Phase 4 - Step B.md +0 -921
- data/redesign/Phase 4 - Step C.md +0 -833
- data/redesign/beta_release.md +0 -107
- data/redesign/branch_parse_refactor_plan.md +0 -163
- data/redesign/c1a-public-api-scope.tsv +0 -256
- data/redesign/c1c2_audit.md +0 -566
- data/redesign/c1c2_bucket6_lib_orphans.md +0 -626
- data/redesign/config_design.rb +0 -501
- data/redesign/index.md +0 -34
- data/redesign/info_object_migration_plan.md +0 -126
- data/redesign/integration_test_analysis.md +0 -521
- data/redesign/phase-4-step-b-test-audit.tsv +0 -485
- data/redesign/remote_refactor_plan.md +0 -164
- data/redesign/reverse_dependencies.sql +0 -44
- data/tasks/gem_tasks.rake +0 -14
- data/tasks/npm_tasks.rake +0 -7
- data/tasks/rspec.rake +0 -111
- data/tasks/rubocop.rake +0 -5
- data/tasks/test_gem.rake +0 -12
- data/tasks/yard.rake +0 -57
|
@@ -1,981 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: yard-documentation
|
|
3
|
-
description: "General YARD documentation rules and workflow for all Ruby source code. Use when writing or reviewing YARD doc comments, generating missing docs, updating examples, fixing doc errors, or checking documentation coverage."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# YARD Documentation
|
|
7
|
-
|
|
8
|
-
General YARD documentation rules and workflow for all Ruby source code.
|
|
9
|
-
|
|
10
|
-
## Contents
|
|
11
|
-
|
|
12
|
-
- [Contents](#contents)
|
|
13
|
-
- [How to use this skill](#how-to-use-this-skill)
|
|
14
|
-
- [Related skills](#related-skills)
|
|
15
|
-
- [Reference files](#reference-files)
|
|
16
|
-
- [Precedence](#precedence)
|
|
17
|
-
- [Workflow](#workflow)
|
|
18
|
-
- [Named length limits](#named-length-limits)
|
|
19
|
-
- [Step 1: Identify What Needs Documentation](#step-1-identify-what-needs-documentation)
|
|
20
|
-
- [Step 2: Write Documentation](#step-2-write-documentation)
|
|
21
|
-
- [Standard template (no `@overload`)](#standard-template-no-overload)
|
|
22
|
-
- [Overload template](#overload-template)
|
|
23
|
-
- [Overload decision matrix](#overload-decision-matrix)
|
|
24
|
-
- [Documenting anonymous splats with `@overload`](#documenting-anonymous-splats-with-overload)
|
|
25
|
-
- [Documenting other elements](#documenting-other-elements)
|
|
26
|
-
- [Step 3: Verify Documentation](#step-3-verify-documentation)
|
|
27
|
-
- [Line and summary length checks](#line-and-summary-length-checks)
|
|
28
|
-
- [Documentation Standards](#documentation-standards)
|
|
29
|
-
- [Formatting Rules](#formatting-rules)
|
|
30
|
-
- [Doc comment placement](#doc-comment-placement)
|
|
31
|
-
- [Blank lines around tags](#blank-lines-around-tags)
|
|
32
|
-
- [Never use raw blank lines inside a doc comment block](#never-use-raw-blank-lines-inside-a-doc-comment-block)
|
|
33
|
-
- [Short descriptions](#short-descriptions)
|
|
34
|
-
- [Line and summary length](#line-and-summary-length)
|
|
35
|
-
- [`@return` must always include a type](#return-must-always-include-a-type)
|
|
36
|
-
- [No shell calls in `@example` blocks](#no-shell-calls-in-example-blocks)
|
|
37
|
-
- [Blank lines within `@example` blocks](#blank-lines-within-example-blocks)
|
|
38
|
-
- [`@example` titles are required](#example-titles-are-required)
|
|
39
|
-
- [Cross-reference links only resolve to objects included in generated docs](#cross-reference-links-only-resolve-to-objects-included-in-generated-docs)
|
|
40
|
-
- [Inline code formatting](#inline-code-formatting)
|
|
41
|
-
- [Escaping opening braces in descriptions](#escaping-opening-braces-in-descriptions)
|
|
42
|
-
- [Cross-reference links](#cross-reference-links)
|
|
43
|
-
- [Type specifier conventions](#type-specifier-conventions)
|
|
44
|
-
- [`Array<...>` (collection) vs `Array(...)` (tuple)](#array-collection-vs-array-tuple)
|
|
45
|
-
- [`@api private` vs `@private`](#api-private-vs-private)
|
|
46
|
-
- [Class and module `@api` visibility (Required)](#class-and-module-api-visibility-required)
|
|
47
|
-
- [`@since` tags are not used](#since-tags-are-not-used)
|
|
48
|
-
- [`@todo` tags are not used](#todo-tags-are-not-used)
|
|
49
|
-
- [`@abstract`](#abstract)
|
|
50
|
-
- [Method Rules](#method-rules)
|
|
51
|
-
- [Short description](#short-description)
|
|
52
|
-
- [Standard tags](#standard-tags)
|
|
53
|
-
- [`@example` on non-private methods](#example-on-non-private-methods)
|
|
54
|
-
- [Yield tags](#yield-tags)
|
|
55
|
-
- [`@overload` for distinct signatures](#overload-for-distinct-signatures)
|
|
56
|
-
- [`@overload` for anonymous splats](#overload-for-anonymous-splats)
|
|
57
|
-
- [`@note` for callouts (Optional)](#note-for-callouts-optional)
|
|
58
|
-
- [`@deprecated` on deprecated methods](#deprecated-on-deprecated-methods)
|
|
59
|
-
- [`@api` on methods (Optional)](#api-on-methods-optional)
|
|
60
|
-
- [Command Reference](#command-reference)
|
|
61
|
-
|
|
62
|
-
## How to use this skill
|
|
63
|
-
|
|
64
|
-
Attach this file to your Copilot Chat context, then invoke it with the source
|
|
65
|
-
files that need YARD updates. Use it when adding new APIs, fixing doc warnings,
|
|
66
|
-
or improving existing YARD quality and examples.
|
|
67
|
-
|
|
68
|
-
Work top to bottom: follow the three-step [Workflow](#workflow), reaching into the
|
|
69
|
-
[Documentation Standards](#documentation-standards) reference below as you write,
|
|
70
|
-
and into [`element-rules.md`](element-rules.md) when documenting a class, module,
|
|
71
|
-
constant, attribute, dynamically defined method, or value object.
|
|
72
|
-
|
|
73
|
-
## Related skills
|
|
74
|
-
|
|
75
|
-
- [Command YARD Documentation](../command-yard-documentation/SKILL.md) — command-specific rules for writing and reviewing YARD docs on `Git::Commands::Base` subclasses
|
|
76
|
-
|
|
77
|
-
## Reference files
|
|
78
|
-
|
|
79
|
-
Situational rules live in a sibling file, loaded only when the element type calls
|
|
80
|
-
for it:
|
|
81
|
-
|
|
82
|
-
- [`element-rules.md`](element-rules.md) — per-element requirements for **classes,
|
|
83
|
-
modules, constants, attributes, dynamically defined methods**, and value
|
|
84
|
-
objects (`Data.define` / `Struct.new`). Read it whenever you document one
|
|
85
|
-
of those elements. Rules for **methods** and rules that apply to **every** doc
|
|
86
|
-
comment stay in this file.
|
|
87
|
-
|
|
88
|
-
## Precedence
|
|
89
|
-
|
|
90
|
-
When a more specific YARD skill applies, its rules override this general skill:
|
|
91
|
-
|
|
92
|
-
- [Command YARD Documentation](../command-yard-documentation/SKILL.md) overrides
|
|
93
|
-
these rules for `Git::Commands::Base` subclasses.
|
|
94
|
-
- [Facade YARD Documentation](../facade-yard-documentation/SKILL.md) overrides these
|
|
95
|
-
rules for `Git::Repository::*` topic modules.
|
|
96
|
-
|
|
97
|
-
Otherwise, the rules in this file apply to all Ruby source.
|
|
98
|
-
|
|
99
|
-
## Workflow
|
|
100
|
-
|
|
101
|
-
Documenting or fixing YARD docs follows three steps:
|
|
102
|
-
|
|
103
|
-
1. [Step 1: Identify What Needs Documentation](#step-1-identify-what-needs-documentation)
|
|
104
|
-
2. [Step 2: Write Documentation](#step-2-write-documentation) — apply the
|
|
105
|
-
templates and the [Documentation Standards](#documentation-standards)
|
|
106
|
-
3. [Step 3: Verify Documentation](#step-3-verify-documentation) — lint, build,
|
|
107
|
-
and manually check
|
|
108
|
-
|
|
109
|
-
ruby-git uses YARD for API documentation. All classes, modules, constants,
|
|
110
|
-
attributes, and methods must have YARD documentation. Methods with Ruby `private`
|
|
111
|
-
visibility require a short description and all applicable tags from the
|
|
112
|
-
[Method Rules](#method-rules) — `@param`, `@return`, `@raise`,
|
|
113
|
-
`@yield`/`@yieldparam`/`@yieldreturn`, and `@overload` — with the exception that
|
|
114
|
-
`@example` may be omitted unless an example materially clarifies the behavior.
|
|
115
|
-
Private methods still need YARD docs for developer reference in source, even though
|
|
116
|
-
YARD excludes them from generated HTML by default.
|
|
117
|
-
|
|
118
|
-
## Named length limits
|
|
119
|
-
|
|
120
|
-
Three named limits govern line and description length throughout this skill. They
|
|
121
|
-
are referenced by name in [Step 3](#step-3-verify-documentation) and the
|
|
122
|
-
[Formatting Rules](#formatting-rules):
|
|
123
|
-
|
|
124
|
-
- **`LINE_LIMIT`** (90 characters) — the preferred maximum length of any
|
|
125
|
-
physical YARD comment line, measured from column 1 and including every
|
|
126
|
-
character: indentation, `#`, tag metadata, and all text. Wrap prose at
|
|
127
|
-
this limit wherever possible.
|
|
128
|
-
- **`LINE_MAX`** (120 characters) — the hard ceiling for lines that cannot
|
|
129
|
-
be wrapped without breaking their meaning. The following content may
|
|
130
|
-
exceed `LINE_LIMIT` up to `LINE_MAX`; it must not exceed `LINE_MAX`:
|
|
131
|
-
- **URLs** — in `@see` tags or markdown links; a URL cannot be split
|
|
132
|
-
- **Long inline code spans** — a `` `backtick` `` span whose content
|
|
133
|
-
alone approaches or exceeds `LINE_LIMIT`
|
|
134
|
-
- **Long `[Type]` expressions** — a type such as
|
|
135
|
-
`[String, Pathname, Array<String, Pathname>]` that fills the tag
|
|
136
|
-
metadata column before any description text begins
|
|
137
|
-
- **`@example` code lines** — real code inside an example block that
|
|
138
|
-
cannot be reflowed without changing its meaning
|
|
139
|
-
- **Markdown table rows** — pipe-delimited table rows that cannot be
|
|
140
|
-
split across lines
|
|
141
|
-
- **`SUMMARY_LIMIT`** (90 characters) — the maximum length of a short
|
|
142
|
-
description — either a tag's description text or a documentable object's short
|
|
143
|
-
description (class, module, method, constant, or attribute) — measured by
|
|
144
|
-
concatenating the text from the first line with all immediately following
|
|
145
|
-
indented continuation lines (stripping the leading `#` and continuation indent
|
|
146
|
-
from each and joining with a single space).
|
|
147
|
-
For tags, this covers the description text only — not the tag name, `[Type]`,
|
|
148
|
-
option key, or `(default)`.
|
|
149
|
-
|
|
150
|
-
## Step 1: Identify What Needs Documentation
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
# Find undocumented objects
|
|
154
|
-
bundle exec yard stats --list-undoc
|
|
155
|
-
|
|
156
|
-
# Check a specific file
|
|
157
|
-
bundle exec yard doc lib/git/repository.rb --no-output
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Step 2: Write Documentation
|
|
161
|
-
|
|
162
|
-
Follow the YARD documentation templates below and apply the
|
|
163
|
-
[Documentation Standards](#documentation-standards) as you write. Use the
|
|
164
|
-
**standard template** when a method has a single call signature. Use the
|
|
165
|
-
**overload template** when a method has distinct call signatures with different
|
|
166
|
-
parameters or return types.
|
|
167
|
-
|
|
168
|
-
When `@overload` blocks are present:
|
|
169
|
-
|
|
170
|
-
- Keep signature-specific tags inside overload blocks only:
|
|
171
|
-
`@example`, `@param`, `@option`, `@return`, overload-specific `@raise`,
|
|
172
|
-
and `@yield`/`@yieldparam`/`@yieldreturn`
|
|
173
|
-
- Keep `@return` inside each `@overload` block. For overloaded methods,
|
|
174
|
-
`@return` is overload-scoped even when the return type/text is the same
|
|
175
|
-
across call shapes
|
|
176
|
-
- Keep shared `@raise` at top level only once (outside all overload blocks)
|
|
177
|
-
- Keep `@raise` inside an overload only when that exception applies to that
|
|
178
|
-
overload shape only
|
|
179
|
-
- Never document the same `@raise` in both places (top-level and overload)
|
|
180
|
-
- Keep non-signature tags (`@note`, `@deprecated`, `@see`, `@api`) at top level
|
|
181
|
-
- Never nest `@api` inside an `@overload` block; it applies to the method
|
|
182
|
-
itself, not to an individual call shape
|
|
183
|
-
|
|
184
|
-
Correct placement pattern:
|
|
185
|
-
|
|
186
|
-
```ruby
|
|
187
|
-
# @overload fetch(name)
|
|
188
|
-
#
|
|
189
|
-
# @param name [String] the remote name
|
|
190
|
-
#
|
|
191
|
-
# @return [Git::CommandLineResult] the command result
|
|
192
|
-
#
|
|
193
|
-
# @overload fetch(name, **options)
|
|
194
|
-
#
|
|
195
|
-
# @param name [String] the remote name
|
|
196
|
-
#
|
|
197
|
-
# @param options [Hash] command options
|
|
198
|
-
#
|
|
199
|
-
# @return [Git::CommandLineResult] the command result
|
|
200
|
-
#
|
|
201
|
-
# @raise [ArgumentError] when the remote name is invalid
|
|
202
|
-
#
|
|
203
|
-
# @api public
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
Incorrect placement pattern:
|
|
207
|
-
|
|
208
|
-
```ruby
|
|
209
|
-
# @overload fetch(name)
|
|
210
|
-
#
|
|
211
|
-
# @param name [String] the remote name
|
|
212
|
-
#
|
|
213
|
-
# @return [Git::CommandLineResult] the command result
|
|
214
|
-
#
|
|
215
|
-
# @raise [ArgumentError] when the remote name is invalid
|
|
216
|
-
#
|
|
217
|
-
# @overload fetch(name, **options)
|
|
218
|
-
#
|
|
219
|
-
# @param name [String] the remote name
|
|
220
|
-
#
|
|
221
|
-
# @param options [Hash] command options
|
|
222
|
-
#
|
|
223
|
-
# @raise [ArgumentError] when the remote name is invalid
|
|
224
|
-
#
|
|
225
|
-
# @api public
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
**Trigger: always use `@overload` for anonymous `*`, anonymous `**`, or `...`**
|
|
229
|
-
|
|
230
|
-
Anonymous splats and the forwarding parameter give `@param`, `@option`, `@yield`,
|
|
231
|
-
and `@yieldparam` no named parameter to bind to, so YARD silently drops them.
|
|
232
|
-
Switch to `@overload` for the entire signature — see
|
|
233
|
-
[Documenting anonymous splats with `@overload`](#documenting-anonymous-splats-with-overload).
|
|
234
|
-
|
|
235
|
-
### Standard template (no `@overload`)
|
|
236
|
-
|
|
237
|
-
When present, tags must appear in the order shown. `@param` tags appear in
|
|
238
|
-
parameter order, with one exception described below; `@option` tags appear
|
|
239
|
-
immediately after the `@param` for the hash they describe. Every `@option` tag
|
|
240
|
-
**must** be preceded by a `@param` for the options hash, and all `@option` tags
|
|
241
|
-
under that `@param` must reference the same parameter name. For keyword arguments
|
|
242
|
-
(`**options` or `**kwargs`), use `@param options [Hash]` (or the actual splat
|
|
243
|
-
name) as the preceding `@param`.
|
|
244
|
-
|
|
245
|
-
For public APIs with known option keys, every `@option` tag must document a real
|
|
246
|
-
supported key, such as `:force` or `:timeout`. Do not invent placeholder option
|
|
247
|
-
keys for a public `options` hash.
|
|
248
|
-
|
|
249
|
-
For private helpers that accept arbitrary keyword collectors whose keys are
|
|
250
|
-
validated elsewhere, use a neutral splat name such as `candidate_keywords` and
|
|
251
|
-
document the collector shape with a single pseudo-option entry named `key_name`.
|
|
252
|
-
A pseudo-option is required because yard-lint's `Documentation/UndocumentedOptions`
|
|
253
|
-
flags any documented `**` collector that has no `@option` tag, and that check has
|
|
254
|
-
no type, name, or visibility exemption for double-splats. Use `key_name` rather
|
|
255
|
-
than a literal-looking `key` so it is not mistaken for a real option key. This is
|
|
256
|
-
only for arbitrary-keyword helpers where the accepted keys are intentionally not
|
|
257
|
-
known at that abstraction layer:
|
|
258
|
-
|
|
259
|
-
```ruby
|
|
260
|
-
# Validate that candidate option keys are listed in `allowed`
|
|
261
|
-
#
|
|
262
|
-
# @param allowed [Array<Symbol>] the permitted option keys
|
|
263
|
-
#
|
|
264
|
-
# @param candidate_keywords [Hash<Symbol, Object>] the keywords to validate
|
|
265
|
-
#
|
|
266
|
-
# @option candidate_keywords [Object] key_name a candidate keyword value
|
|
267
|
-
#
|
|
268
|
-
# @return [void]
|
|
269
|
-
#
|
|
270
|
-
# @raise [ArgumentError] when any candidate key is not in `allowed`
|
|
271
|
-
#
|
|
272
|
-
def assert_valid_opts!(allowed, **candidate_keywords)
|
|
273
|
-
end
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
The exception to parameter order: all `@param` tags must come before the first
|
|
277
|
-
`@option` tag, because yard-lint's `Tags/Order` validator rejects a `@param` that
|
|
278
|
-
follows an `@option`. When a positional parameter follows the options hash in the
|
|
279
|
-
signature, document the options-hash `@param` (and its `@option` tags) last so the
|
|
280
|
-
`@option` tags stay grouped at the end — that is, move the options-hash `@param`
|
|
281
|
-
after the later positional `@param` rather than in strict signature order:
|
|
282
|
-
|
|
283
|
-
```ruby
|
|
284
|
-
# Short description of what the method does
|
|
285
|
-
#
|
|
286
|
-
# Longer description with more details about behavior,
|
|
287
|
-
# edge cases, or important notes.
|
|
288
|
-
#
|
|
289
|
-
# @example Basic usage
|
|
290
|
-
# git = Git.open('/path/to/repo')
|
|
291
|
-
# result = git.method_name('arg', {}, '/path')
|
|
292
|
-
#
|
|
293
|
-
# @example With options
|
|
294
|
-
# git.method_name('arg', { option: true }, '/path')
|
|
295
|
-
#
|
|
296
|
-
# @param name [Type] description of parameter
|
|
297
|
-
#
|
|
298
|
-
# @param path [String] a parameter that follows the options hash in the signature
|
|
299
|
-
#
|
|
300
|
-
# @param options [Hash] options hash description
|
|
301
|
-
#
|
|
302
|
-
# @option options [Type] :key description of option
|
|
303
|
-
#
|
|
304
|
-
# @return [Type] description of return value
|
|
305
|
-
#
|
|
306
|
-
# @raise [ArgumentError] when invalid arguments are provided
|
|
307
|
-
#
|
|
308
|
-
# @raise [Git::FailedError] when git exits with a non-zero exit status
|
|
309
|
-
#
|
|
310
|
-
# @yield [commit] passes each commit to the block
|
|
311
|
-
#
|
|
312
|
-
# @yieldparam commit [Git::Object::Commit] a commit object
|
|
313
|
-
#
|
|
314
|
-
# @yieldreturn [void]
|
|
315
|
-
#
|
|
316
|
-
# @note This method is not thread-safe
|
|
317
|
-
#
|
|
318
|
-
# @deprecated Use {#new_method} instead
|
|
319
|
-
#
|
|
320
|
-
# @see #related_method
|
|
321
|
-
#
|
|
322
|
-
# @see Git::RelatedClass
|
|
323
|
-
#
|
|
324
|
-
# @see https://git-scm.com/docs/git-log
|
|
325
|
-
#
|
|
326
|
-
# @api public
|
|
327
|
-
#
|
|
328
|
-
def method_name(name, options = {}, path)
|
|
329
|
-
end
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
### Overload template
|
|
333
|
-
|
|
334
|
-
Each `@overload` block carries only signature-specific tags: `@example`,
|
|
335
|
-
`@param`, `@option`, `@return`, overload-specific `@raise`, and
|
|
336
|
-
`@yield`/`@yieldparam`/`@yieldreturn`. Tags that are **not**
|
|
337
|
-
call-signature-specific — `@note`, `@deprecated`, `@see`, `@api` — remain
|
|
338
|
-
at the top level. `@return` remains overload-scoped even when identical across
|
|
339
|
-
call shapes. `@raise` can be top-level when shared across all call shapes, and
|
|
340
|
-
overload-local when shape-specific. Never place `@api` inside an overload
|
|
341
|
-
block.
|
|
342
|
-
|
|
343
|
-
```ruby
|
|
344
|
-
# Short description of what the method does
|
|
345
|
-
#
|
|
346
|
-
# Longer description with more details about behavior,
|
|
347
|
-
# edge cases, or important notes.
|
|
348
|
-
#
|
|
349
|
-
# @overload method_name(arg)
|
|
350
|
-
#
|
|
351
|
-
# Single-argument form description
|
|
352
|
-
#
|
|
353
|
-
# @example Basic usage
|
|
354
|
-
# result = git.method_name('arg')
|
|
355
|
-
#
|
|
356
|
-
# @param arg [String] the argument
|
|
357
|
-
#
|
|
358
|
-
# @return [String] the result
|
|
359
|
-
#
|
|
360
|
-
# @overload method_name(arg, options)
|
|
361
|
-
#
|
|
362
|
-
# Two-argument form description
|
|
363
|
-
#
|
|
364
|
-
# @example With options
|
|
365
|
-
# result = git.method_name('arg', { force: true })
|
|
366
|
-
#
|
|
367
|
-
# @param arg [String] the argument
|
|
368
|
-
#
|
|
369
|
-
# @param options [Hash] additional options
|
|
370
|
-
#
|
|
371
|
-
# @return [Array<String>] the results
|
|
372
|
-
#
|
|
373
|
-
# @raise [ArgumentError] when an invalid argument is provided
|
|
374
|
-
#
|
|
375
|
-
# @note This method is not thread-safe
|
|
376
|
-
#
|
|
377
|
-
# @deprecated Use {#new_method} instead
|
|
378
|
-
#
|
|
379
|
-
# @see #related_method
|
|
380
|
-
#
|
|
381
|
-
# @see https://git-scm.com/docs/git-log
|
|
382
|
-
#
|
|
383
|
-
# @api public
|
|
384
|
-
#
|
|
385
|
-
def method_name(arg, options = {})
|
|
386
|
-
end
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
### Overload decision matrix
|
|
390
|
-
|
|
391
|
-
Use this matrix to decide whether to use `@overload` and where to place tags:
|
|
392
|
-
|
|
393
|
-
| Method signature or behavior | Documentation form |
|
|
394
|
-
| --- | --- |
|
|
395
|
-
| Single named signature, no `*`/`**`/`...` | Standard template (no `@overload`) |
|
|
396
|
-
| Uses anonymous `*`, `**`, or `...` | `@overload` required |
|
|
397
|
-
| Private arbitrary keyword collector | Neutral splat name plus pseudo-option `key_name` |
|
|
398
|
-
| Multiple call shapes (different params and/or return types) | One `@overload` per shape |
|
|
399
|
-
| Return value for overloaded methods | `@return` in each overload; never top-level |
|
|
400
|
-
| Shared errors across all call shapes | Top-level `@raise` once (outside overloads) |
|
|
401
|
-
| Error only for specific call shape | `@raise` only in that overload |
|
|
402
|
-
| Same error documented top-level and inside overloads | Invalid; choose one placement |
|
|
403
|
-
| Method-level API visibility (`@api`) | Top-level `@api` only; never inside `@overload` |
|
|
404
|
-
|
|
405
|
-
### Documenting anonymous splats with `@overload`
|
|
406
|
-
|
|
407
|
-
When the method signature uses an anonymous splat — `def foo(*)`, `def foo(**)`,
|
|
408
|
-
`def foo(*, **)` — or the argument forwarding parameter `def foo(...)` —
|
|
409
|
-
`@param`, `@option`, `@yield`, and `@yieldparam` tags have no parameter name
|
|
410
|
-
to bind to. RuboCop's `Style/ArgumentsForwarding` cop prefers these forms when
|
|
411
|
-
arguments are forwarded unchanged, so naming the splat (or expanding `...`
|
|
412
|
-
into `*args, **kwargs, &block`) is **not** an acceptable workaround. Use
|
|
413
|
-
`@overload` blocks that introduce named parameters for documentation purposes
|
|
414
|
-
only:
|
|
415
|
-
|
|
416
|
-
```ruby
|
|
417
|
-
# Update the index with the current content found in the working tree
|
|
418
|
-
#
|
|
419
|
-
# @overload add(paths = '.', **options)
|
|
420
|
-
#
|
|
421
|
-
# @example Stage a specific file
|
|
422
|
-
# git.add('README.md')
|
|
423
|
-
#
|
|
424
|
-
# @param paths [String, Array<String>] file(s) to add (relative to the
|
|
425
|
-
# worktree root); defaults to `'.'` (all files)
|
|
426
|
-
#
|
|
427
|
-
# @param options [Hash] command options
|
|
428
|
-
#
|
|
429
|
-
# @option options [Boolean, nil] :all (nil) add, modify, and remove index entries to
|
|
430
|
-
# match the worktree
|
|
431
|
-
#
|
|
432
|
-
# @option options [Boolean, nil] :force (nil) allow adding otherwise ignored files
|
|
433
|
-
#
|
|
434
|
-
# @return [String] the command output
|
|
435
|
-
#
|
|
436
|
-
# @raise [Git::FailedError] if `git add` exits with a non-zero status
|
|
437
|
-
#
|
|
438
|
-
def add(paths = '.', **)
|
|
439
|
-
Git::Commands::Add.new(@execution_context).call(*Array(paths), **).stdout
|
|
440
|
-
end
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
The same approach applies to `...`. The overload signature names the
|
|
444
|
-
parameters; the actual `def` keeps `...` so RuboCop is satisfied:
|
|
445
|
-
|
|
446
|
-
```ruby
|
|
447
|
-
# Run a command against the underlying execution context
|
|
448
|
-
#
|
|
449
|
-
# @overload run(command, *args, **options, &block)
|
|
450
|
-
#
|
|
451
|
-
# @example Run git status
|
|
452
|
-
# result = git.run('status')
|
|
453
|
-
#
|
|
454
|
-
# @param command [String] the git subcommand to run
|
|
455
|
-
#
|
|
456
|
-
# @param args [Array<String>] positional arguments forwarded to the command
|
|
457
|
-
#
|
|
458
|
-
# @param options [Hash] keyword options forwarded to the command
|
|
459
|
-
#
|
|
460
|
-
# @return [Git::CommandLineResult] the command result
|
|
461
|
-
#
|
|
462
|
-
# @yield [result] yields the command result, when a block is given
|
|
463
|
-
#
|
|
464
|
-
# @yieldparam result [Git::CommandLineResult] the command result
|
|
465
|
-
#
|
|
466
|
-
# @yieldreturn [void]
|
|
467
|
-
#
|
|
468
|
-
def run(command, ...)
|
|
469
|
-
Git::Commands::Run.new(@execution_context).call(command, ...)
|
|
470
|
-
end
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
When a method has multiple genuinely distinct call shapes, write one
|
|
474
|
-
`@overload` block per shape as in the [Overload template](#overload-template)
|
|
475
|
-
above.
|
|
476
|
-
|
|
477
|
-
**Anonymous block parameter (`&`)** is **not** covered by this rule.
|
|
478
|
-
`@yield`, `@yieldparam`, and `@yieldreturn` describe what is yielded to the
|
|
479
|
-
block, not the block parameter itself, so they bind correctly even with an
|
|
480
|
-
anonymous `&`. Use a named block parameter (`&block`) and a `@param block
|
|
481
|
-
[Proc]` tag only in the rare case where the block is documented as a
|
|
482
|
-
first-class `Proc` value (stored, returned, or passed elsewhere) rather than
|
|
483
|
-
yielded to.
|
|
484
|
-
|
|
485
|
-
### Documenting other elements
|
|
486
|
-
|
|
487
|
-
The templates above cover **methods**. When documenting a **class, module,
|
|
488
|
-
constant, attribute, dynamically defined method (`@!method`)**, or a value
|
|
489
|
-
object (`Data.define` / `Struct.new`), follow the per-element requirements
|
|
490
|
-
in [`element-rules.md`](element-rules.md).
|
|
491
|
-
|
|
492
|
-
## Step 3: Verify Documentation
|
|
493
|
-
|
|
494
|
-
First, run the automated linter. `yard-lint` enforces many of the rules in this
|
|
495
|
-
skill (undocumented objects, missing `@param`/`@option`/`@return`, tag order,
|
|
496
|
-
type syntax, orphaned doc comments) and the minimum documentation coverage
|
|
497
|
-
threshold:
|
|
498
|
-
|
|
499
|
-
```bash
|
|
500
|
-
# Lint YARD docs against the project standards (config: .yard-lint.yml)
|
|
501
|
-
bundle exec yard-lint lib/
|
|
502
|
-
|
|
503
|
-
# Lint only the files you changed
|
|
504
|
-
bundle exec yard-lint lib/ --diff main
|
|
505
|
-
|
|
506
|
-
# Or run it through rake (build + lint + example-test)
|
|
507
|
-
bundle exec rake yard
|
|
508
|
-
```
|
|
509
|
-
|
|
510
|
-
A clean `yard-lint` run is necessary but not sufficient: the linter cannot check
|
|
511
|
-
every rule here (e.g. the `LINE_LIMIT`/`LINE_MAX` distinction, `SUMMARY_LIMIT`,
|
|
512
|
-
short-description capitalization and punctuation, noun-phrase class descriptions,
|
|
513
|
-
required `@example` titles, class/module-level `@api` visibility correctness).
|
|
514
|
-
Still perform the manual checks below.
|
|
515
|
-
|
|
516
|
-
Legacy offenses are baselined in `.yard-lint-todo.yml`; when you touch a file
|
|
517
|
-
listed there, remove it from every `Exclude:` list that names it (a file may be
|
|
518
|
-
baselined under more than one validator) and fix the offenses as part of your
|
|
519
|
-
change.
|
|
520
|
-
|
|
521
|
-
Then generate and review the rendered docs:
|
|
522
|
-
|
|
523
|
-
```bash
|
|
524
|
-
# Generate and review docs
|
|
525
|
-
bundle exec yard doc
|
|
526
|
-
# then open doc/index.html in your browser
|
|
527
|
-
|
|
528
|
-
# Check for warnings
|
|
529
|
-
bundle exec yard doc 2>&1 | ruby -ne 'puts $_ if $_ =~ /warn/i'
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
Verify `@example` code runs correctly in `bundle exec bin/console`.
|
|
533
|
-
Check that all `@see` references point to valid targets.
|
|
534
|
-
|
|
535
|
-
### Line and summary length checks
|
|
536
|
-
|
|
537
|
-
Apply these checks to every YARD doc comment — the description on a class,
|
|
538
|
-
module, method, constant, or attribute, and every tag within it (`@param`,
|
|
539
|
-
`@return`, `@raise`, `@option`, `@yield`, `@yieldparam`, `@yieldreturn`, etc.).
|
|
540
|
-
Check all three limits:
|
|
541
|
-
|
|
542
|
-
1. **`LINE_LIMIT`**: Count every character from column 1 (indentation, `#`,
|
|
543
|
-
metadata, text) on each physical line. If any wrappable line exceeds
|
|
544
|
-
`LINE_LIMIT`, split at a word boundary onto a continuation line (indented
|
|
545
|
-
two extra spaces). Apply this check to every continuation line
|
|
546
|
-
independently.
|
|
547
|
-
2. **`LINE_MAX`**: Confirm no physical line exceeds `LINE_MAX` — the hard
|
|
548
|
-
ceiling that nothing may cross. Only unwrappable content (URLs, long inline
|
|
549
|
-
code spans, long `[Type]` expressions, `@example` code, markdown table rows)
|
|
550
|
-
may sit between `LINE_LIMIT` and `LINE_MAX`; every other line must stay
|
|
551
|
-
within `LINE_LIMIT`.
|
|
552
|
-
3. **`SUMMARY_LIMIT`**: For each short description — a tag's description or a
|
|
553
|
-
documented object's short description — strip the leading `#` and its
|
|
554
|
-
indentation from every continuation line and join with a single space. If the
|
|
555
|
-
concatenated text exceeds `SUMMARY_LIMIT`, shorten it and move the excess into
|
|
556
|
-
a paragraph after a blank `#` line.
|
|
557
|
-
|
|
558
|
-
## Documentation Standards
|
|
559
|
-
|
|
560
|
-
The rules below are the reference the [Workflow](#workflow) draws on. The
|
|
561
|
-
[Formatting Rules](#formatting-rules) apply to every doc comment regardless of
|
|
562
|
-
element type; the [Method Rules](#method-rules) govern method doc comments.
|
|
563
|
-
Per-element rules for classes, modules, constants, attributes, and value objects
|
|
564
|
-
are in [`element-rules.md`](element-rules.md).
|
|
565
|
-
|
|
566
|
-
Treat every rule in this section as mandatory unless its heading is marked
|
|
567
|
-
**(SHOULD)** or **(Optional)**. Headings that name a descriptive topic (e.g.
|
|
568
|
-
type-specifier conventions) are reference material; any obligations they carry are
|
|
569
|
-
stated with “must” inline.
|
|
570
|
-
|
|
571
|
-
### Formatting Rules
|
|
572
|
-
|
|
573
|
-
Doc comments are rendered as **markdown** via the redcarpet gem. Write all
|
|
574
|
-
free-text descriptions, tag values, and examples using markdown syntax. These rules
|
|
575
|
-
apply to all documentation regardless of element type. They reference the three
|
|
576
|
-
[Named length limits](#named-length-limits) (`LINE_LIMIT`, `LINE_MAX`,
|
|
577
|
-
`SUMMARY_LIMIT`) defined earlier.
|
|
578
|
-
|
|
579
|
-
#### Doc comment placement
|
|
580
|
-
|
|
581
|
-
YARD doc comments must appear immediately above the element they document (class,
|
|
582
|
-
module, method, constant, or attribute) with no intervening blank lines or
|
|
583
|
-
non-comment code.
|
|
584
|
-
|
|
585
|
-
#### Blank lines around tags
|
|
586
|
-
|
|
587
|
-
Every individual YARD tag must be preceded by a blank comment line (`#`) unless it is the very first line of a doc comment.
|
|
588
|
-
A YARD tag is any comment token matching `@!?[a-z_]+` — that is, `@word` (regular
|
|
589
|
-
tags such as `@param`, `@return`, `@raise`, `@api`, `@abstract`, `@deprecated`,
|
|
590
|
-
etc.) or `@!word` (directives such as `@!attribute`, `@!method`, `@!scope`, etc.).
|
|
591
|
-
|
|
592
|
-
Within the tag block there are no other exceptions: consecutive same-kind tags (e.g.
|
|
593
|
-
multiple `@param` lines) each require their own preceding blank line.
|
|
594
|
-
|
|
595
|
-
#### Never use raw blank lines inside a doc comment block
|
|
596
|
-
|
|
597
|
-
A raw blank line — an empty line with no leading `#` — terminates the YARD doc
|
|
598
|
-
comment block at that point. Any comment lines that follow the raw blank line are
|
|
599
|
-
treated as separate, unattached comments and will not appear in the generated
|
|
600
|
-
documentation. Always use a blank comment line (`#`) to separate paragraphs or
|
|
601
|
-
continuation text within a YARD block:
|
|
602
|
-
|
|
603
|
-
Correct — blank comment line keeps the block intact:
|
|
604
|
-
|
|
605
|
-
```ruby
|
|
606
|
-
# @option options [Boolean, nil] :ipv4 (nil) use IPv4 addresses only
|
|
607
|
-
#
|
|
608
|
-
# Alias: :"4"
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
Incorrect — raw blank line silently drops the alias note:
|
|
612
|
-
|
|
613
|
-
```ruby
|
|
614
|
-
# @option options [Boolean, nil] :ipv4 (nil) use IPv4 addresses only
|
|
615
|
-
|
|
616
|
-
# Alias: :"4"
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
Watch for editors that auto-strip trailing spaces from `#` lines, silently
|
|
620
|
-
creating raw blank lines.
|
|
621
|
-
|
|
622
|
-
#### Short descriptions
|
|
623
|
-
|
|
624
|
-
The short description (the first sentence of any doc comment, or the inline text of
|
|
625
|
-
a `@param`, `@return`, `@raise`, etc. tag) must:
|
|
626
|
-
|
|
627
|
-
- Be a single sentence
|
|
628
|
-
- Not end with sentence-ending punctuation (`.`, `?`, `!`)
|
|
629
|
-
- **Element-level short descriptions** (on classes, modules, and methods) **start
|
|
630
|
-
with an uppercase letter** (e.g. `Returns the commit count`,
|
|
631
|
-
`Represents a Git branch`)
|
|
632
|
-
- **Tag short descriptions** (`@option`, `@param`, `@return`, `@raise`, `@yield`,
|
|
633
|
-
`@yieldparam`, etc.) **all start with a lowercase letter** (e.g. `@option options
|
|
634
|
-
[Boolean, nil] :force (nil) overwrite existing files`, `@param name [String] the branch
|
|
635
|
-
name`, `@return [String] the result`, `@raise [ArgumentError] when no name is provided`)
|
|
636
|
-
|
|
637
|
-
For tags, the **summary text** is the description that follows the tag
|
|
638
|
-
metadata (tag name, `[Type]`, option key, and `(default)`). For example, in:
|
|
639
|
-
|
|
640
|
-
```text
|
|
641
|
-
@option options [Boolean, nil] :ignore_case (nil) ignore case distinctions
|
|
642
|
-
```
|
|
643
|
-
|
|
644
|
-
the summary text is `ignore case distinctions`.
|
|
645
|
-
|
|
646
|
-
#### Line and summary length
|
|
647
|
-
|
|
648
|
-
Every physical YARD doc line should not exceed `LINE_LIMIT`. When a description
|
|
649
|
-
would push a line past `LINE_LIMIT`, split it at a word boundary
|
|
650
|
-
onto a continuation line indented two extra spaces. For content that cannot
|
|
651
|
-
be wrapped (URLs, long inline code spans, long `[Type]` expressions,
|
|
652
|
-
`@example` code lines, markdown table rows), lines may extend up to
|
|
653
|
-
`LINE_MAX` but must not exceed it.
|
|
654
|
-
|
|
655
|
-
Additionally, the concatenated description — the description text from the
|
|
656
|
-
first line joined with all continuation lines — must not exceed
|
|
657
|
-
`SUMMARY_LIMIT`. If the concatenated description exceeds `SUMMARY_LIMIT`,
|
|
658
|
-
shorten it and move the excess detail into a paragraph after a blank `#` line.
|
|
659
|
-
|
|
660
|
-
For example, this tag has a description of 84 characters (within
|
|
661
|
-
`SUMMARY_LIMIT`), but the single physical line is 102 characters (exceeds
|
|
662
|
-
`LINE_LIMIT`) and must be split:
|
|
663
|
-
|
|
664
|
-
```ruby
|
|
665
|
-
# @return [Array] a two-element array `[target, options]` containing the translated checkout arguments
|
|
666
|
-
```
|
|
667
|
-
|
|
668
|
-
Split so each physical line fits within `LINE_LIMIT`:
|
|
669
|
-
|
|
670
|
-
```ruby
|
|
671
|
-
# @return [Array] a two-element array `[target, options]` containing the
|
|
672
|
-
# translated checkout arguments
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
If the tag metadata itself is long (e.g. a long `[Type]` or `@option` key),
|
|
676
|
-
start the description on an indented continuation line so only the metadata
|
|
677
|
-
appears on the first physical line.
|
|
678
|
-
|
|
679
|
-
If more explanation is needed, add continuation paragraphs after a blank
|
|
680
|
-
comment line (`#`). Every physical line — in the summary and in any
|
|
681
|
-
continuation paragraph — must independently fit within `LINE_LIMIT`
|
|
682
|
-
(or `LINE_MAX` for unwrappable content such as URLs, long inline code
|
|
683
|
-
spans, long `[Type]` expressions, `@example` code, or table rows).
|
|
684
|
-
|
|
685
|
-
These rules apply to every doc comment — an object's short description and a
|
|
686
|
-
tag's text alike; the first sentence is the short description. The no-punctuation rule applies only to
|
|
687
|
-
short descriptions; continuation paragraphs use normal prose punctuation (periods).
|
|
688
|
-
Separate continuation paragraphs with a blank comment line.
|
|
689
|
-
|
|
690
|
-
Correct — tag title without punctuation, blank line before continuation:
|
|
691
|
-
|
|
692
|
-
```ruby
|
|
693
|
-
# @option options [Boolean, nil] :ignore_case (nil) ignore case
|
|
694
|
-
# distinctions in both the pattern and the file contents
|
|
695
|
-
#
|
|
696
|
-
# Alias: :i
|
|
697
|
-
#
|
|
698
|
-
# @option options [String, Array<String>] :pattern the search pattern
|
|
699
|
-
# (required; must not be nil)
|
|
700
|
-
#
|
|
701
|
-
# Pass a String for a simple pattern (emitted as `-e <pattern>`).
|
|
702
|
-
# Pass an Array of raw CLI arguments for compound boolean
|
|
703
|
-
# expressions.
|
|
704
|
-
#
|
|
705
|
-
# @return [Git::CommandLineResult] the result of calling `git grep`
|
|
706
|
-
#
|
|
707
|
-
# Exit status 0 means matches were found; exit status 1 means no
|
|
708
|
-
# lines were selected (not an error).
|
|
709
|
-
```
|
|
710
|
-
|
|
711
|
-
Incorrect — trailing period on title, missing blank line before continuation, and `@return` concatenated summary exceeds `SUMMARY_LIMIT` (132 chars):
|
|
712
|
-
|
|
713
|
-
```ruby
|
|
714
|
-
# @option options [Boolean, nil] :ignore_case (nil) ignore case
|
|
715
|
-
# distinctions in both the pattern and the file contents.
|
|
716
|
-
# Alias: :i
|
|
717
|
-
#
|
|
718
|
-
# @return [Git::CommandLineResult] the result of calling `git grep`.
|
|
719
|
-
# Exit status 0 means matches were found; exit status 1 means no
|
|
720
|
-
# lines were selected (not an error).
|
|
721
|
-
```
|
|
722
|
-
|
|
723
|
-
#### `@return` must always include a type
|
|
724
|
-
|
|
725
|
-
Every `@return` tag must include a `[Type]` specifier. `@return the value` is
|
|
726
|
-
incorrect; write `@return [Object] the value` (or a more specific type). If the
|
|
727
|
-
return value is the block's return value, use `@return [Object]`.
|
|
728
|
-
|
|
729
|
-
#### No shell calls in `@example` blocks
|
|
730
|
-
|
|
731
|
-
Never use backtick shell calls (`` `true` ``, `` `git version` ``) or process-status
|
|
732
|
-
globals (`$?`, `$CHILD_STATUS`) in `@example` blocks. They are side-effecting,
|
|
733
|
-
environment-dependent, and confuse readers about the type of object being
|
|
734
|
-
demonstrated. Construct example objects directly in Ruby instead:
|
|
735
|
-
|
|
736
|
-
Incorrect:
|
|
737
|
-
|
|
738
|
-
```ruby
|
|
739
|
-
# @example Incorrect shell call
|
|
740
|
-
# `true`
|
|
741
|
-
# result = Git::CommandLine::Result.new([], $?, '', '')
|
|
742
|
-
```
|
|
743
|
-
|
|
744
|
-
Correct:
|
|
745
|
-
|
|
746
|
-
```ruby
|
|
747
|
-
# @example Constructing a result with a double
|
|
748
|
-
# status = instance_double(ProcessExecuter::Result)
|
|
749
|
-
# result = Git::CommandLine::Result.new([], status, '', '')
|
|
750
|
-
```
|
|
751
|
-
|
|
752
|
-
#### Blank lines within `@example` blocks
|
|
753
|
-
|
|
754
|
-
Within `@example` blocks, blank comment lines (`#`) render as literal blank lines in
|
|
755
|
-
the displayed code. Use them for readability between setup and assertions, but be
|
|
756
|
-
aware they are literal content, not tag separators.
|
|
757
|
-
|
|
758
|
-
#### `@example` titles are required
|
|
759
|
-
|
|
760
|
-
Every `@example` tag must include a title — the descriptive text on the same line
|
|
761
|
-
after `@example`. Write `@example Basic usage`, not bare `@example`. Titles appear
|
|
762
|
-
as headings in generated docs and help readers scan multiple examples.
|
|
763
|
-
|
|
764
|
-
#### Cross-reference links only resolve to objects included in generated docs
|
|
765
|
-
|
|
766
|
-
YARD renders `{ClassName#method}` as a hyperlink only when the target method is
|
|
767
|
-
included in the generated documentation. Public objects are included by default,
|
|
768
|
-
and objects marked with `@api private` remain included with a private annotation.
|
|
769
|
-
Ruby private methods are excluded by default. Do not write
|
|
770
|
-
`{Git::Commands::Base#execute_command}` — it will render as plain text and may
|
|
771
|
-
generate an unresolved reference warning.
|
|
772
|
-
|
|
773
|
-
If you need to refer to a private method, describe it in prose instead, or link to
|
|
774
|
-
the public method that callers should use.
|
|
775
|
-
|
|
776
|
-
#### Inline code formatting
|
|
777
|
-
|
|
778
|
-
Use backtick code spans for inline code (`` `true` ``, `` `nil` ``, symbols, type
|
|
779
|
-
names, method calls). Do not use the RDoc `+value+` style; it is inconsistent with
|
|
780
|
-
the project's markdown rendering via redcarpet.
|
|
781
|
-
|
|
782
|
-
#### Escaping opening braces in descriptions
|
|
783
|
-
|
|
784
|
-
YARD treats `{` as the start of a cross-reference link. Because redcarpet consumes
|
|
785
|
-
one `\` before YARD sees it, write `\\{` (two backslashes) to produce a literal
|
|
786
|
-
`{` — redcarpet reduces `\\` to `\`, leaving `\{` for YARD. For example, use
|
|
787
|
-
`'stash@\\{0}'` to render as `stash@{0}`. Using only `\{` still triggers a YARD
|
|
788
|
-
unresolved link warning.
|
|
789
|
-
|
|
790
|
-
#### Cross-reference links
|
|
791
|
-
|
|
792
|
-
Link to other code objects anywhere in a doc comment using `{ClassName}`,
|
|
793
|
-
`{ClassName#method}`, `{#method_in_same_class}`, or `{Class::CONSTANT}`. An
|
|
794
|
-
optional title follows the reference separated by a space:
|
|
795
|
-
`{Git::Repository#log the log method}`. Do not use brace syntax inside `@see` tags —
|
|
796
|
-
`@see` links automatically without braces. `@see` accepts three target forms:
|
|
797
|
-
|
|
798
|
-
- Code objects: `@see Git::Repository#log`
|
|
799
|
-
- URLs: `@see https://git-scm.com/docs/git-log`
|
|
800
|
-
- Quoted text: `@see "Pro Git, Chapter 2"`
|
|
801
|
-
|
|
802
|
-
#### Type specifier conventions
|
|
803
|
-
|
|
804
|
-
The `[Types]` field in `@param`, `@return`, `@raise`, etc. supports:
|
|
805
|
-
|
|
806
|
-
- Plain types: `[String]`, `[Integer]`, `[Git::Repository]`
|
|
807
|
-
- Multiple types: `[String, nil]`, `[String, Array<String>]`
|
|
808
|
-
- Parametrized collections: `[Array<String>]`, `[Hash<Symbol, String>]`
|
|
809
|
-
- Fixed-position tuples: `[Array(String, Integer)]`, `[Array(Symbol, (Integer, nil))]`
|
|
810
|
-
- Duck-types (responds to): `[#read]`, `[#to_s]`
|
|
811
|
-
- `[Boolean]` — conventional meta-type for `true` or `false` (not a real Ruby class)
|
|
812
|
-
- `[void]` — for `@return` tags on methods whose return value must not be used
|
|
813
|
-
|
|
814
|
-
#### `Array<...>` (collection) vs `Array(...)` (tuple)
|
|
815
|
-
|
|
816
|
-
YARD treats angle brackets and parentheses as distinct type constructors, so
|
|
817
|
-
choose the one that matches the value's shape:
|
|
818
|
-
|
|
819
|
-
- `Array<T>` (angle brackets) — a **collection**: an array *of* `T` with any
|
|
820
|
-
number of elements, e.g. `Array<String>` is zero or more strings. Listing
|
|
821
|
-
several types inside `<...>` means each element is one *of* those types
|
|
822
|
-
(`Array<String, Symbol>` is an array whose elements are each a String or a
|
|
823
|
-
Symbol), **not** a fixed sequence.
|
|
824
|
-
- `Array(A, B)` (parentheses) — a **tuple**: an array *containing* exactly `A`
|
|
825
|
-
then `B` in that order, e.g. `Array(String, Integer)` is a two-element
|
|
826
|
-
`[name, count]`. Use this whenever a method returns or accepts a
|
|
827
|
-
fixed-position array such as `[status, similarity]` or `[path, options]`.
|
|
828
|
-
|
|
829
|
-
The same rule applies to nested types: `Array<Array(Integer, String)>` is a
|
|
830
|
-
collection of `[index, message]` tuples. Use `[Array]` with a prose description
|
|
831
|
-
only when the element types cannot be expressed concisely.
|
|
832
|
-
|
|
833
|
-
#### `@api private` vs `@private`
|
|
834
|
-
|
|
835
|
-
Use `@api private` (not `@private`) to mark internal classes and modules. `@api
|
|
836
|
-
private` includes the object in generated docs with a private annotation; YARD's
|
|
837
|
-
`@private` tag excludes the object from docs entirely.
|
|
838
|
-
|
|
839
|
-
#### Class and module `@api` visibility (Required)
|
|
840
|
-
|
|
841
|
-
Every documented class and module must declare API visibility explicitly with
|
|
842
|
-
exactly one tag:
|
|
843
|
-
|
|
844
|
-
- `@api public` for user-facing API
|
|
845
|
-
- `@api private` for internal implementation details
|
|
846
|
-
|
|
847
|
-
Do not rely on YARD's implicit default visibility.
|
|
848
|
-
|
|
849
|
-
`@api` visibility is inherited by child objects. Omit redundant method-level or
|
|
850
|
-
constant-level `@api` tags when a child matches its enclosing class/module
|
|
851
|
-
visibility.
|
|
852
|
-
|
|
853
|
-
Add method-level or constant-level `@api` only when a child intentionally differs
|
|
854
|
-
from its enclosing class/module visibility.
|
|
855
|
-
|
|
856
|
-
#### `@since` tags are not used
|
|
857
|
-
|
|
858
|
-
Do not add `@since` tags. The project has no historical `@since` annotations, and
|
|
859
|
-
retroactively tagging existing APIs is impractical at v4.x. Version introduction
|
|
860
|
-
history is tracked through git blame and the CHANGELOG instead.
|
|
861
|
-
|
|
862
|
-
#### `@todo` tags are not used
|
|
863
|
-
|
|
864
|
-
Do not add `@todo` tags. Track incomplete work in GitHub Issues, not in source
|
|
865
|
-
comments. YARD renders `@todo` prominently in generated docs, and these annotations
|
|
866
|
-
go stale quickly.
|
|
867
|
-
|
|
868
|
-
#### `@abstract`
|
|
869
|
-
|
|
870
|
-
Use `@abstract` on classes or methods that must be subclassed or overridden before
|
|
871
|
-
use. Include guidance text describing what the subclass must implement:
|
|
872
|
-
`@abstract Subclass and implement {#run}`. Do not use `@abstract` on concrete
|
|
873
|
-
classes or fully implemented methods.
|
|
874
|
-
|
|
875
|
-
### Method Rules
|
|
876
|
-
|
|
877
|
-
#### Short description
|
|
878
|
-
|
|
879
|
-
Every method must have a short description that:
|
|
880
|
-
|
|
881
|
-
- Starts with a verb (`Returns`, `Resets`, `Finds` — not "The…" or "This method…")
|
|
882
|
-
- Omits the subject — write "Returns the commit count", not "This method returns
|
|
883
|
-
the commit count"
|
|
884
|
-
- States the outcome, not the mechanism — `Finds the nearest tagged ancestor` not
|
|
885
|
-
`Iterates through commits checking tags`
|
|
886
|
-
- Mentions key parameters inline — `Resets HEAD to the given ref` rather than
|
|
887
|
-
relying solely on param tags
|
|
888
|
-
- Avoids restating the method name — add specificity about what kind, from where,
|
|
889
|
-
or what is returned
|
|
890
|
-
- Is specific about return values — `Returns true if the branch exists, false
|
|
891
|
-
otherwise` beats `Returns a Boolean`
|
|
892
|
-
- Omits implementation details — callers don't care about internal loops or temp
|
|
893
|
-
variables
|
|
894
|
-
|
|
895
|
-
#### Standard tags
|
|
896
|
-
|
|
897
|
-
Methods use these standard YARD tags:
|
|
898
|
-
|
|
899
|
-
- `@param` for each method parameter, in signature order; omit `@param` entirely
|
|
900
|
-
on zero-argument methods
|
|
901
|
-
- `@return` on every method; use `[void]` when the return value must not be used
|
|
902
|
-
- `@raise` for each caller-relevant exception the method can raise as part of its
|
|
903
|
-
contract; omit `@raise` when the method has no documented exceptional path
|
|
904
|
-
|
|
905
|
-
#### `@example` on non-private methods
|
|
906
|
-
|
|
907
|
-
Methods without Ruby `private` visibility must have one or more `@example`s;
|
|
908
|
-
Ruby-private methods may omit `@example` unless usage would otherwise be unclear.
|
|
909
|
-
|
|
910
|
-
#### Yield tags
|
|
911
|
-
|
|
912
|
-
Methods that yield to a block must include `@yield [param_names]`, one
|
|
913
|
-
`@yieldparam name [Type]` per yielded parameter, and `@yieldreturn [Type]`; omit
|
|
914
|
-
all yield tags on methods that do not yield.
|
|
915
|
-
|
|
916
|
-
#### `@overload` for distinct signatures
|
|
917
|
-
|
|
918
|
-
Use `@overload` when a method has distinct call signatures with different
|
|
919
|
-
parameters or return types — each overload gets its own full set of tags.
|
|
920
|
-
Methods that yield only when an optional block is given should use `@overload`
|
|
921
|
-
to document the with-block and without-block signatures separately.
|
|
922
|
-
|
|
923
|
-
#### `@overload` for anonymous splats
|
|
924
|
-
|
|
925
|
-
Methods whose signature uses an anonymous `*`, `**`, or `...` must document their
|
|
926
|
-
call shapes with named `@overload` blocks. Do **not** name the splat or expand
|
|
927
|
-
`...` into `*args, **kwargs, &block` to make tags bind — that conflicts with
|
|
928
|
-
RuboCop's `Style/ArgumentsForwarding` cop. See
|
|
929
|
-
[Documenting anonymous splats with `@overload`](#documenting-anonymous-splats-with-overload).
|
|
930
|
-
|
|
931
|
-
#### `@note` for callouts (Optional)
|
|
932
|
-
|
|
933
|
-
Use `@note` for callouts that need visual emphasis: thread-safety warnings,
|
|
934
|
-
significant side effects, or platform-specific behavior.
|
|
935
|
-
|
|
936
|
-
#### `@deprecated` on deprecated methods
|
|
937
|
-
|
|
938
|
-
Deprecated methods must include `@deprecated` explaining the migration path,
|
|
939
|
-
e.g. `@deprecated Use {#new_method} instead`.
|
|
940
|
-
|
|
941
|
-
#### `@api` on methods (Optional)
|
|
942
|
-
|
|
943
|
-
Method-level `@api` is exception-only: when omitted, the method inherits the
|
|
944
|
-
containing class's `@api` level. Use it only when the method's intended visibility
|
|
945
|
-
differs from the class's level (e.g. an `@api private` helper inside an `@api
|
|
946
|
-
public` class). For overloaded methods, place `@api` once at top level and never
|
|
947
|
-
nest it inside an `@overload` block.
|
|
948
|
-
|
|
949
|
-
## Command Reference
|
|
950
|
-
|
|
951
|
-
```bash
|
|
952
|
-
# Lint YARD documentation against the project standards
|
|
953
|
-
bundle exec yard-lint lib/
|
|
954
|
-
|
|
955
|
-
# Lint only changed files (great for pre-commit / CI)
|
|
956
|
-
bundle exec yard-lint lib/ --diff main
|
|
957
|
-
|
|
958
|
-
# Show documentation coverage statistics
|
|
959
|
-
bundle exec yard-lint lib/ --stats
|
|
960
|
-
|
|
961
|
-
# Generate documentation
|
|
962
|
-
bundle exec yard doc
|
|
963
|
-
|
|
964
|
-
# Generate and serve locally
|
|
965
|
-
bundle exec yard server --reload
|
|
966
|
-
|
|
967
|
-
# Check documentation coverage
|
|
968
|
-
bundle exec yard stats
|
|
969
|
-
|
|
970
|
-
# List undocumented objects
|
|
971
|
-
bundle exec yard stats --list-undoc
|
|
972
|
-
|
|
973
|
-
# Generate docs for specific file
|
|
974
|
-
bundle exec yard doc lib/git/repository.rb
|
|
975
|
-
|
|
976
|
-
# Check for YARD syntax errors
|
|
977
|
-
bundle exec yard doc --no-output 2>&1
|
|
978
|
-
|
|
979
|
-
# View documentation for specific class
|
|
980
|
-
bundle exec yard ri Git::Repository
|
|
981
|
-
```
|