Merge branch '20862-google-api-client'
[arvados.git] / sdk / ruby-google-api-client / yard / templates / default / docstring / setup.rb
diff --git a/sdk/ruby-google-api-client/yard/templates/default/docstring/setup.rb b/sdk/ruby-google-api-client/yard/templates/default/docstring/setup.rb
new file mode 100644 (file)
index 0000000..63a5877
--- /dev/null
@@ -0,0 +1,54 @@
+lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../../lib'))
+$LOAD_PATH.unshift(lib_dir)
+$LOAD_PATH.uniq!
+require 'yard-google-code'
+
+def init
+  return if object.docstring.blank? && !object.has_tag?(:api)
+  sections :index, [:private, :deprecated, :abstract, :todo, :note, :returns_void, :text], T('tags')
+end
+
+def private
+  return unless object.has_tag?(:api) && object.tag(:api).text == 'private'
+  erb(:private)
+end
+
+def abstract
+  return unless object.has_tag?(:abstract)
+  erb(:abstract)
+end
+
+def deprecated
+  return unless object.has_tag?(:deprecated)
+  erb(:deprecated)
+end
+
+def todo
+  return unless object.has_tag?(:todo)
+  erb(:todo)
+end
+
+def note
+  return unless object.has_tag?(:note)
+  erb(:note)
+end
+
+def returns_void
+  return unless object.type == :method
+  return if object.name == :initialize && object.scope == :instance
+  return unless object.tags(:return).size == 1 && object.tag(:return).types == ['void']
+  erb(:returns_void)
+end
+
+def docstring_text
+  text = ""
+  unless object.tags(:overload).size == 1 && object.docstring.empty?
+    text = object.docstring
+  end
+
+  if text.strip.empty? && object.tags(:return).size == 1 && object.tag(:return).text
+    text = object.tag(:return).text.gsub(/\A([a-z])/) {|x| x.upcase }
+  end
+
+  text.strip
+end
\ No newline at end of file