How to specify an `@since` for a method alias?

99 Views Asked by At

I am writing a Ruby gem. To document my code, I am using YARD. I have been using @since (see here) to mark in which gem versions methods have been added. However, I'm having a problem. In one version of my gem I had defined a method. Now, in a new version of the gem, I want to define an alias for that method. How, with YARD/RDoc, can I add @since to an alias?

I have tried this, which didn't work:

# ...
# @since 1.0.0
def my_method
  # ...
end
# @since 1.1.0
alias new_method my_method

Any ideas?

1

There are 1 best solutions below

1
Drenmi On

You should be able to use the @!method directive to accomplish this:

# @since 1.0.0
def my_method
  # ...
end

# @!method new_method
#   @since 1.1.0
alias new_method my_method