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

How can I reference the current class as a return type in YARD? #1584

Open
stdedos opened this issue Sep 18, 2024 · 0 comments
Open

How can I reference the current class as a return type in YARD? #1584

stdedos opened this issue Sep 18, 2024 · 0 comments

Comments

@stdedos
Copy link

stdedos commented Sep 18, 2024

[Describe your issue here. Try to be as specific as possible so we can find
the root cause more quickly!]

Steps to reproduce

I am asking whether the question https://stackoverflow.com/q/56287625/2309247 has been considered

Consider a code like this:

module Foo
  # returns a copy of self
  # @return [ ___ ]
  def returns_new_self
    self.class.new
  end
end

class Bar
  include Foo
end

class Zap
  include Foo
end

With this, Bar.new.returns_new_self will return another Bar, and the same goes with Zap.new.returns_new_self.

I want to have retuns_new_self YARD-documented with a return type.
It will be nice if I could do something like @return [Self] as the Self in Rust.

Can I do something similar?

In my case, I do not care much about the generated documentation - only the fact that IntelliJ / Rubymine give coding hints is enough for me.

I don't know if it makes any difference from the code above, but in my case I am dealing with a Folder < UUIDRow < Row code, and I am implementing something at Row

Actual Output

[Provide the full output (please run yard with --debug) or screenshots for
visual issues.]

Expected Output

[Describe what you expected to happen.]

Environment details:

  • OS: [Enter operating system / version here]
  • Ruby version (ruby -v): [Enter output of ruby -v]
  • YARD version (yard -v): [Enter output of yard -v]
  • Relevant software dependency/versions:
    • [Any 3rd party libs required to reproduce, omit if none]

I have read the Contributing Guide.

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

1 participant