I'm writing my first gem which I'm documenting with YARD. I've made one of my classes have a constructor which expects a block which takes no arguments1.
YARD provides the @yield [params] description
tag to describe a block argument in terms of the parameters a method will pass to it, but it doesn't format properly if the params
list is empty. How should I document a block with no parameters?
1: Technically, I'm not even yield
ing to the block; I have code that looks like this:
def initialize(&block)
define_singleton_method(:create, block)
create
class << self; undef_method :create; end
end
...so the block contains code to be run in the context of the newly-created object. If this is a terrible idea for some reason, I'd be glad to know that, too :)
I found an old issue on YARD's github page; it looks like the parameters block should just be omitted:
# @yield Description of the block here
def initialize(&block)
define_singleton_method(:create, block)
create
class << self; undef_method :create; end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With