gitlab-rdoc 6.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +220 -0
  3. data/CVE-2013-0256.rdoc +49 -0
  4. data/ExampleMarkdown.md +37 -0
  5. data/ExampleRDoc.rdoc +208 -0
  6. data/Gemfile +12 -0
  7. data/History.rdoc +1666 -0
  8. data/LEGAL.rdoc +50 -0
  9. data/LICENSE.rdoc +57 -0
  10. data/README.rdoc +133 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +101 -0
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/exe/rdoc +44 -0
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +112 -0
  19. data/lib/rdoc/anon_class.rb +11 -0
  20. data/lib/rdoc/any_method.rb +361 -0
  21. data/lib/rdoc/attr.rb +176 -0
  22. data/lib/rdoc/class_module.rb +802 -0
  23. data/lib/rdoc/code_object.rb +421 -0
  24. data/lib/rdoc/code_objects.rb +6 -0
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +187 -0
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +1266 -0
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +136 -0
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +42 -0
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +790 -0
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +160 -0
  37. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  38. data/lib/rdoc/generator/pot/po.rb +84 -0
  39. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  40. data/lib/rdoc/generator/pot.rb +98 -0
  41. data/lib/rdoc/generator/ri.rb +31 -0
  42. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  44. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  57. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  58. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  59. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  60. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  72. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  73. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  74. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  75. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  76. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  77. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  78. data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  79. data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  80. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  81. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  82. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  83. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  84. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  85. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  86. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  87. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  88. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  89. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  90. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  91. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  92. data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
  93. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
  94. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  95. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  96. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  97. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  98. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  99. data/lib/rdoc/generator/template/json_index/.document +1 -0
  100. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  101. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  102. data/lib/rdoc/generator.rb +51 -0
  103. data/lib/rdoc/ghost_method.rb +7 -0
  104. data/lib/rdoc/i18n/locale.rb +102 -0
  105. data/lib/rdoc/i18n/text.rb +126 -0
  106. data/lib/rdoc/i18n.rb +10 -0
  107. data/lib/rdoc/include.rb +10 -0
  108. data/lib/rdoc/known_classes.rb +73 -0
  109. data/lib/rdoc/markdown/entities.rb +2132 -0
  110. data/lib/rdoc/markdown/literals.kpeg +23 -0
  111. data/lib/rdoc/markdown/literals.rb +417 -0
  112. data/lib/rdoc/markdown.kpeg +1237 -0
  113. data/lib/rdoc/markdown.rb +16685 -0
  114. data/lib/rdoc/markup/attr_changer.rb +23 -0
  115. data/lib/rdoc/markup/attr_span.rb +36 -0
  116. data/lib/rdoc/markup/attribute_manager.rb +409 -0
  117. data/lib/rdoc/markup/attributes.rb +71 -0
  118. data/lib/rdoc/markup/blank_line.rb +28 -0
  119. data/lib/rdoc/markup/block_quote.rb +15 -0
  120. data/lib/rdoc/markup/document.rb +165 -0
  121. data/lib/rdoc/markup/formatter.rb +266 -0
  122. data/lib/rdoc/markup/hard_break.rb +32 -0
  123. data/lib/rdoc/markup/heading.rb +79 -0
  124. data/lib/rdoc/markup/include.rb +43 -0
  125. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  126. data/lib/rdoc/markup/list.rb +102 -0
  127. data/lib/rdoc/markup/list_item.rb +100 -0
  128. data/lib/rdoc/markup/paragraph.rb +29 -0
  129. data/lib/rdoc/markup/parser.rb +575 -0
  130. data/lib/rdoc/markup/pre_process.rb +296 -0
  131. data/lib/rdoc/markup/raw.rb +70 -0
  132. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  133. data/lib/rdoc/markup/rule.rb +21 -0
  134. data/lib/rdoc/markup/table.rb +47 -0
  135. data/lib/rdoc/markup/to_ansi.rb +94 -0
  136. data/lib/rdoc/markup/to_bs.rb +77 -0
  137. data/lib/rdoc/markup/to_html.rb +444 -0
  138. data/lib/rdoc/markup/to_html_crossref.rb +176 -0
  139. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  140. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  141. data/lib/rdoc/markup/to_label.rb +75 -0
  142. data/lib/rdoc/markup/to_markdown.rb +192 -0
  143. data/lib/rdoc/markup/to_rdoc.rb +362 -0
  144. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  145. data/lib/rdoc/markup/to_test.rb +70 -0
  146. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  147. data/lib/rdoc/markup/verbatim.rb +84 -0
  148. data/lib/rdoc/markup.rb +867 -0
  149. data/lib/rdoc/meta_method.rb +7 -0
  150. data/lib/rdoc/method_attr.rb +419 -0
  151. data/lib/rdoc/mixin.rb +121 -0
  152. data/lib/rdoc/normal_class.rb +93 -0
  153. data/lib/rdoc/normal_module.rb +74 -0
  154. data/lib/rdoc/options.rb +1285 -0
  155. data/lib/rdoc/parser/c.rb +1225 -0
  156. data/lib/rdoc/parser/changelog.rb +335 -0
  157. data/lib/rdoc/parser/markdown.rb +24 -0
  158. data/lib/rdoc/parser/rd.rb +23 -0
  159. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  160. data/lib/rdoc/parser/ruby.rb +2327 -0
  161. data/lib/rdoc/parser/ruby_tools.rb +167 -0
  162. data/lib/rdoc/parser/simple.rb +61 -0
  163. data/lib/rdoc/parser/text.rb +12 -0
  164. data/lib/rdoc/parser.rb +277 -0
  165. data/lib/rdoc/rd/block_parser.rb +1056 -0
  166. data/lib/rdoc/rd/block_parser.ry +639 -0
  167. data/lib/rdoc/rd/inline.rb +72 -0
  168. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  169. data/lib/rdoc/rd/inline_parser.ry +593 -0
  170. data/lib/rdoc/rd.rb +100 -0
  171. data/lib/rdoc/rdoc.rb +579 -0
  172. data/lib/rdoc/require.rb +52 -0
  173. data/lib/rdoc/ri/driver.rb +1572 -0
  174. data/lib/rdoc/ri/formatter.rb +6 -0
  175. data/lib/rdoc/ri/paths.rb +171 -0
  176. data/lib/rdoc/ri/store.rb +7 -0
  177. data/lib/rdoc/ri/task.rb +71 -0
  178. data/lib/rdoc/ri.rb +21 -0
  179. data/lib/rdoc/rubygems_hook.rb +246 -0
  180. data/lib/rdoc/servlet.rb +451 -0
  181. data/lib/rdoc/single_class.rb +26 -0
  182. data/lib/rdoc/stats/normal.rb +58 -0
  183. data/lib/rdoc/stats/quiet.rb +60 -0
  184. data/lib/rdoc/stats/verbose.rb +46 -0
  185. data/lib/rdoc/stats.rb +462 -0
  186. data/lib/rdoc/store.rb +979 -0
  187. data/lib/rdoc/task.rb +329 -0
  188. data/lib/rdoc/text.rb +304 -0
  189. data/lib/rdoc/token_stream.rb +119 -0
  190. data/lib/rdoc/tom_doc.rb +263 -0
  191. data/lib/rdoc/top_level.rb +289 -0
  192. data/lib/rdoc/version.rb +8 -0
  193. data/lib/rdoc.rb +201 -0
  194. data/man/ri.1 +247 -0
  195. data/rdoc.gemspec +249 -0
  196. metadata +279 -0
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # MetaMethod represents a meta-programmed method
4
+
5
+ class RDoc::MetaMethod < RDoc::AnyMethod
6
+ end
7
+
@@ -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
+