Dry yard options

I have what I suggested is a fairly simple use of the yards macro when I have a hash structure with several parameters that are shared between several functions. I was hoping to use the macro just to stop me from repeating this structure everywhere, but it doesn't seem like it.

What I expected to work was:

# @macro [new] my_hash
#   @param  $1 [Hash,Array<Hash>] Inputted my_hash
#   @option $1 [String] :a Value for A.
#   @option $1 [String] :b Value for B.
#   @option $1 [String] :c Value for C.

##
# my_func does stuff
# @macro my_hash h1
def my_func h1
end

## 
# other_func does stuff
# @macro my_hash h2
def other_func h2, a, b
end

and document h1 and h2 correctly. I think I realized that at least $ 1 doesn’t work the way it does, instead of the function itself, but I can call both h1 parameters and replace $ 1 h1 in the macro, and I still don’t get what I want,

" " http://rubydoc.info/docs/yard/file/docs/Tags.md#macro , ( , @! , , , ).

, ? - , ? , , ?

+5
3

, , . , . , [new] , -, @!macro @macro.

# @!macro my_hash
#   @param  $1 [Hash,Array<Hash>] Inputted my_hash
#   @option $1 [String] :a Value for A.
#   @option $1 [String] :b Value for B.
#   @option $1 [String] :c Value for C.

##
# my_func does stuff
# @!macro my_hash
def my_func h1
end

##
# other_func does stuff
# @!macro my_hash
def other_func h2, a, b
end
0

, , , YARDs .

:

(see OBJECT), ". OBJECT. , @param :

# @param [String] user the username for the operation
# @param [String] host the host that this user is associated with
# @param [Time] time the time that this operation took place
def clean(user, host, time = Time.now) end

# @param (see #clean)
def activate(user, host, time = Time.now) end
0

yardoc 0.9.8 (, ):

# @!macro my_hash
#   @param  $1 [Hash,Array<Hash>] Inputted my_hash
#   @option $1 [String] :a Value for A.
#   @option $1 [String] :b Value for B.
#   @option $1 [String] :c Value for C.

##
# my_func does stuff
# @macro my_hash
def my_func h1
end

##
# other_func does stuff
# @macro my_hash
def other_func h2, a, b
end

Pay attention to the missing exclamation mark! when calling macro s @macro. This is the correct syntax for yards .

0
source

All Articles