gitlab-rdoc 6.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +133 -0
- data/RI.rdoc +57 -0
- data/Rakefile +101 -0
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/exe/rdoc +44 -0
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +112 -0
- data/lib/rdoc/anon_class.rb +11 -0
- data/lib/rdoc/any_method.rb +361 -0
- data/lib/rdoc/attr.rb +176 -0
- data/lib/rdoc/class_module.rb +802 -0
- data/lib/rdoc/code_object.rb +421 -0
- data/lib/rdoc/code_objects.rb +6 -0
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +187 -0
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +1266 -0
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +136 -0
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +42 -0
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +790 -0
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +160 -0
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +98 -0
- data/lib/rdoc/generator/ri.rb +31 -0
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
- data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +51 -0
- data/lib/rdoc/ghost_method.rb +7 -0
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +10 -0
- data/lib/rdoc/known_classes.rb +73 -0
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +417 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16685 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +409 -0
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +28 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +165 -0
- data/lib/rdoc/markup/formatter.rb +266 -0
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +79 -0
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +102 -0
- data/lib/rdoc/markup/list_item.rb +100 -0
- data/lib/rdoc/markup/paragraph.rb +29 -0
- data/lib/rdoc/markup/parser.rb +575 -0
- data/lib/rdoc/markup/pre_process.rb +296 -0
- data/lib/rdoc/markup/raw.rb +70 -0
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +21 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +94 -0
- data/lib/rdoc/markup/to_bs.rb +77 -0
- data/lib/rdoc/markup/to_html.rb +444 -0
- data/lib/rdoc/markup/to_html_crossref.rb +176 -0
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +362 -0
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +70 -0
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +84 -0
- data/lib/rdoc/markup.rb +867 -0
- data/lib/rdoc/meta_method.rb +7 -0
- data/lib/rdoc/method_attr.rb +419 -0
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +93 -0
- data/lib/rdoc/normal_module.rb +74 -0
- data/lib/rdoc/options.rb +1285 -0
- data/lib/rdoc/parser/c.rb +1225 -0
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +2327 -0
- data/lib/rdoc/parser/ruby_tools.rb +167 -0
- data/lib/rdoc/parser/simple.rb +61 -0
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +277 -0
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +579 -0
- data/lib/rdoc/require.rb +52 -0
- data/lib/rdoc/ri/driver.rb +1572 -0
- data/lib/rdoc/ri/formatter.rb +6 -0
- data/lib/rdoc/ri/paths.rb +171 -0
- data/lib/rdoc/ri/store.rb +7 -0
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +21 -0
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +26 -0
- data/lib/rdoc/stats/normal.rb +58 -0
- data/lib/rdoc/stats/quiet.rb +60 -0
- data/lib/rdoc/stats/verbose.rb +46 -0
- data/lib/rdoc/stats.rb +462 -0
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +329 -0
- data/lib/rdoc/text.rb +304 -0
- data/lib/rdoc/token_stream.rb +119 -0
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +289 -0
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +201 -0
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +279 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# Abstract class representing either a method or an attribute.
|
|
4
|
+
|
|
5
|
+
class RDoc::MethodAttr < RDoc::CodeObject
|
|
6
|
+
|
|
7
|
+
include Comparable
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# Name of this method/attribute.
|
|
11
|
+
|
|
12
|
+
attr_accessor :name
|
|
13
|
+
|
|
14
|
+
##
|
|
15
|
+
# public, protected, private
|
|
16
|
+
|
|
17
|
+
attr_accessor :visibility
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# Is this a singleton method/attribute?
|
|
21
|
+
|
|
22
|
+
attr_accessor :singleton
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Source file token stream
|
|
26
|
+
|
|
27
|
+
attr_reader :text
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# Array of other names for this method/attribute
|
|
31
|
+
|
|
32
|
+
attr_reader :aliases
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# The method/attribute we're aliasing
|
|
36
|
+
|
|
37
|
+
attr_accessor :is_alias_for
|
|
38
|
+
|
|
39
|
+
#--
|
|
40
|
+
# The attributes below are for AnyMethod only.
|
|
41
|
+
# They are left here for the time being to
|
|
42
|
+
# allow ri to operate.
|
|
43
|
+
# TODO modify ri to avoid calling these on attributes.
|
|
44
|
+
#++
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# Parameters yielded by the called block
|
|
48
|
+
|
|
49
|
+
attr_reader :block_params
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# Parameters for this method
|
|
53
|
+
|
|
54
|
+
attr_accessor :params
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# Different ways to call this method
|
|
58
|
+
|
|
59
|
+
attr_accessor :call_seq
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# The call_seq or the param_seq with method name, if there is no call_seq.
|
|
63
|
+
|
|
64
|
+
attr_reader :arglists
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# Pretty parameter list for this method
|
|
68
|
+
|
|
69
|
+
attr_reader :param_seq
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
##
|
|
73
|
+
# Creates a new MethodAttr from token stream +text+ and method or attribute
|
|
74
|
+
# name +name+.
|
|
75
|
+
#
|
|
76
|
+
# Usually this is called by super from a subclass.
|
|
77
|
+
|
|
78
|
+
def initialize text, name
|
|
79
|
+
super()
|
|
80
|
+
|
|
81
|
+
@text = text
|
|
82
|
+
@name = name
|
|
83
|
+
|
|
84
|
+
@aliases = []
|
|
85
|
+
@is_alias_for = nil
|
|
86
|
+
@parent_name = nil
|
|
87
|
+
@singleton = nil
|
|
88
|
+
@visibility = :public
|
|
89
|
+
@see = false
|
|
90
|
+
|
|
91
|
+
@arglists = nil
|
|
92
|
+
@block_params = nil
|
|
93
|
+
@call_seq = nil
|
|
94
|
+
@param_seq = nil
|
|
95
|
+
@params = nil
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# Resets cached data for the object so it can be rebuilt by accessor methods
|
|
100
|
+
|
|
101
|
+
def initialize_copy other # :nodoc:
|
|
102
|
+
@full_name = nil
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def initialize_visibility # :nodoc:
|
|
106
|
+
super
|
|
107
|
+
@see = nil
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# Order by #singleton then #name
|
|
112
|
+
|
|
113
|
+
def <=>(other)
|
|
114
|
+
return unless other.respond_to?(:singleton) &&
|
|
115
|
+
other.respond_to?(:name)
|
|
116
|
+
|
|
117
|
+
[ @singleton ? 0 : 1, name] <=>
|
|
118
|
+
[other.singleton ? 0 : 1, other.name]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def == other # :nodoc:
|
|
122
|
+
equal?(other) or self.class == other.class and full_name == other.full_name
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
##
|
|
126
|
+
# A method/attribute is documented if any of the following is true:
|
|
127
|
+
# - it was marked with :nodoc:;
|
|
128
|
+
# - it has a comment;
|
|
129
|
+
# - it is an alias for a documented method;
|
|
130
|
+
# - it has a +#see+ method that is documented.
|
|
131
|
+
|
|
132
|
+
def documented?
|
|
133
|
+
super or
|
|
134
|
+
(is_alias_for and is_alias_for.documented?) or
|
|
135
|
+
(see and see.documented?)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
##
|
|
139
|
+
# A method/attribute to look at,
|
|
140
|
+
# in particular if this method/attribute has no documentation.
|
|
141
|
+
#
|
|
142
|
+
# It can be a method/attribute of the superclass or of an included module,
|
|
143
|
+
# including the Kernel module, which is always appended to the included
|
|
144
|
+
# modules.
|
|
145
|
+
#
|
|
146
|
+
# Returns +nil+ if there is no such method/attribute.
|
|
147
|
+
# The +#is_alias_for+ method/attribute, if any, is not included.
|
|
148
|
+
#
|
|
149
|
+
# Templates may generate a "see also ..." if this method/attribute
|
|
150
|
+
# has documentation, and "see ..." if it does not.
|
|
151
|
+
|
|
152
|
+
def see
|
|
153
|
+
@see = find_see if @see == false
|
|
154
|
+
@see
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
##
|
|
158
|
+
# Sets the store for this class or module and its contained code objects.
|
|
159
|
+
|
|
160
|
+
def store= store
|
|
161
|
+
super
|
|
162
|
+
|
|
163
|
+
@file = @store.add_file @file.full_name if @file
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def find_see # :nodoc:
|
|
167
|
+
return nil if singleton || is_alias_for
|
|
168
|
+
|
|
169
|
+
# look for the method
|
|
170
|
+
other = find_method_or_attribute name
|
|
171
|
+
return other if other
|
|
172
|
+
|
|
173
|
+
# if it is a setter, look for a getter
|
|
174
|
+
return nil unless name =~ /[a-z_]=$/i # avoid == or ===
|
|
175
|
+
return find_method_or_attribute name[0..-2]
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def find_method_or_attribute name # :nodoc:
|
|
179
|
+
return nil unless parent.respond_to? :ancestors
|
|
180
|
+
|
|
181
|
+
searched = parent.ancestors
|
|
182
|
+
kernel = @store.modules_hash['Kernel']
|
|
183
|
+
|
|
184
|
+
searched << kernel if kernel &&
|
|
185
|
+
parent != kernel && !searched.include?(kernel)
|
|
186
|
+
|
|
187
|
+
searched.each do |ancestor|
|
|
188
|
+
next if String === ancestor
|
|
189
|
+
next if parent == ancestor
|
|
190
|
+
|
|
191
|
+
other = ancestor.find_method_named('#' + name) ||
|
|
192
|
+
ancestor.find_attribute_named(name)
|
|
193
|
+
|
|
194
|
+
return other if other
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
nil
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
##
|
|
201
|
+
# Abstract method. Contexts in their building phase call this
|
|
202
|
+
# to register a new alias for this known method/attribute.
|
|
203
|
+
#
|
|
204
|
+
# - creates a new AnyMethod/Attribute named <tt>an_alias.new_name</tt>;
|
|
205
|
+
# - adds +self+ as an alias for the new method or attribute
|
|
206
|
+
# - adds the method or attribute to #aliases
|
|
207
|
+
# - adds the method or attribute to +context+.
|
|
208
|
+
|
|
209
|
+
def add_alias(an_alias, context)
|
|
210
|
+
raise NotImplementedError
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
##
|
|
214
|
+
# HTML fragment reference for this method
|
|
215
|
+
|
|
216
|
+
def aref
|
|
217
|
+
type = singleton ? 'c' : 'i'
|
|
218
|
+
# % characters are not allowed in html names => dash instead
|
|
219
|
+
"#{aref_prefix}-#{type}-#{html_name}"
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
##
|
|
223
|
+
# Prefix for +aref+, defined by subclasses.
|
|
224
|
+
|
|
225
|
+
def aref_prefix
|
|
226
|
+
raise NotImplementedError
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
##
|
|
230
|
+
# Attempts to sanitize the content passed by the Ruby parser:
|
|
231
|
+
# remove outer parentheses, etc.
|
|
232
|
+
|
|
233
|
+
def block_params=(value)
|
|
234
|
+
# 'yield.to_s' or 'assert yield, msg'
|
|
235
|
+
return @block_params = '' if value =~ /^[\.,]/
|
|
236
|
+
|
|
237
|
+
# remove trailing 'if/unless ...'
|
|
238
|
+
return @block_params = '' if value =~ /^(if|unless)\s/
|
|
239
|
+
|
|
240
|
+
value = $1.strip if value =~ /^(.+)\s(if|unless)\s/
|
|
241
|
+
|
|
242
|
+
# outer parentheses
|
|
243
|
+
value = $1 if value =~ /^\s*\((.*)\)\s*$/
|
|
244
|
+
value = value.strip
|
|
245
|
+
|
|
246
|
+
# proc/lambda
|
|
247
|
+
return @block_params = $1 if value =~ /^(proc|lambda)(\s*\{|\sdo)/
|
|
248
|
+
|
|
249
|
+
# surrounding +...+ or [...]
|
|
250
|
+
value = $1.strip if value =~ /^\+(.*)\+$/
|
|
251
|
+
value = $1.strip if value =~ /^\[(.*)\]$/
|
|
252
|
+
|
|
253
|
+
return @block_params = '' if value.empty?
|
|
254
|
+
|
|
255
|
+
# global variable
|
|
256
|
+
return @block_params = 'str' if value =~ /^\$[&0-9]$/
|
|
257
|
+
|
|
258
|
+
# wipe out array/hash indices
|
|
259
|
+
value.gsub!(/(\w)\[[^\[]+\]/, '\1')
|
|
260
|
+
|
|
261
|
+
# remove @ from class/instance variables
|
|
262
|
+
value.gsub!(/@@?([a-z0-9_]+)/, '\1')
|
|
263
|
+
|
|
264
|
+
# method calls => method name
|
|
265
|
+
value.gsub!(/([A-Z:a-z0-9_]+)\.([a-z0-9_]+)(\s*\(\s*[a-z0-9_.,\s]*\s*\)\s*)?/) do
|
|
266
|
+
case $2
|
|
267
|
+
when 'to_s' then $1
|
|
268
|
+
when 'const_get' then 'const'
|
|
269
|
+
when 'new' then
|
|
270
|
+
$1.split('::').last. # ClassName => class_name
|
|
271
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
272
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
273
|
+
downcase
|
|
274
|
+
else
|
|
275
|
+
$2
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# class prefixes
|
|
280
|
+
value.gsub!(/[A-Za-z0-9_:]+::/, '')
|
|
281
|
+
|
|
282
|
+
# simple expressions
|
|
283
|
+
value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/
|
|
284
|
+
|
|
285
|
+
@block_params = value.strip
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
##
|
|
289
|
+
# HTML id-friendly method/attribute name
|
|
290
|
+
|
|
291
|
+
def html_name
|
|
292
|
+
require 'cgi'
|
|
293
|
+
|
|
294
|
+
CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
##
|
|
298
|
+
# Full method/attribute name including namespace
|
|
299
|
+
|
|
300
|
+
def full_name
|
|
301
|
+
@full_name ||= "#{parent_name}#{pretty_name}"
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def inspect # :nodoc:
|
|
305
|
+
alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
|
|
306
|
+
visibility = self.visibility
|
|
307
|
+
visibility = "forced #{visibility}" if force_documentation
|
|
308
|
+
"#<%s:0x%x %s (%s)%s>" % [
|
|
309
|
+
self.class, object_id,
|
|
310
|
+
full_name,
|
|
311
|
+
visibility,
|
|
312
|
+
alias_for,
|
|
313
|
+
]
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
##
|
|
317
|
+
# '::' for a class method/attribute, '#' for an instance method.
|
|
318
|
+
|
|
319
|
+
def name_prefix
|
|
320
|
+
@singleton ? '::' : '#'
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
##
|
|
324
|
+
# Name for output to HTML. For class methods the full name with a "." is
|
|
325
|
+
# used like +SomeClass.method_name+. For instance methods the class name is
|
|
326
|
+
# used if +context+ does not match the parent.
|
|
327
|
+
#
|
|
328
|
+
# This is to help prevent people from using :: to call class methods.
|
|
329
|
+
|
|
330
|
+
def output_name context
|
|
331
|
+
return "#{name_prefix}#{@name}" if context == parent
|
|
332
|
+
|
|
333
|
+
"#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
##
|
|
337
|
+
# Method/attribute name with class/instance indicator
|
|
338
|
+
|
|
339
|
+
def pretty_name
|
|
340
|
+
"#{name_prefix}#{@name}"
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
##
|
|
344
|
+
# Type of method/attribute (class or instance)
|
|
345
|
+
|
|
346
|
+
def type
|
|
347
|
+
singleton ? 'class' : 'instance'
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
##
|
|
351
|
+
# Path to this method for use with HTML generator output.
|
|
352
|
+
|
|
353
|
+
def path
|
|
354
|
+
"#{@parent.path}##{aref}"
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
##
|
|
358
|
+
# Name of our parent with special handling for un-marshaled methods
|
|
359
|
+
|
|
360
|
+
def parent_name
|
|
361
|
+
@parent_name || super
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def pretty_print q # :nodoc:
|
|
365
|
+
alias_for =
|
|
366
|
+
if @is_alias_for.respond_to? :name then
|
|
367
|
+
"alias for #{@is_alias_for.name}"
|
|
368
|
+
elsif Array === @is_alias_for then
|
|
369
|
+
"alias for #{@is_alias_for.last}"
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
|
|
373
|
+
if alias_for then
|
|
374
|
+
q.breakable
|
|
375
|
+
q.text alias_for
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
if text then
|
|
379
|
+
q.breakable
|
|
380
|
+
q.text "text:"
|
|
381
|
+
q.breakable
|
|
382
|
+
q.pp @text
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
unless comment.empty? then
|
|
386
|
+
q.breakable
|
|
387
|
+
q.text "comment:"
|
|
388
|
+
q.breakable
|
|
389
|
+
q.pp @comment
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
##
|
|
395
|
+
# Used by RDoc::Generator::JsonIndex to create a record for the search
|
|
396
|
+
# engine.
|
|
397
|
+
|
|
398
|
+
def search_record
|
|
399
|
+
[
|
|
400
|
+
@name,
|
|
401
|
+
full_name,
|
|
402
|
+
@name,
|
|
403
|
+
@parent.full_name,
|
|
404
|
+
path,
|
|
405
|
+
params,
|
|
406
|
+
snippet(@comment),
|
|
407
|
+
]
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def to_s # :nodoc:
|
|
411
|
+
if @is_alias_for
|
|
412
|
+
"#{self.class.name}: #{full_name} -> #{is_alias_for}"
|
|
413
|
+
else
|
|
414
|
+
"#{self.class.name}: #{full_name}"
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
end
|
|
419
|
+
|
data/lib/rdoc/mixin.rb
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# A Mixin adds features from a module into another context. RDoc::Include and
|
|
4
|
+
# RDoc::Extend are both mixins.
|
|
5
|
+
|
|
6
|
+
class RDoc::Mixin < RDoc::CodeObject
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# Name of included module
|
|
10
|
+
|
|
11
|
+
attr_accessor :name
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# Creates a new Mixin for +name+ with +comment+
|
|
15
|
+
|
|
16
|
+
def initialize(name, comment)
|
|
17
|
+
super()
|
|
18
|
+
@name = name
|
|
19
|
+
self.comment = comment
|
|
20
|
+
@module = nil # cache for module if found
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# Mixins are sorted by name
|
|
25
|
+
|
|
26
|
+
def <=> other
|
|
27
|
+
return unless self.class === other
|
|
28
|
+
|
|
29
|
+
name <=> other.name
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def == other # :nodoc:
|
|
33
|
+
self.class === other and @name == other.name
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
alias eql? == # :nodoc:
|
|
37
|
+
|
|
38
|
+
##
|
|
39
|
+
# Full name based on #module
|
|
40
|
+
|
|
41
|
+
def full_name
|
|
42
|
+
m = self.module
|
|
43
|
+
RDoc::ClassModule === m ? m.full_name : @name
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def hash # :nodoc:
|
|
47
|
+
[@name, self.module].hash
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def inspect # :nodoc:
|
|
51
|
+
"#<%s:0x%x %s.%s %s>" % [
|
|
52
|
+
self.class,
|
|
53
|
+
object_id,
|
|
54
|
+
parent_name, self.class.name.downcase, @name,
|
|
55
|
+
]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# Attempts to locate the included module object. Returns the name if not
|
|
60
|
+
# known.
|
|
61
|
+
#
|
|
62
|
+
# The scoping rules of Ruby to resolve the name of an included module are:
|
|
63
|
+
# - first look into the children of the current context;
|
|
64
|
+
# - if not found, look into the children of included modules,
|
|
65
|
+
# in reverse inclusion order;
|
|
66
|
+
# - if still not found, go up the hierarchy of names.
|
|
67
|
+
#
|
|
68
|
+
# This method has <code>O(n!)</code> behavior when the module calling
|
|
69
|
+
# include is referencing nonexistent modules. Avoid calling #module until
|
|
70
|
+
# after all the files are parsed. This behavior is due to ruby's constant
|
|
71
|
+
# lookup behavior.
|
|
72
|
+
#
|
|
73
|
+
# As of the beginning of October, 2011, no gem includes nonexistent modules.
|
|
74
|
+
|
|
75
|
+
def module
|
|
76
|
+
return @module if @module
|
|
77
|
+
|
|
78
|
+
# search the current context
|
|
79
|
+
return @name unless parent
|
|
80
|
+
full_name = parent.child_name(@name)
|
|
81
|
+
@module = @store.modules_hash[full_name]
|
|
82
|
+
return @module if @module
|
|
83
|
+
return @name if @name =~ /^::/
|
|
84
|
+
|
|
85
|
+
# search the includes before this one, in reverse order
|
|
86
|
+
searched = parent.includes.take_while { |i| i != self }.reverse
|
|
87
|
+
searched.each do |i|
|
|
88
|
+
inc = i.module
|
|
89
|
+
next if String === inc
|
|
90
|
+
full_name = inc.child_name(@name)
|
|
91
|
+
@module = @store.modules_hash[full_name]
|
|
92
|
+
return @module if @module
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# go up the hierarchy of names
|
|
96
|
+
up = parent.parent
|
|
97
|
+
while up
|
|
98
|
+
full_name = up.child_name(@name)
|
|
99
|
+
@module = @store.modules_hash[full_name]
|
|
100
|
+
return @module if @module
|
|
101
|
+
up = up.parent
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
@name
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# Sets the store for this class or module and its contained code objects.
|
|
109
|
+
|
|
110
|
+
def store= store
|
|
111
|
+
super
|
|
112
|
+
|
|
113
|
+
@file = @store.add_file @file.full_name if @file
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def to_s # :nodoc:
|
|
117
|
+
"#{self.class.name.downcase} #@name in: #{parent}"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|