Fixed an issue where the code was expecting parameters as a hash when in fact they...
[arvados.git] / yard / templates / default / tags / setup.rb
1 lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../../lib'))
2 $LOAD_PATH.unshift(lib_dir)
3 $LOAD_PATH.uniq!
4 require 'yard-google-code'
5
6 def init
7   tags = Tags::Library.visible_tags - [:abstract, :deprecated, :note, :todo]
8   create_tag_methods(tags - [:example, :option, :overload, :see])
9   sections :index, tags
10   sections.any(:overload).push(T('docstring'))
11 end
12
13 def return
14   if object.type == :method
15     return if object.name == :initialize && object.scope == :instance
16     return if object.tags(:return).size == 1 && object.tag(:return).types == ['void']
17   end
18   tag(:return)
19 end
20
21 private
22
23 def tag(name, opts = nil)
24   return unless object.has_tag?(name)
25   opts ||= options_for_tag(name)
26   @no_names = true if opts[:no_names]
27   @no_types = true if opts[:no_types]
28   @name = name
29   out = erb('tag')
30   @no_names, @no_types = nil, nil
31   out
32 end
33
34 def create_tag_methods(tags)
35   tags.each do |tag|
36     next if respond_to?(tag)
37     instance_eval(<<-eof, __FILE__, __LINE__ + 1)
38       def #{tag}; tag(#{tag.inspect}) end
39     eof
40   end
41 end
42
43 def options_for_tag(tag)
44   opts = {:no_types => true, :no_names => true}
45   case Tags::Library.factory_method_for(tag)
46   when :with_types
47     opts[:no_types] = false
48   when :with_types_and_name
49     opts[:no_types] = false
50     opts[:no_names] = false
51   when :with_name
52     opts[:no_names] = false
53   end
54   opts
55 end