yard

DRYing yard parameters

别等时光非礼了梦想. 提交于 2019-12-05 08:02:23
I've got what i assumed was a fairly basic yard macro usage where i have a Hash structure with a number of options that is shared between multiple functions. I was hoping to use a macro simply to prevent me having to replicate this structure all over the place but it doesn't seem to work like that. 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

How to prevent [view source] link when creating documentation using yard?

痞子三分冷 提交于 2019-12-04 11:18:28
I am using yard to generate project documentation, but i don't want to display the [view source] link in the documentation, i have dived into the yard official guides but still don't get the solution. Anything ideas? Thanks. I might be a little late but you can trivially customize the default template by removing the "source" section from the method_details partial. You can do so by creating the file "my_template/default/method_details/setup.rb" in the root of your project with the contents: def init super sections.first.delete(:source) end Then you can call YARD with your custom template

Document model attributes with YARD

此生再无相见时 提交于 2019-12-02 22:57:32
I'm using YARD to generate docs for my rails app with makrdown as the script parser. Most of the documentation features just work great right out of the box. However, I'd also like to document the model attributes to one, record the list of available attributes on a model and two, to describe their semantic meaning. I wasn't able to find any special support for this in YARD and I'm basically left with simply listing out the attributes in the class comments. Is there a way to document the dynamically generated model attributes so that they appear in the documentation like standard attributes

Best way to document “splatted” parameter with YARD? [closed]

感情迁移 提交于 2019-11-30 18:48:04
I have a method that should take 1+ parameters of any class, similar to Array#push : def my_push(*objects) raise ArgumentError, 'Needs 1+ arguments' if objects.empty? objects.each do |obj| puts "An object was pushed: #{obj.inspect}" @my_array.push obj end end What is the best way to document the method parameters using YARD syntax? Edit: I realize that my original question was a bit too vague and didn't quite specify what I was looking for. A better question would be, what is the best way to specify the arity of a method (1-∞ in this case) in YARD when using a splatted parameter? I know I