yard

Document model attributes with YARD

杀马特。学长 韩版系。学妹 提交于 2020-01-12 01:47:08
问题 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

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

江枫思渺然 提交于 2019-12-30 06:17:31
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . 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

Yard doc and `define_method`

让人想犯罪 __ 提交于 2019-12-23 08:04:32
问题 Is there a way to comment methods defined with define_method in YardDoc? I tried this: %w(one two three).each do |type| # The #{type} way # @return [String] the #{type} way define_method("#{type}_way") do ... end end But, unfortunately, not working. 回答1: If you move the method creation into a class method, you could use a macro: class Foo # @!macro [attach] generate # @method $1_way # The $1 way # @return [String] the $1 way def self.generate(type) define_method("#{type}_way") do end end

What's the difference between @tag and @!tag in Yard documentation tool?

最后都变了- 提交于 2019-12-13 02:18:24
问题 While looking at Yard documentation and examples sI found some tags prefixed by an exclamation mark. I found working examples with and without exclamation marks and I wasn't able to spot the difference, so what changes when @!some-tag is used instead of @some-tag ? For instance this code generate the same documentation for both attr and attr2 class Anything # @!attribute [rw] attr # @attribute [rw] attr2 end On the other side, in some examples the importance of exclamation mark is underlined,

Dynamic documentation, using the return of method in the description of another YARD?

╄→гoц情女王★ 提交于 2019-12-11 07:26:14
问题 I am documenting a project and essientially I have something similar to the following: def foo return bar(__method__) end def bar (method) return method.to_s + 'somestring' end I am setting up a multitude of methods similar to how I have implemented foo where they are they are returning the return of bar. An example is as follows: # The descriptions for foo0... # @return [String] the method name concatenated with somestring def foo0 return bar(__method__) end # The descriptions for foo1... #

yard 0.7.3 fails to build my README in both markdown and textile

半城伤御伤魂 提交于 2019-12-10 15:45:49
问题 I've decided to convert the README file in a project of mine to markdown and have been using yard verify the documentation rendered out ok. So I installed rdiscount, changed README to README.md and tried: yard doc README.md which gave me a waring: [warn]: Syntax error in `readme.md`:(3,18): syntax error, unexpected tinteger, expecting $end So I tried: yard doc -m markdown -- README.md Same problem. Running: yard doc --backtrace -- README.md gives a little bit more info: [warn]: Syntax error

How to make Yard `@macro`s apply to multiple files

我是研究僧i 提交于 2019-12-10 10:06:33
问题 If I have in one file the following: module Something class Resource # Defines a new property # @param [String] name the property name # @param [Class] type the property's type # @macro [attach] property # @return [$2] the $1 property def self.property(name, type) end end class Post < Resource property :title, String property :view_count, Integer end end The methods property defined with get documented properly. However, if I have in separate files these definitions the documentation is not

Iterating over the registers of a Yardoc `@macro`

北战南征 提交于 2019-12-09 04:00:05
问题 I am looking for way to iterate over the registers of a yardoc @macro . I know you are able to use them in something like as follows: class Post include DataMapper::Resource # @macro dm.property # @return [$2] the $1 $0 of the post property :title, String end and you are able generate the arguments the registers represent separated by comas as if you were taking a section of an array like as follows: # @macro dsl_method # @method $1(${2--2}) # @return [${-1}] the return value of $0 create

DRYing yard parameters

假装没事ソ 提交于 2019-12-07 03:27:32
问题 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]

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

你离开我真会死。 提交于 2019-12-06 05:46:38
问题 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. 回答1: 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