[Feature Request] YARD support as method interface
euglena1215 opened this issue · 5 comments
Suggestion
Support YARD as well as Sorbet as a method interface.
Details
I expect the following behavior.
# packs/foo/app/models/foo.rb
class Foo
# @return [Bar]
def bar
self.bar
end
end
# packs/bar/app/models/bar.rb
class Bar
end
As shown above, if a comment is placed in the bar
method that can be interpreted as YARD to the Foo
class, then the Foo
class is handled as dependent on the Bar
class.
Motivation
In our Rails application we use packwerk and use YARD to define types instead of sorbet.
(To be more precise, we use the sord gem to generate RBS from YARD to utilize type information in our editor and IDE).
I understand that you are recommending the use of Sorbet. However, if you support YARD, we can use packwerk more effectively.
I also expect that there are many Rails applications out there that do not use Sorbet, but use YARD. I think YARD support will lower the barrier to using packwerk.
Just a note that there's no explicit support for sorbet in packwerk. It "just works" since sorbet signatures are just Ruby code and use constant references. It's a lucky coincidence.
So there's no pre-existing method interface parsing mechanism that we can just add YARD to.
I do agree though that YARD support would be useful.
There are some efforts underway to allow for client configured parsers: #375
This would permit a plugin to parse classes declared in YARD comments.
Besides that though I agree it'd make sense to permit YARD comments to be parsed this way (regardless if it's implemented in packwerk itself or as a community maintained plugin in packwerk-extensions)!
Thank you for the information!
There are some efforts underway to allow for client configured parsers: #375
I look forward to waiting for that PR to be merged.
I will try to create a packwerk-yard gem with https://github.com/richardmarbach/packwerk-haml as a reference.
I am creating https://github.com/euglena1215/packwerk-yard.
I found something in the original pull request that needs to be fixed in the process of making it, so I commented on it. #375 (comment)
Thank you for the issue but we have no interest in parsing YARD in this tool.