Skip to content
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

Attr_accessor documentation of @param broke in 436fae5 #905

Closed
now opened this issue Oct 19, 2015 · 3 comments
Closed

Attr_accessor documentation of @param broke in 436fae5 #905

now opened this issue Oct 19, 2015 · 3 comments

Comments

@now
Copy link

now commented Oct 19, 2015

The changes introduced in 436fae5 messed up the following:

# @param [String] value
# @return [String] The string’s value
attr_accessor :string

as attr_accessor’s reader won’t have a parameter. This should really be fixed, either by reverting 436fae5 (and erring on the side of not generating spurious warnings) or by adjusting the code in AttributeHandler to first add the parameters before the call to #register, then removing them (which will appease the check and still generate a correct result).

What do you think?

@lsegal
Copy link
Owner

lsegal commented Oct 19, 2015

That isn't valid documentation; YARD is correct to warn you here. When documenting an attr_accessor, you should be documenting the getter portion, i.e., only the @return tag. YARD will typically fill in the setter for you, but if you want your own setter documentation, you should use an @overload tag instead:

# @overload string
#   @return [String] the string's value
# @overload string=(value)
#   @param value [String] the value to set
attr_accessor :string

This isn't well documented, unfortunately, so I understand the confusion. Documenting attrs should have their own callout in the guide.

@lsegal
Copy link
Owner

lsegal commented Oct 19, 2015

I have some documentation improvements coming in the guide for this.

lsegal pushed a commit that referenced this issue Oct 19, 2015
Add basic information on documenting attributes in the Getting Started
Guide.

References #905
lsegal added a commit that referenced this issue Oct 19, 2015
Add basic information on documenting attributes in the Getting Started
Guide.

References #905
@now
Copy link
Author

now commented Oct 20, 2015

OK, thanks. As using @Overloads felt a bit verbose, I create the missing @param tag programmatically in my template for attribute writers instead.

@now now closed this as completed Oct 20, 2015
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

No branches or pull requests

2 participants