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

[Feature Request] YARD support as method interface #383

Closed
euglena1215 opened this issue Dec 31, 2023 · 5 comments
Closed

[Feature Request] YARD support as method interface #383

euglena1215 opened this issue Dec 31, 2023 · 5 comments

Comments

@euglena1215
Copy link

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.

@exterm
Copy link
Contributor

exterm commented Jan 1, 2024

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.

@alexevanczuk
Copy link
Contributor

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)!

@euglena1215
Copy link
Author

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.

@euglena1215
Copy link
Author

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)

@rafaelfranca
Copy link
Member

Thank you for the issue but we have no interest in parsing YARD in this tool.

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

4 participants