yard 0.9.29 → 0.9.30
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/docs/CodeObjects.md +115 -0
- data/docs/GettingStarted.md +679 -0
- data/docs/Handlers.md +152 -0
- data/docs/Overview.md +61 -0
- data/docs/Parser.md +191 -0
- data/docs/Tags.md +283 -0
- data/docs/TagsArch.md +123 -0
- data/docs/Templates.md +496 -0
- data/docs/WhatsNew.md +1245 -0
- data/docs/images/code-objects-class-diagram.png +0 -0
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/images/tags-class-diagram.png +0 -0
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +9 -0
- data/docs/templates/default/fulldoc/html/setup.rb +6 -0
- data/docs/templates/default/layout/html/setup.rb +9 -0
- data/docs/templates/default/layout/html/tag_list.erb +11 -0
- data/docs/templates/default/yard_tags/html/list.erb +18 -0
- data/docs/templates/default/yard_tags/html/setup.rb +26 -0
- data/docs/templates/plugin.rb +70 -0
- data/lib/yard/version.rb +1 -1
- data/po/ja.po +31108 -0
- data/templates/default/class/dot/setup.rb +7 -0
- data/templates/default/class/dot/superklass.erb +3 -0
- data/templates/default/class/html/constructor_details.erb +8 -0
- data/templates/default/class/html/setup.rb +2 -0
- data/templates/default/class/html/subclasses.erb +4 -0
- data/templates/default/class/setup.rb +36 -0
- data/templates/default/class/text/setup.rb +12 -0
- data/templates/default/class/text/subclasses.erb +5 -0
- data/templates/default/constant/text/header.erb +11 -0
- data/templates/default/constant/text/setup.rb +4 -0
- data/templates/default/docstring/html/abstract.erb +4 -0
- data/templates/default/docstring/html/deprecated.erb +1 -0
- data/templates/default/docstring/html/index.erb +5 -0
- data/templates/default/docstring/html/note.erb +6 -0
- data/templates/default/docstring/html/private.erb +4 -0
- data/templates/default/docstring/html/returns_void.erb +1 -0
- data/templates/default/docstring/html/text.erb +1 -0
- data/templates/default/docstring/html/todo.erb +6 -0
- data/templates/default/docstring/setup.rb +52 -0
- data/templates/default/docstring/text/abstract.erb +2 -0
- data/templates/default/docstring/text/deprecated.erb +2 -0
- data/templates/default/docstring/text/index.erb +2 -0
- data/templates/default/docstring/text/note.erb +4 -0
- data/templates/default/docstring/text/private.erb +2 -0
- data/templates/default/docstring/text/returns_void.erb +1 -0
- data/templates/default/docstring/text/text.erb +1 -0
- data/templates/default/docstring/text/todo.erb +4 -0
- data/templates/default/fulldoc/html/css/common.css +1 -0
- data/templates/default/fulldoc/html/css/full_list.css +58 -0
- data/templates/default/fulldoc/html/css/style.css +497 -0
- data/templates/default/fulldoc/html/frames.erb +17 -0
- data/templates/default/fulldoc/html/full_list.erb +37 -0
- data/templates/default/fulldoc/html/full_list_class.erb +2 -0
- data/templates/default/fulldoc/html/full_list_file.erb +7 -0
- data/templates/default/fulldoc/html/full_list_method.erb +10 -0
- data/templates/default/fulldoc/html/js/app.js +314 -0
- data/templates/default/fulldoc/html/js/full_list.js +216 -0
- data/templates/default/fulldoc/html/js/jquery.js +4 -0
- data/templates/default/fulldoc/html/setup.rb +241 -0
- data/templates/default/layout/dot/header.erb +6 -0
- data/templates/default/layout/dot/setup.rb +15 -0
- data/templates/default/layout/html/breadcrumb.erb +11 -0
- data/templates/default/layout/html/files.erb +11 -0
- data/templates/default/layout/html/footer.erb +5 -0
- data/templates/default/layout/html/headers.erb +15 -0
- data/templates/default/layout/html/index.erb +2 -0
- data/templates/default/layout/html/layout.erb +24 -0
- data/templates/default/layout/html/listing.erb +4 -0
- data/templates/default/layout/html/objects.erb +32 -0
- data/templates/default/layout/html/script_setup.erb +4 -0
- data/templates/default/layout/html/search.erb +13 -0
- data/templates/default/layout/html/setup.rb +89 -0
- data/templates/default/method/html/header.erb +17 -0
- data/templates/default/method/setup.rb +4 -0
- data/templates/default/method/text/header.erb +1 -0
- data/templates/default/method_details/html/header.erb +3 -0
- data/templates/default/method_details/html/method_signature.erb +25 -0
- data/templates/default/method_details/html/source.erb +10 -0
- data/templates/default/method_details/setup.rb +11 -0
- data/templates/default/method_details/text/header.erb +10 -0
- data/templates/default/method_details/text/method_signature.erb +12 -0
- data/templates/default/method_details/text/setup.rb +11 -0
- data/templates/default/module/dot/child.erb +1 -0
- data/templates/default/module/dot/dependencies.erb +3 -0
- data/templates/default/module/dot/header.erb +6 -0
- data/templates/default/module/dot/info.erb +14 -0
- data/templates/default/module/dot/setup.rb +15 -0
- data/templates/default/module/html/attribute_details.erb +10 -0
- data/templates/default/module/html/attribute_summary.erb +8 -0
- data/templates/default/module/html/box_info.erb +43 -0
- data/templates/default/module/html/children.erb +8 -0
- data/templates/default/module/html/constant_summary.erb +17 -0
- data/templates/default/module/html/defines.erb +3 -0
- data/templates/default/module/html/header.erb +5 -0
- data/templates/default/module/html/inherited_attributes.erb +14 -0
- data/templates/default/module/html/inherited_constants.erb +8 -0
- data/templates/default/module/html/inherited_methods.erb +19 -0
- data/templates/default/module/html/item_summary.erb +40 -0
- data/templates/default/module/html/method_details_list.erb +9 -0
- data/templates/default/module/html/method_summary.erb +14 -0
- data/templates/default/module/html/methodmissing.erb +12 -0
- data/templates/default/module/html/pre_docstring.erb +1 -0
- data/templates/default/module/setup.rb +167 -0
- data/templates/default/module/text/children.erb +10 -0
- data/templates/default/module/text/class_meths_list.erb +8 -0
- data/templates/default/module/text/extends.erb +8 -0
- data/templates/default/module/text/header.erb +7 -0
- data/templates/default/module/text/includes.erb +8 -0
- data/templates/default/module/text/instance_meths_list.erb +8 -0
- data/templates/default/module/text/setup.rb +13 -0
- data/templates/default/onefile/html/files.erb +5 -0
- data/templates/default/onefile/html/headers.erb +6 -0
- data/templates/default/onefile/html/layout.erb +17 -0
- data/templates/default/onefile/html/readme.erb +3 -0
- data/templates/default/onefile/html/setup.rb +62 -0
- data/templates/default/root/dot/child.erb +3 -0
- data/templates/default/root/dot/setup.rb +6 -0
- data/templates/default/root/html/setup.rb +2 -0
- data/templates/default/tags/html/example.erb +11 -0
- data/templates/default/tags/html/index.erb +3 -0
- data/templates/default/tags/html/option.erb +24 -0
- data/templates/default/tags/html/overload.erb +14 -0
- data/templates/default/tags/html/see.erb +8 -0
- data/templates/default/tags/html/tag.erb +20 -0
- data/templates/default/tags/setup.rb +57 -0
- data/templates/default/tags/text/example.erb +12 -0
- data/templates/default/tags/text/index.erb +1 -0
- data/templates/default/tags/text/option.erb +20 -0
- data/templates/default/tags/text/overload.erb +19 -0
- data/templates/default/tags/text/see.erb +11 -0
- data/templates/default/tags/text/tag.erb +13 -0
- data/templates/guide/class/html/setup.rb +2 -0
- data/templates/guide/docstring/html/setup.rb +2 -0
- data/templates/guide/fulldoc/html/css/style.css +108 -0
- data/templates/guide/fulldoc/html/js/app.js +33 -0
- data/templates/guide/fulldoc/html/setup.rb +74 -0
- data/templates/guide/layout/html/layout.erb +81 -0
- data/templates/guide/layout/html/setup.rb +25 -0
- data/templates/guide/method/html/header.erb +18 -0
- data/templates/guide/method/html/setup.rb +22 -0
- data/templates/guide/module/html/header.erb +7 -0
- data/templates/guide/module/html/method_list.erb +5 -0
- data/templates/guide/module/html/setup.rb +27 -0
- data/templates/guide/onefile/html/files.erb +4 -0
- data/templates/guide/onefile/html/setup.rb +6 -0
- data/templates/guide/onefile/html/toc.erb +3 -0
- data/templates/guide/tags/html/setup.rb +9 -0
- metadata +151 -2
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
include Helpers::ModuleHelper
|
3
|
+
|
4
|
+
def init
|
5
|
+
sections :header, :box_info, :pre_docstring, T('docstring'), :children,
|
6
|
+
:constant_summary, [T('docstring')], :inherited_constants,
|
7
|
+
:attribute_summary, [:item_summary], :inherited_attributes,
|
8
|
+
:method_summary, [:item_summary], :inherited_methods,
|
9
|
+
:methodmissing, [T('method_details')],
|
10
|
+
:attribute_details, [T('method_details')],
|
11
|
+
:method_details_list, [T('method_details')]
|
12
|
+
end
|
13
|
+
|
14
|
+
def pre_docstring
|
15
|
+
return if object.docstring.blank?
|
16
|
+
erb(:pre_docstring)
|
17
|
+
end
|
18
|
+
|
19
|
+
def children
|
20
|
+
@inner = [[:modules, []], [:classes, []]]
|
21
|
+
object.children.each do |child|
|
22
|
+
@inner[0][1] << child if child.type == :module
|
23
|
+
@inner[1][1] << child if child.type == :class
|
24
|
+
end
|
25
|
+
@inner.map! {|v| [v[0], run_verifier(v[1].sort_by {|o| o.name.to_s })] }
|
26
|
+
return if (@inner[0][1].size + @inner[1][1].size) == 0
|
27
|
+
erb(:children)
|
28
|
+
end
|
29
|
+
|
30
|
+
def methodmissing
|
31
|
+
mms = object.meths(:inherited => true, :included => true)
|
32
|
+
@mm = mms.find {|o| o.name == :method_missing && o.scope == :instance }
|
33
|
+
erb(:methodmissing) if @mm
|
34
|
+
end
|
35
|
+
|
36
|
+
def method_listing(include_specials = true)
|
37
|
+
return @smeths ||= method_listing.reject {|o| special_method?(o) } unless include_specials
|
38
|
+
return @meths if defined?(@meths) && @meths
|
39
|
+
@meths = object.meths(:inherited => false, :included => !options.embed_mixins.empty?)
|
40
|
+
unless options.embed_mixins.empty?
|
41
|
+
@meths = @meths.reject {|m| options.embed_mixins_match?(m.namespace) == false }
|
42
|
+
end
|
43
|
+
@meths = sort_listing(prune_method_listing(@meths))
|
44
|
+
@meths
|
45
|
+
end
|
46
|
+
|
47
|
+
def special_method?(meth)
|
48
|
+
return true if meth.name(true) == '#method_missing'
|
49
|
+
return true if meth.constructor?
|
50
|
+
false
|
51
|
+
end
|
52
|
+
|
53
|
+
def attr_listing
|
54
|
+
return @attrs if defined?(@attrs) && @attrs
|
55
|
+
@attrs = []
|
56
|
+
object.inheritance_tree(true).each do |superclass|
|
57
|
+
next if superclass.is_a?(CodeObjects::Proxy)
|
58
|
+
next if !options.embed_mixins.empty? &&
|
59
|
+
!options.embed_mixins_match?(superclass)
|
60
|
+
[:class, :instance].each do |scope|
|
61
|
+
superclass.attributes[scope].each do |_name, rw|
|
62
|
+
attr = prune_method_listing([rw[:read], rw[:write]].compact, false).first
|
63
|
+
@attrs << attr if attr
|
64
|
+
end
|
65
|
+
end
|
66
|
+
break if options.embed_mixins.empty?
|
67
|
+
end
|
68
|
+
@attrs = sort_listing(@attrs)
|
69
|
+
end
|
70
|
+
|
71
|
+
def constant_listing
|
72
|
+
return @constants if defined?(@constants) && @constants
|
73
|
+
@constants = object.constants(:included => false, :inherited => false)
|
74
|
+
@constants += object.cvars
|
75
|
+
@constants = run_verifier(@constants)
|
76
|
+
@constants
|
77
|
+
end
|
78
|
+
|
79
|
+
def sort_listing(list)
|
80
|
+
list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] }
|
81
|
+
end
|
82
|
+
|
83
|
+
def inherited_attr_list
|
84
|
+
object.inheritance_tree(true)[1..-1].each do |superclass|
|
85
|
+
next if superclass.is_a?(YARD::CodeObjects::Proxy)
|
86
|
+
next if !options.embed_mixins.empty? && options.embed_mixins_match?(superclass) != false
|
87
|
+
attribs = superclass.attributes[:instance]
|
88
|
+
attribs = attribs.select {|name, _rw| object.child(:scope => :instance, :name => name).nil? }
|
89
|
+
attribs = attribs.sort_by {|args| args.first.to_s }.map {|_n, m| m[:read] || m[:write] }
|
90
|
+
attribs = prune_method_listing(attribs, false)
|
91
|
+
yield superclass, attribs unless attribs.empty?
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def inherited_constant_list
|
96
|
+
object.inheritance_tree(true)[1..-1].each do |superclass|
|
97
|
+
next if superclass.is_a?(YARD::CodeObjects::Proxy)
|
98
|
+
next if !options.embed_mixins.empty? && options.embed_mixins_match?(superclass) != false
|
99
|
+
consts = superclass.constants(:included => false, :inherited => false)
|
100
|
+
consts = consts.select {|const| object.child(:type => :constant, :name => const.name).nil? }
|
101
|
+
consts = consts.sort_by {|const| const.name.to_s }
|
102
|
+
consts = run_verifier(consts)
|
103
|
+
yield superclass, consts unless consts.empty?
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def docstring_full(obj)
|
108
|
+
docstring = obj.tags(:overload).size == 1 && obj.docstring.empty? ?
|
109
|
+
obj.tag(:overload).docstring : obj.docstring
|
110
|
+
|
111
|
+
if docstring.summary.empty? && obj.tags(:return).size == 1 && obj.tag(:return).text
|
112
|
+
docstring = Docstring.new(obj.tag(:return).text.gsub(/\A([a-z])/, &:upcase).strip)
|
113
|
+
end
|
114
|
+
|
115
|
+
docstring
|
116
|
+
end
|
117
|
+
|
118
|
+
def docstring_summary(obj)
|
119
|
+
docstring_full(obj).summary
|
120
|
+
end
|
121
|
+
|
122
|
+
def groups(list, type = "Method")
|
123
|
+
groups_data = object.groups
|
124
|
+
if groups_data
|
125
|
+
list.each {|m| groups_data |= [m.group] if m.group && owner != m.namespace }
|
126
|
+
others = list.select {|m| !m.group || !groups_data.include?(m.group) }
|
127
|
+
groups_data.each do |name|
|
128
|
+
items = list.select {|m| m.group == name }
|
129
|
+
yield(items, name) unless items.empty?
|
130
|
+
end
|
131
|
+
else
|
132
|
+
others = []
|
133
|
+
group_data = {}
|
134
|
+
list.each do |itm|
|
135
|
+
if itm.group
|
136
|
+
(group_data[itm.group] ||= []) << itm
|
137
|
+
else
|
138
|
+
others << itm
|
139
|
+
end
|
140
|
+
end
|
141
|
+
group_data.each {|group, items| yield(items, group) unless items.empty? }
|
142
|
+
end
|
143
|
+
|
144
|
+
return if others.empty?
|
145
|
+
if others.first.respond_to?(:scope)
|
146
|
+
scopes(others) {|items, scope| yield(items, "#{scope.to_s.capitalize} #{type} Summary") }
|
147
|
+
else
|
148
|
+
yield(others, "#{type} Summary")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def scopes(list)
|
153
|
+
[:class, :instance].each do |scope|
|
154
|
+
items = list.select {|m| m.scope == scope }
|
155
|
+
yield(items, scope) unless items.empty?
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def mixed_into(object)
|
160
|
+
unless globals.mixed_into
|
161
|
+
globals.mixed_into = {}
|
162
|
+
list = run_verifier Registry.all(:class, :module)
|
163
|
+
list.each {|o| o.mixins.each {|m| (globals.mixed_into[m.path] ||= []) << o } }
|
164
|
+
end
|
165
|
+
|
166
|
+
globals.mixed_into[object.path] || []
|
167
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
def init
|
3
|
+
sections :header, [T('docstring')], :children, :includes, :extends,
|
4
|
+
:class_meths_list, :instance_meths_list
|
5
|
+
end
|
6
|
+
|
7
|
+
def class_meths
|
8
|
+
@classmeths ||= method_listing.select {|o| o.scope == :class }
|
9
|
+
end
|
10
|
+
|
11
|
+
def instance_meths
|
12
|
+
@instmeths ||= method_listing.select {|o| o.scope == :instance }
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
|
6
|
+
<title><%= defined?(@title) ? @title : '' %></title>
|
7
|
+
<%= erb(:headers) %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div id="content">
|
11
|
+
<h1><%= defined?(@title) ? @title : '' %></h1>
|
12
|
+
<%= yieldall %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<%= erb(:footer) %>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
include T('default/layout/html')
|
3
|
+
include YARD::Parser::Ruby::Legacy
|
4
|
+
|
5
|
+
def init
|
6
|
+
override_serializer
|
7
|
+
@object = YARD::Registry.root
|
8
|
+
@files.shift
|
9
|
+
@objects.delete(YARD::Registry.root)
|
10
|
+
@objects.unshift(YARD::Registry.root)
|
11
|
+
sections :layout, [:readme, :files, :all_objects]
|
12
|
+
end
|
13
|
+
|
14
|
+
def all_objects
|
15
|
+
@objects.map {|obj| obj.format(options) }.join("\n")
|
16
|
+
end
|
17
|
+
|
18
|
+
def layout
|
19
|
+
layout = Object.new.extend(T('layout'))
|
20
|
+
@css_data = layout.stylesheets.map {|sheet| read_asset(sheet) }.join("\n")
|
21
|
+
@js_data = layout.javascripts.map {|script| read_asset(script) }.join("")
|
22
|
+
|
23
|
+
erb(:layout)
|
24
|
+
end
|
25
|
+
|
26
|
+
def read_asset(file)
|
27
|
+
file = T('fulldoc').find_file(file)
|
28
|
+
return unless file
|
29
|
+
data = File.read(file)
|
30
|
+
superfile = self.class.find_nth_file('fulldoc', 2)
|
31
|
+
data.gsub!('{{{__super__}}}', superfile ? IO.read(superfile) : "")
|
32
|
+
data
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def parse_top_comments_from_file
|
38
|
+
return unless defined?(@readme) && @readme
|
39
|
+
return @readme.contents unless @readme.filename =~ /\.rb$/
|
40
|
+
data = ""
|
41
|
+
tokens = TokenList.new(@readme.contents)
|
42
|
+
tokens.each do |token|
|
43
|
+
break unless token.is_a?(RubyToken::TkCOMMENT) || token.is_a?(RubyToken::TkNL)
|
44
|
+
data += (token.text[/\A#\s{0,1}(.*)/, 1] || "\n")
|
45
|
+
end
|
46
|
+
YARD::Docstring.new(data)
|
47
|
+
end
|
48
|
+
|
49
|
+
def override_serializer
|
50
|
+
return if @serializer.nil?
|
51
|
+
class << @serializer
|
52
|
+
define_method(:serialize) do |object, data|
|
53
|
+
return unless object == 'index.html'
|
54
|
+
super(object, data)
|
55
|
+
end
|
56
|
+
|
57
|
+
define_method(:serialized_path) do |object|
|
58
|
+
return object if object.is_a?(String)
|
59
|
+
'index.html'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% if object.has_tag?(:example) %>
|
2
|
+
<div class="examples">
|
3
|
+
<p class="tag_title">Examples:</p>
|
4
|
+
<% object.tags(:example).each do |tag| %>
|
5
|
+
<% unless tag.name.empty? %>
|
6
|
+
<p class="example_title"><%= htmlify_line(tag.name) %></p>
|
7
|
+
<% end %>
|
8
|
+
<pre class="example code"><code><%= html_syntax_highlight(tag.text) %></code></pre>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<% if object.has_tag?(:option) %>
|
2
|
+
<% object.parameters.each do |param, default| %>
|
3
|
+
<% tags = object.tags(:option).select {|x| x.name.to_s == param.to_s.sub(/^\*+|:$/, '') } %>
|
4
|
+
<% next if tags.empty? %>
|
5
|
+
<p class="tag_title">Options Hash (<tt><%= param %></tt>):</p>
|
6
|
+
<ul class="option">
|
7
|
+
<% for tag in tags %>
|
8
|
+
<li>
|
9
|
+
<span class="name"><%= tag.pair.name %></span>
|
10
|
+
<span class="type"><%= format_types(tag.pair.types || ['Object']) %></span>
|
11
|
+
<span class="default">
|
12
|
+
<% if tag.pair.defaults %>
|
13
|
+
— default:
|
14
|
+
<%= tag.pair.defaults.map {|t| "<tt>#{h t}</tt>" }.join(", ") %>
|
15
|
+
<% end %>
|
16
|
+
</span>
|
17
|
+
<% if tag.pair.text && tag.pair.text =~ /\S/ %>
|
18
|
+
— <%= htmlify_line(tag.pair.text) %>
|
19
|
+
<% end %>
|
20
|
+
</li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% if object.tags(:overload).size == 1 %>
|
2
|
+
<%= yieldall :object => object.tag(:overload) %>
|
3
|
+
<% elsif object.has_tag?(:overload) && object.tags(:overload).any? {|o| !o.docstring.blank? } %>
|
4
|
+
<p class="tag_title">Overloads:</p>
|
5
|
+
<ul class="overload">
|
6
|
+
<% object.tags(:overload).each do |overload| %>
|
7
|
+
<% next if overload.docstring.blank? %>
|
8
|
+
<li class="overload_item">
|
9
|
+
<span class="signature"><%= signature(overload, false, false) %></span>
|
10
|
+
<%= yieldall :object => overload %>
|
11
|
+
</li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<p class="tag_title"><%= (defined?(@label) && @label) ? @label : YARD::Tags::Library.labels[@name] %>:</p>
|
2
|
+
<ul class="<%= @name %>">
|
3
|
+
<% object.tags(@name).each do |tag| %>
|
4
|
+
<li>
|
5
|
+
<% unless @no_names %>
|
6
|
+
<span class='name'><%= h tag.name %></span>
|
7
|
+
<% end %>
|
8
|
+
<% unless @no_types %>
|
9
|
+
<span class='type'><%= format_types(tag.types) %></span>
|
10
|
+
<% end %>
|
11
|
+
<% if @name == :param && (o=object.parameters.find {|a| [tag.name.to_s, tag.name.to_s + ":"].include?(a[0]) }) && o[1] %>
|
12
|
+
<em class="default">(defaults to: <tt><%= h o[1] %></tt>)</em>
|
13
|
+
<% end %>
|
14
|
+
<% if tag.text && !tag.text.empty? %>
|
15
|
+
<% unless (@no_types || tag.types.nil? || tag.types.empty?) && @no_names %>—<% end %>
|
16
|
+
<%= htmlify_line(tag.text) %>
|
17
|
+
<% end %>
|
18
|
+
</li>
|
19
|
+
<% end %>
|
20
|
+
</ul>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
def init
|
3
|
+
tags = Tags::Library.visible_tags - [:abstract, :deprecated, :note, :todo]
|
4
|
+
create_tag_methods(tags - [:example, :option, :overload, :see])
|
5
|
+
sections :index, tags.map {|t| t.to_s.tr('.', '_').to_sym }
|
6
|
+
sections.any(:overload).push(T('docstring'))
|
7
|
+
end
|
8
|
+
|
9
|
+
def return
|
10
|
+
if object.type == :method
|
11
|
+
return if object.constructor?
|
12
|
+
return if object.tags(:return).size == 1 && object.tag(:return).types == ['void']
|
13
|
+
end
|
14
|
+
tag(:return)
|
15
|
+
end
|
16
|
+
|
17
|
+
def param
|
18
|
+
tag(:param) if object.type == :method
|
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 = opts[:no_names] ? true : false
|
27
|
+
@no_types = opts[:no_types] ? true : false
|
28
|
+
@name = name
|
29
|
+
out = erb('tag')
|
30
|
+
@no_names = nil
|
31
|
+
@no_types = nil
|
32
|
+
out
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_tag_methods(tags)
|
36
|
+
tags.each do |tag|
|
37
|
+
tag_meth = tag.to_s.tr('.', '_')
|
38
|
+
next if respond_to?(tag_meth)
|
39
|
+
instance_eval(<<-eof, __FILE__, __LINE__ + 1)
|
40
|
+
def #{tag_meth}; tag(#{tag.inspect}) end
|
41
|
+
eof
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def options_for_tag(tag)
|
46
|
+
opts = {:no_types => true, :no_names => true}
|
47
|
+
case Tags::Library.factory_method_for(tag)
|
48
|
+
when :with_types
|
49
|
+
opts[:no_types] = false
|
50
|
+
when :with_types_and_name
|
51
|
+
opts[:no_types] = false
|
52
|
+
opts[:no_names] = false
|
53
|
+
when :with_name
|
54
|
+
opts[:no_names] = false
|
55
|
+
end
|
56
|
+
opts
|
57
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% if object.has_tag?(:example) %>
|
2
|
+
|
3
|
+
Examples:
|
4
|
+
---------
|
5
|
+
|
6
|
+
<% object.tags(:example).each_with_index do |tag, i| %>
|
7
|
+
<%= indent("# " + tag.name + "\n") if tag.name %>
|
8
|
+
<%= indent(format_source(tag.text)) + "\n" %>
|
9
|
+
<%= "\n" if i < object.tags(:example).size - 1 %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yieldall %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% if object.has_tag?(:option) %>
|
2
|
+
<% object.parameters.each do |param, default| %>
|
3
|
+
<% tags = object.tags(:option).select {|x| x.name.to_s == param.to_s.sub(/^\*+|:$/, '') } %>
|
4
|
+
<% next if tags.empty? %>
|
5
|
+
Options Hash (<%= param %>):
|
6
|
+
--------------<%= hr(param.to_s.length) %>--
|
7
|
+
|
8
|
+
<% for tag in tags %>
|
9
|
+
<% text = "" %>
|
10
|
+
<% text += format_types(tag.pair.types || ['Object']) %>
|
11
|
+
<% text += " " + tag.pair.name.to_s %>
|
12
|
+
<% if tag.pair.defaults %>
|
13
|
+
<% text += " - default: " + tag.pair.defaults.join(", ") %>
|
14
|
+
<% end %>
|
15
|
+
<% text += " - " + tag.pair.text if tag.pair.text %>
|
16
|
+
<%= indent(wrap(text)) %>
|
17
|
+
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% if object.tags(:overload).size == 1 %>
|
2
|
+
<%= wrap(yieldall(:object => object.tag(:overload))) %>
|
3
|
+
<% elsif object.has_tag?(:overload) %>
|
4
|
+
Overloads:
|
5
|
+
----------
|
6
|
+
|
7
|
+
<% object.tags(:overload).each do |overload| %>
|
8
|
+
<% if overload.tags.size > 0 %>
|
9
|
+
<%= hr %>
|
10
|
+
|
11
|
+
<%= indent signature(overload) %>
|
12
|
+
|
13
|
+
<%= hr %>
|
14
|
+
|
15
|
+
<%= indent(wrap(yieldall(:object => overload))) %>
|
16
|
+
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% title = (defined?(@label) && @label) ? @label : YARD::Tags::Library.labels[@name] %>
|
2
|
+
<%= title %>:
|
3
|
+
<%= hr(title.length) %>-
|
4
|
+
|
5
|
+
<% object.tags(@name).each do |tag| %>
|
6
|
+
<% text = "" %>
|
7
|
+
<% text += format_types(tag.types) + " " unless @no_types || tag.types.nil? %>
|
8
|
+
<% text += tag.name.to_s + " " unless @no_names %>
|
9
|
+
<% text += "- " unless @no_names && @no_types %>
|
10
|
+
<% text += tag.text if tag.text && !tag.text.empty? %>
|
11
|
+
<%= indent wrap(text) %>
|
12
|
+
|
13
|
+
<% end %>
|