Document all public objects with YARD - #58
Open
tas50 wants to merge 1 commit into
Open
Conversation
YARD was already wired up -- the rake task, the gem, and the .yardoc gitignore entry were all in place, and CONTRIBUTING said documentation was expected -- but nothing checked it, and coverage had drifted to 61.59%. 164 public objects had no comment at all, including every matcher class, every error class, and both runners. This brings lib/ to 100% and adds a way to check it: - .yardopts so `yard doc` produces consistent output, with README as the front page. Markup is deliberately left at YARD's rdoc default, since the existing docstrings use +code+ rather than backticks. - tasks/yard_coverage.rb drives YARD's own CLI::Stats rather than reimplementing its coverage rules, so it can never disagree with `yard stats --list-undoc`. Those rules are subtle: only public objects count, aliases and constructors are skipped, and a docstring made of nothing but an invisible tag still reads as undocumented. - `rake yard:coverage` runs it. It is a local tool only; nothing is wired into CI. - CONTRIBUTING gains the expectation and the conventions behind it. Every changed line under lib/ is a comment: 1267 added, 0 removed, so no behavior can have changed. `yard doc` emits the same 25 warnings as before the change. Signed-off-by: Tim Smith <tsmith84@proton.me>
tas50
force-pushed
the
docs/yard-comments
branch
from
August 22, 2026 01:59
1c6b569 to
844ef78
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CONTRIBUTING.mdalready said documentation was expected, and YARD was already wired up — the rake task, theyardgem, and the.yardocgitignore entry were all in place. But nothing ever checked, and coverage had drifted:The gap was not in obscure corners. Every matcher class, all 15 error classes, both runners, the whole stubs subsystem, and the
ChefSpecmodule itself had no comment at all.What's here
Documentation — YARD comments for the 164 undocumented objects, following the existing house style (bare
#lines opening and closing each block,@param/@returnseparated by bare#lines). Every changed line underlib/is a comment: 1267 added, 0 removed, so no behavior can have changed..yardopts— soyard docproduces consistent output with the README as the front page. Markup is deliberately left at YARD'srdocdefault: the existing docstrings use+template+rather than backticks, and switching to Markdown would render all of that literally.tasks/yard_coverage.rb+rake yard:coverage— a local check that reports anything public without a comment, exiting non-zero and naming the offendingfile:line. It drives YARD's ownCLI::Statsrather than reimplementing the rules, so it cannot disagree withyard stats --list-undoc. Worth knowing that those rules are subtler than they look:# @api privateon its own does not satisfy it (@deprecated, being visible, does)My first attempt hand-rolled this and reported 63 false failures against
yard stats' zero, which is exactly why it now defers to YARD.This is a local tool only — nothing is wired into CI, and no workflow files are touched by this PR.
CONTRIBUTING.mdgains the expectation plus the conventions behind it, including the RDoc-vs-Markdown gotcha and the rule that cross-gem references need+Chef::Resource+rather than{Chef::Resource}, since YARD cannot link to a class it has not parsed.Verification
rake yard:coveragefile:linecookstyle --chefstyle -c .rubocop.ymlruby -con all 74 files inlib/+tasks/yard docwarningsupstream/main— no new warningslib/The warning comparison caught real problems on the way: my first pass added six
Cannot resolve linkwarnings by writing{Mash}and{Chef::Resource}for classes that live in other gems. Those are now+Mash+and+Chef::Resource+.One caveat on what I could not verify: I was unable to run the RSpec suite —
bundle installcurrently fails building the Windows-onlywin32-apigem via the Chef git source. That is not specific to this branch:upstream/mainfails CI on its last four commits including the current tip, and the other open PRs fail identically. Given the diff is comments-only, the risk is minimal, but the suite has genuinely not run against this.Types of changes
Checklist
lib/are documentedlib/diff is entirely commentsyard docproduces no new warnings