Open jaredcwhite opened 2 years ago
there is some precedent with Solargraphs @type
tag:
module ClassMethods
# @type [String]
@tag_name
end
It would be pretty cool if sord were to pick that up.
Thanks for the suggestion - this would be neat!
Unfortunately, I'm not sure that YARD is actually aware of instance variables :( Sord doesn't parse the tags or Ruby code itself; it just loads the YARD registry, so can only use what's there. YARD appears to know about class variables, but I can't spot anything about instance variables in the API docs, nor does it seem to generate any docs for them (unless I'm doing it wrong):
A not-great workaround I've found is to use the @!attribute
directive:
# @!attribute [r] http
# @return [::HTTPX::Session]
But then that leads to the generated documentation mentioning it as, well, an attribute.
Would it make sense for sord to register a custom tag in YARD? Something like @itype name [String]
?
This may be a limitation of YARD tags, but I have a module that's trying to set class instance variables, and I'm not sure how I can get those typings to be output by Sord. The RBS file needs to have something like this:
but how to get that instance variable definition in there is the question…