inch-ci / inch_ci-web

Web frontend for Inch CI
http://inch-ci.org/
MIT License
139 stars 20 forks source link

Documenting multiple attributes via @!attribute directive #67

Closed sds closed 2 months ago

sds commented 9 years ago

Which syntax for documenting attributes does InchCI support? For situations where I declare a number of attributes using a single attr_reader call, e.g.

attr_reader :attr_one, :attr_two

Ideally, I should be able to document these as:

# @!attribute attr_one
#   @return [String] description of attr_one
# @!attribute attr_two
#   @return [Integer] description of attr_two
attr_reader :attr_one, :attr_two

However, this doesn't appear to work. Am I misunderstanding how the @!attribute YARD directive is meant to be used?


Re: [U] SlimLint::Document#source_lines in sds/slim-lint

rrrene commented 9 years ago

Hi there,

this is a good question. I thought this case should be documented like so:

# @return [String] description of attr_one
attr_reader :attr_one
# @return [String] description of attr_two
attr_reader :attr_two

This seems to be the case since 2010: https://gist.github.com/koraktor/587533

I will try to take another look after work.

sds commented 9 years ago

I was trying to stay away from using @attr_reader since according to YARD's documentation all @attr*-related tags are deprecated in favor of @!attribute (see http://www.rubydoc.info/gems/yard/file/docs/Tags.md).

I'm fine splitting up the declarations and using the deprecated form for now, but it would be great to have Inch recognize it.

rrrene commented 9 years ago

@sds no,no, noooooo :grin: ... that's not what I meant by posting the link.

I was trying to describe that I do it using @return tags on individual attributes.

# @return [String] description of attr_one
attr_reader :attr_one
# @return [String] description of attr_two
attr_reader :attr_two

Some think this bloats their code (to put each attribute on its own line). I posted the link simply because the gist suggests that the "one attribute per line" thing is around since the days of @attr_reader, not to advise you to use it.

sds commented 9 years ago

Sorry for the confusion, I mispoke (long day for me).

I indeed didn't end up using @attr_reader. Thanks for the clarification that it isn't necessary in this case. :)