-
Notifications
You must be signed in to change notification settings - Fork 289
Address PR #909 review comments for YARD documentation #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: ruby-shoryuken/shoryuken
Length of output: 1766
🏁 Script executed:
Repository: ruby-shoryuken/shoryuken
Length of output: 173
🌐 Web query:
YARD documentation multiple @return tags attribute methods how to document attributes💡 Result:
Short answer — use @!attribute for attributes (with an indented docstring and a single @return describing the type/value), put attribute docs directly above attr_* (or use @!attribute when attributes are created dynamically), and use multiple @return tags only for distinct return cases (each starting with "if ...").
Examples and rules
Document a normal attr_accessor/reader/writer by placing the doc above the declaration and a single @return for the getter type. Example:
@return [String] the name
attr_accessor :name
[1][2]
For dynamically defined attributes (DSL/meta-programming) use the @!attribute directive. You can specify [r], [w], or [rw] and include an indented docstring with @return:
@!attribute [rw] publisher
@return [String] publisher name
cattr_accessor :publisher
[2][3]
If getter and setter need different docs, keep docs on the reader/declaration and use @overload to describe separate behavior/signatures (or use @!method/@!attribute to create explicit docs). By default YARD exposes the reader. [1][2]
Multiple @return tags: allowed only when the method has distinct return cases — each @return should document a specific case and begin with "if …" (e.g. "@return [TypeA] if condition; @return [TypeB] if other condition"). Otherwise list multiple types in one @return (e.g. @return [String, nil]). [4][1]
References
[1] YARD Getting Started — Documenting Attributes (rubydoc.info).
[2] YARD Tags / @!attribute directive (rubydoc.info).
[3] Example usage / community guidance (Stack Overflow).
[4] YARD @return tag documentation and multiple-return-case guidance (rubydoc.info / YARD source).
Refactor documentation to use one @return per attribute method.
This pattern places 11 separate
@returntags before a singleattr_accessordeclaration with 11 comma-separated attributes. YARD documentation conventions specify that each attribute method should have its own documentation block with a single@returntag describing the getter's return type. Multiple@returntags are only appropriate when documenting distinct conditional return cases within the same method, each prefixed with "if ...".The current structure does not follow YARD best practices and may result in incorrect or missing documentation in the generated YARD output. Each attribute should either:
@!attribute [rw]directive with indented docstrings (useful for DSL-based attributes)Apply similar corrections to lines 42–45 (attr_writer with 3 @return tags) and verify line 47–48 (attr_reader with 1 @return tag, which is correct).