yard-to_mkdocs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/yard/to_mkdocs/default/class/dot/setup.rb +7 -0
- data/lib/yard/to_mkdocs/default/class/dot/superklass.erb +3 -0
- data/lib/yard/to_mkdocs/default/class/html/constructor_details.erb +7 -0
- data/lib/yard/to_mkdocs/default/class/html/setup.rb +2 -0
- data/lib/yard/to_mkdocs/default/class/html/subclasses.erb +3 -0
- data/lib/yard/to_mkdocs/default/class/setup.rb +36 -0
- data/lib/yard/to_mkdocs/default/class/text/setup.rb +12 -0
- data/lib/yard/to_mkdocs/default/class/text/subclasses.erb +5 -0
- data/lib/yard/to_mkdocs/default/constant/text/header.erb +9 -0
- data/lib/yard/to_mkdocs/default/constant/text/setup.rb +4 -0
- data/lib/yard/to_mkdocs/default/docstring/html/abstract.erb +1 -0
- data/lib/yard/to_mkdocs/default/docstring/html/deprecated.erb +1 -0
- data/lib/yard/to_mkdocs/default/docstring/html/index.erb +5 -0
- data/lib/yard/to_mkdocs/default/docstring/html/note.erb +4 -0
- data/lib/yard/to_mkdocs/default/docstring/html/private.erb +1 -0
- data/lib/yard/to_mkdocs/default/docstring/html/returns_void.erb +1 -0
- data/lib/yard/to_mkdocs/default/docstring/html/text.erb +1 -0
- data/lib/yard/to_mkdocs/default/docstring/html/todo.erb +4 -0
- data/lib/yard/to_mkdocs/default/docstring/setup.rb +52 -0
- data/lib/yard/to_mkdocs/default/docstring/text/abstract.erb +2 -0
- data/lib/yard/to_mkdocs/default/docstring/text/deprecated.erb +2 -0
- data/lib/yard/to_mkdocs/default/docstring/text/index.erb +2 -0
- data/lib/yard/to_mkdocs/default/docstring/text/note.erb +4 -0
- data/lib/yard/to_mkdocs/default/docstring/text/private.erb +2 -0
- data/lib/yard/to_mkdocs/default/docstring/text/returns_void.erb +1 -0
- data/lib/yard/to_mkdocs/default/docstring/text/text.erb +1 -0
- data/lib/yard/to_mkdocs/default/docstring/text/todo.erb +4 -0
- data/lib/yard/to_mkdocs/default/fulldoc/html/frames.erb +0 -0
- data/lib/yard/to_mkdocs/default/fulldoc/html/full_list.erb +1 -0
- data/lib/yard/to_mkdocs/default/fulldoc/html/full_list_class.erb +3 -0
- data/lib/yard/to_mkdocs/default/fulldoc/html/full_list_file.erb +4 -0
- data/lib/yard/to_mkdocs/default/fulldoc/html/full_list_method.erb +4 -0
- data/lib/yard/to_mkdocs/default/fulldoc/html/setup.rb +184 -0
- data/lib/yard/to_mkdocs/default/layout/dot/header.erb +6 -0
- data/lib/yard/to_mkdocs/default/layout/dot/setup.rb +15 -0
- data/lib/yard/to_mkdocs/default/layout/html/breadcrumb.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/files.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/footer.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/headers.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/index.erb +3 -0
- data/lib/yard/to_mkdocs/default/layout/html/layout.erb +1 -0
- data/lib/yard/to_mkdocs/default/layout/html/listing.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/objects.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/script_setup.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/search.erb +0 -0
- data/lib/yard/to_mkdocs/default/layout/html/setup.rb +87 -0
- data/lib/yard/to_mkdocs/default/method/html/header.erb +5 -0
- data/lib/yard/to_mkdocs/default/method/setup.rb +4 -0
- data/lib/yard/to_mkdocs/default/method/text/header.erb +1 -0
- data/lib/yard/to_mkdocs/default/method_details/html/header.erb +1 -0
- data/lib/yard/to_mkdocs/default/method_details/html/method_signature.erb +9 -0
- data/lib/yard/to_mkdocs/default/method_details/html/source.erb +5 -0
- data/lib/yard/to_mkdocs/default/method_details/setup.rb +11 -0
- data/lib/yard/to_mkdocs/default/method_details/text/header.erb +10 -0
- data/lib/yard/to_mkdocs/default/method_details/text/method_signature.erb +12 -0
- data/lib/yard/to_mkdocs/default/method_details/text/setup.rb +11 -0
- data/lib/yard/to_mkdocs/default/module/dot/child.erb +1 -0
- data/lib/yard/to_mkdocs/default/module/dot/dependencies.erb +3 -0
- data/lib/yard/to_mkdocs/default/module/dot/header.erb +6 -0
- data/lib/yard/to_mkdocs/default/module/dot/info.erb +14 -0
- data/lib/yard/to_mkdocs/default/module/dot/setup.rb +15 -0
- data/lib/yard/to_mkdocs/default/module/html/attribute_details.erb +7 -0
- data/lib/yard/to_mkdocs/default/module/html/attribute_summary.erb +7 -0
- data/lib/yard/to_mkdocs/default/module/html/box_info.erb +14 -0
- data/lib/yard/to_mkdocs/default/module/html/children.erb +7 -0
- data/lib/yard/to_mkdocs/default/module/html/constant_summary.erb +13 -0
- data/lib/yard/to_mkdocs/default/module/html/defines.erb +1 -0
- data/lib/yard/to_mkdocs/default/module/html/header.erb +1 -0
- data/lib/yard/to_mkdocs/default/module/html/inherited_attributes.erb +16 -0
- data/lib/yard/to_mkdocs/default/module/html/inherited_constants.erb +11 -0
- data/lib/yard/to_mkdocs/default/module/html/inherited_methods.erb +22 -0
- data/lib/yard/to_mkdocs/default/module/html/item_summary.erb +16 -0
- data/lib/yard/to_mkdocs/default/module/html/method_details_list.erb +7 -0
- data/lib/yard/to_mkdocs/default/module/html/method_summary.erb +9 -0
- data/lib/yard/to_mkdocs/default/module/html/methodmissing.erb +10 -0
- data/lib/yard/to_mkdocs/default/module/html/pre_docstring.erb +1 -0
- data/lib/yard/to_mkdocs/default/module/setup.rb +168 -0
- data/lib/yard/to_mkdocs/default/module/text/children.erb +10 -0
- data/lib/yard/to_mkdocs/default/module/text/class_meths_list.erb +8 -0
- data/lib/yard/to_mkdocs/default/module/text/extends.erb +8 -0
- data/lib/yard/to_mkdocs/default/module/text/header.erb +7 -0
- data/lib/yard/to_mkdocs/default/module/text/includes.erb +8 -0
- data/lib/yard/to_mkdocs/default/module/text/instance_meths_list.erb +8 -0
- data/lib/yard/to_mkdocs/default/module/text/setup.rb +13 -0
- data/lib/yard/to_mkdocs/default/onefile/html/files.erb +6 -0
- data/lib/yard/to_mkdocs/default/onefile/html/headers.erb +0 -0
- data/lib/yard/to_mkdocs/default/onefile/html/layout.erb +3 -0
- data/lib/yard/to_mkdocs/default/onefile/html/readme.erb +1 -0
- data/lib/yard/to_mkdocs/default/onefile/html/setup.rb +62 -0
- data/lib/yard/to_mkdocs/default/root/dot/child.erb +3 -0
- data/lib/yard/to_mkdocs/default/root/dot/setup.rb +6 -0
- data/lib/yard/to_mkdocs/default/root/html/setup.rb +2 -0
- data/lib/yard/to_mkdocs/default/tags/html/example.erb +13 -0
- data/lib/yard/to_mkdocs/default/tags/html/index.erb +2 -0
- data/lib/yard/to_mkdocs/default/tags/html/option.erb +13 -0
- data/lib/yard/to_mkdocs/default/tags/html/overload.erb +11 -0
- data/lib/yard/to_mkdocs/default/tags/html/see.erb +7 -0
- data/lib/yard/to_mkdocs/default/tags/html/tag.erb +6 -0
- data/lib/yard/to_mkdocs/default/tags/setup.rb +57 -0
- data/lib/yard/to_mkdocs/default/tags/text/example.erb +12 -0
- data/lib/yard/to_mkdocs/default/tags/text/index.erb +1 -0
- data/lib/yard/to_mkdocs/default/tags/text/option.erb +20 -0
- data/lib/yard/to_mkdocs/default/tags/text/overload.erb +19 -0
- data/lib/yard/to_mkdocs/default/tags/text/see.erb +11 -0
- data/lib/yard/to_mkdocs/default/tags/text/tag.erb +13 -0
- data/lib/yard/to_mkdocs/version.rb +7 -0
- data/lib/yard-to_mkdocs.rb +19 -0
- data/yard-to_mkdocs.gemspec +36 -0
- metadata +177 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
include Helpers::ModuleHelper
|
3
|
+
|
4
|
+
def init
|
5
|
+
options.serializer.extension = 'md'
|
6
|
+
sections :header, :box_info, :pre_docstring, T('docstring'), :children,
|
7
|
+
:constant_summary, [T('docstring')], :inherited_constants,
|
8
|
+
:attribute_summary, [:item_summary], :inherited_attributes,
|
9
|
+
:method_summary, [:item_summary], :inherited_methods,
|
10
|
+
:methodmissing, [T('method_details')],
|
11
|
+
:attribute_details, [T('method_details')],
|
12
|
+
:method_details_list, [T('method_details')]
|
13
|
+
end
|
14
|
+
|
15
|
+
def pre_docstring
|
16
|
+
return if object.docstring.blank?
|
17
|
+
erb(:pre_docstring)
|
18
|
+
end
|
19
|
+
|
20
|
+
def children
|
21
|
+
@inner = [[:modules, []], [:classes, []]]
|
22
|
+
object.children.each do |child|
|
23
|
+
@inner[0][1] << child if child.type == :module
|
24
|
+
@inner[1][1] << child if child.type == :class
|
25
|
+
end
|
26
|
+
@inner.map! {|v| [v[0], run_verifier(v[1].sort_by {|o| o.name.to_s })] }
|
27
|
+
return if (@inner[0][1].size + @inner[1][1].size) == 0
|
28
|
+
erb(:children)
|
29
|
+
end
|
30
|
+
|
31
|
+
def methodmissing
|
32
|
+
mms = object.meths(:inherited => true, :included => true)
|
33
|
+
@mm = mms.find {|o| o.name == :method_missing && o.scope == :instance }
|
34
|
+
erb(:methodmissing) if @mm
|
35
|
+
end
|
36
|
+
|
37
|
+
def method_listing(include_specials = true)
|
38
|
+
return @smeths ||= method_listing.reject {|o| special_method?(o) } unless include_specials
|
39
|
+
return @meths if defined?(@meths) && @meths
|
40
|
+
@meths = object.meths(:inherited => false, :included => !options.embed_mixins.empty?)
|
41
|
+
unless options.embed_mixins.empty?
|
42
|
+
@meths = @meths.reject {|m| options.embed_mixins_match?(m.namespace) == false }
|
43
|
+
end
|
44
|
+
@meths = sort_listing(prune_method_listing(@meths))
|
45
|
+
@meths
|
46
|
+
end
|
47
|
+
|
48
|
+
def special_method?(meth)
|
49
|
+
return true if meth.name(true) == '#method_missing'
|
50
|
+
return true if meth.constructor?
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
def attr_listing
|
55
|
+
return @attrs if defined?(@attrs) && @attrs
|
56
|
+
@attrs = []
|
57
|
+
object.inheritance_tree(true).each do |superclass|
|
58
|
+
next if superclass.is_a?(CodeObjects::Proxy)
|
59
|
+
next if !options.embed_mixins.empty? &&
|
60
|
+
!options.embed_mixins_match?(superclass)
|
61
|
+
[:class, :instance].each do |scope|
|
62
|
+
superclass.attributes[scope].each do |_name, rw|
|
63
|
+
attr = prune_method_listing([rw[:read], rw[:write]].compact, false).first
|
64
|
+
@attrs << attr if attr
|
65
|
+
end
|
66
|
+
end
|
67
|
+
break if options.embed_mixins.empty?
|
68
|
+
end
|
69
|
+
@attrs = sort_listing(@attrs)
|
70
|
+
end
|
71
|
+
|
72
|
+
def constant_listing
|
73
|
+
return @constants if defined?(@constants) && @constants
|
74
|
+
@constants = object.constants(:included => false, :inherited => false)
|
75
|
+
@constants += object.cvars
|
76
|
+
@constants = run_verifier(@constants)
|
77
|
+
@constants
|
78
|
+
end
|
79
|
+
|
80
|
+
def sort_listing(list)
|
81
|
+
list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] }
|
82
|
+
end
|
83
|
+
|
84
|
+
def inherited_attr_list
|
85
|
+
object.inheritance_tree(true)[1..-1].each do |superclass|
|
86
|
+
next if superclass.is_a?(YARD::CodeObjects::Proxy)
|
87
|
+
next if !options.embed_mixins.empty? && options.embed_mixins_match?(superclass) != false
|
88
|
+
attribs = superclass.attributes[:instance]
|
89
|
+
attribs = attribs.select {|name, _rw| object.child(:scope => :instance, :name => name).nil? }
|
90
|
+
attribs = attribs.sort_by {|args| args.first.to_s }.map {|_n, m| m[:read] || m[:write] }
|
91
|
+
attribs = prune_method_listing(attribs, false)
|
92
|
+
yield superclass, attribs unless attribs.empty?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def inherited_constant_list
|
97
|
+
object.inheritance_tree(true)[1..-1].each do |superclass|
|
98
|
+
next if superclass.is_a?(YARD::CodeObjects::Proxy)
|
99
|
+
next if !options.embed_mixins.empty? && options.embed_mixins_match?(superclass) != false
|
100
|
+
consts = superclass.constants(:included => false, :inherited => false)
|
101
|
+
consts = consts.select {|const| object.child(:type => :constant, :name => const.name).nil? }
|
102
|
+
consts = consts.sort_by {|const| const.name.to_s }
|
103
|
+
consts = run_verifier(consts)
|
104
|
+
yield superclass, consts unless consts.empty?
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def docstring_full(obj)
|
109
|
+
docstring = obj.tags(:overload).size == 1 && obj.docstring.empty? ?
|
110
|
+
obj.tag(:overload).docstring : obj.docstring
|
111
|
+
|
112
|
+
if docstring.summary.empty? && obj.tags(:return).size == 1 && obj.tag(:return).text
|
113
|
+
docstring = Docstring.new(obj.tag(:return).text.gsub(/\A([a-z])/, &:upcase).strip)
|
114
|
+
end
|
115
|
+
|
116
|
+
docstring
|
117
|
+
end
|
118
|
+
|
119
|
+
def docstring_summary(obj)
|
120
|
+
docstring_full(obj).summary
|
121
|
+
end
|
122
|
+
|
123
|
+
def groups(list, type = "Method")
|
124
|
+
groups_data = object.groups
|
125
|
+
if groups_data
|
126
|
+
list.each {|m| groups_data |= [m.group] if m.group && owner != m.namespace }
|
127
|
+
others = list.select {|m| !m.group || !groups_data.include?(m.group) }
|
128
|
+
groups_data.each do |name|
|
129
|
+
items = list.select {|m| m.group == name }
|
130
|
+
yield(items, name) unless items.empty?
|
131
|
+
end
|
132
|
+
else
|
133
|
+
others = []
|
134
|
+
group_data = {}
|
135
|
+
list.each do |itm|
|
136
|
+
if itm.group
|
137
|
+
(group_data[itm.group] ||= []) << itm
|
138
|
+
else
|
139
|
+
others << itm
|
140
|
+
end
|
141
|
+
end
|
142
|
+
group_data.each {|group, items| yield(items, group) unless items.empty? }
|
143
|
+
end
|
144
|
+
|
145
|
+
return if others.empty?
|
146
|
+
if others.first.respond_to?(:scope)
|
147
|
+
scopes(others) {|items, scope| yield(items, "#{scope.to_s.capitalize} #{type} Summary") }
|
148
|
+
else
|
149
|
+
yield(others, "#{type} Summary")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def scopes(list)
|
154
|
+
[:class, :instance].each do |scope|
|
155
|
+
items = list.select {|m| m.scope == scope }
|
156
|
+
yield(items, scope) unless items.empty?
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def mixed_into(object)
|
161
|
+
unless globals.mixed_into
|
162
|
+
globals.mixed_into = {}
|
163
|
+
list = run_verifier Registry.all(:class, :module)
|
164
|
+
list.each {|o| o.mixins.each {|m| (globals.mixed_into[m.path] ||= []) << o } }
|
165
|
+
end
|
166
|
+
|
167
|
+
globals.mixed_into[object.path] || []
|
168
|
+
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
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= parse_top_comments_from_file %>
|
@@ -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.md'
|
54
|
+
super(object, data)
|
55
|
+
end
|
56
|
+
|
57
|
+
define_method(:serialized_path) do |object|
|
58
|
+
return object if object.is_a?(String)
|
59
|
+
'index.md'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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
|
+
|
6
|
+
Options Hash (`<%= param %>`):
|
7
|
+
|
8
|
+
<% tags.each do |tag| %>
|
9
|
+
* <%= tag.pair.name %> <%= format_types(tag.pair.types || ['Object']) %> <% if tag.pair.defaults %> - default: <%= tag.pair.defaults.map { |t| "`#{h t}`" }.join(", ") %><% end %> <% if tag.pair.text && tag.pair.text =~ /\S/ %> - <%= tag.pair.text %><% end %>
|
10
|
+
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
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
|
+
|
5
|
+
Overloads:
|
6
|
+
|
7
|
+
<% object.tags(:overload).each do |overload| %>
|
8
|
+
<% next if overload.docstring.blank? %>
|
9
|
+
* <%= signature(overload, false, false) %> <%= yieldall :object => overload %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= (defined?(@label) && @label) ? @label : YARD::Tags::Library.labels[@name] %>:
|
2
|
+
|
3
|
+
<% object.tags(@name).each do |tag| %>
|
4
|
+
* <% unless @no_names %><%= h tag.name %><% end %> <% unless @no_types %><%= format_types(tag.types) %><% end %> <% if @name == :param && (o=object.parameters.find {|a| [tag.name.to_s, tag.name.to_s + ":"].include?(a[0]) }) && o[1] %>_(defaults to: `<%= h o[1] %>`)_<% end %> <% if tag.text && !tag.text.empty? %><% unless (@no_types || tag.types.nil? || tag.types.empty?) && @no_names %>—<% end %><%= tag.text %><% end %>
|
5
|
+
|
6
|
+
<% end %>
|
@@ -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 %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yard'
|
4
|
+
require 'yard/to_mkdocs/version'
|
5
|
+
|
6
|
+
module YARD
|
7
|
+
module Serializers
|
8
|
+
class FileSystemSerializer < Base
|
9
|
+
def initialize(opts = {})
|
10
|
+
super
|
11
|
+
@name_map = nil
|
12
|
+
@basepath = (options[:basepath] || 'doc').to_s
|
13
|
+
@extension = 'md'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
YARD::Templates::Engine.register_template_path File.expand_path('./yard/to_mkdocs', __dir__)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/yard/to_mkdocs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "yard-to_mkdocs"
|
7
|
+
spec.version = YARD::ToMkdocs::VERSION
|
8
|
+
spec.authors = ["Octothope"]
|
9
|
+
spec.email = ["octothorpe@invoca.com"]
|
10
|
+
|
11
|
+
spec.summary = "Simple template that removes extra frames from yardocs html template"
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/invoca/yard-to_mkdocs"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency "yard"
|
33
|
+
|
34
|
+
# For more information and examples about making a new gem, checkout our
|
35
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
36
|
+
end
|