Skip to content

docs: complete the YARD tags on the workflow attribute writers - #47

Open
tas50 wants to merge 1 commit into
mainfrom
docs/complete-yard-tags
Open

tas50 wants to merge 1 commit into
mainfrom
docs/complete-yard-tags

Conversation

@tas50

@tas50 tas50 commented Aug 30, 2026

Copy link
Copy Markdown
Member

What

yard stats has reported 100.00% documented for a while, but object coverage
only asks whether an object has a docstring -- it says nothing about whether
the tags inside are complete. Auditing the registry directly for missing
@param / @return tags turned up two gaps, both on the generated attribute
writers:

before: methods=22  missing_@param=1  missing_@return=1
        PARAM:  Kitchen::Driver::Vro#workflow_name=
        RETURN: Kitchen::Driver::Vro#workflow_id=

after:  methods=22  missing_@param=0  missing_@return=0

Why the accessor is split

Neither gap could be closed in place. YARD shares a single docstring between the
reader and the writer of an attr_accessor, so:

  • a @param value added to that shared docstring lands on the reader too,
    which takes no arguments -- YARD then emits
    @param tag has unknown parameter name: value (verified: adding it produced
    12 such warnings), and
  • when the @!attribute directive form is used, YARD replaces the writer's
    docstring with an auto-generated @param value and the @return is lost --
    which is exactly the asymmetry the audit found between workflow_name= and
    workflow_id=.

So this PR declares an attr_reader and an attr_writer per attribute instead
of one attr_accessor, which lets each direction carry its own tags. This
defines exactly the same two methods attr_accessor did; there is no runtime
change. A short comment records why the pair is written out, so it does not get
"tidied" back into an accessor and silently reopen the gap.

While there, both writers now note that {#set_workflow_vars} is the intended way
to switch workflows, since it also clears the memoized client and the memoized
output parameters. Assigning the attribute on its own leaves both pointing at the
previous workflow -- that is a real footgun the existing docs on
set_workflow_vars describe but the writers themselves did not.

What this PR does not do

  • It does not add YARD rake tasks or a .yardopts. Both already exist and
    both still work: rake -T lists rake doc and rake doc_coverage, and both
    still report 100.00% documented with Attributes: 2 (0 undocumented).
  • It does not change any prose that was already correct.

Verification

No @param tag has unknown parameter name warnings remain:

$ bundle exec yard 2>&1 | grep -i warn
[warn]: In file `LICENSE.txt':1: Cannot resolve link to yyyy from text:
[warn]: In file `LICENSE.txt':1: Cannot resolve link to name from text:

Those two are pre-existing and unrelated to Ruby docs: LICENSE.txt is listed as
an extra file in .yardopts and the Apache boilerplate's [yyyy] and
[name of copyright owner] placeholders get parsed as markdown links. Left alone
here.

Docs coverage unchanged:

$ bundle exec rake doc_coverage
Files:           2
Modules:         2 (    0 undocumented)
Classes:         1 (    0 undocumented)
Constants:       1 (    0 undocumented)
Attributes:      2 (    0 undocumented)
Methods:        18 (    0 undocumented)
 100.00% documented

Tests, same count before and after:

$ bundle exec rake test
85 examples, 0 failures

Lint clean:

$ bundle exec cookstyle --chefstyle   # Cookstyle 9.0.0 / RuboCop 1.90.0
8 files inspected, no offenses detected

Worth noting: main is green under Cookstyle 9.0.0 again. The
Layout/ExtraSpacing offense on the unused webmock line is gone, because #44
removed the webmock dependency entirely.

Merge order

No conflicts expected. #44 and #45 have both landed, and this branch is cut from
the current main. #46 (ci:) touches workflow files rather than lib/, so the
two are independent. #7 is an outside contribution that is already unmergeable
against main and will need rebasing regardless of this PR; it does not touch
these attribute declarations.

Unrelated, for a separate PR

This repo's licence file is LICENSE.txt, while 18 of the 21 sibling repos use
LICENSE. As a result the README's [LICENSE](LICENSE) link (README.md:257)
404s. Deliberately not touched here -- flagging it so it can be handled on its
own.

The two attribute writers were the last tag gaps in the driver:
workflow_name= had no @PARAM and workflow_id= had no @return. Neither
could be fixed in place, because YARD shares one docstring between the
reader and the writer of an attr_accessor, so a @PARAM added there is
reported as an unknown parameter name on the reader.

Split the accessor into an attr_reader and an attr_writer per attribute
so each direction carries its own tags, and note on both writers that
set_workflow_vars is the intended way to switch workflows since it also
resets the memoized client and output parameters.

Runtime behaviour is unchanged: attr_reader plus attr_writer defines the
same two methods attr_accessor did.

Signed-off-by: Tim Smith <tim@mondoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant