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
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rdoc"
5
+
6
+ require "irb"
7
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/exe/rdoc ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # RDoc: Documentation tool for source code
4
+ # (see lib/rdoc/rdoc.rb for more information)
5
+ #
6
+ # Copyright (c) 2003 Dave Thomas
7
+ # Released under the same terms as Ruby
8
+
9
+ begin
10
+ gem 'rdoc'
11
+ rescue NameError => e # --disable-gems
12
+ raise unless e.name == :gem
13
+ rescue Gem::LoadError
14
+ end
15
+
16
+ require 'rdoc/rdoc'
17
+
18
+ begin
19
+ r = RDoc::RDoc.new
20
+ r.document ARGV
21
+ rescue Errno::ENOSPC
22
+ $stderr.puts 'Ran out of space creating documentation'
23
+ $stderr.puts
24
+ $stderr.puts 'Please free up some space and try again'
25
+ rescue SystemExit
26
+ raise
27
+ rescue Exception => e
28
+ if $DEBUG_RDOC then
29
+ $stderr.puts e.message
30
+ $stderr.puts "#{e.backtrace.join "\n\t"}"
31
+ $stderr.puts
32
+ elsif Interrupt === e then
33
+ $stderr.puts
34
+ $stderr.puts 'Interrupted'
35
+ else
36
+ $stderr.puts "uh-oh! RDoc had a problem:"
37
+ $stderr.puts e.message
38
+ $stderr.puts
39
+ $stderr.puts "run with --debug for full backtrace"
40
+ end
41
+
42
+ exit 1
43
+ end
44
+
data/exe/ri ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ gem 'rdoc'
5
+ rescue NameError => e # --disable-gems
6
+ raise unless e.name == :gem
7
+ rescue Gem::LoadError
8
+ end
9
+
10
+ require 'rdoc/ri/driver'
11
+
12
+ RDoc::RI::Driver.run ARGV
data/lib/rdoc/alias.rb ADDED
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Represent an alias, which is an old_name/new_name pair associated with a
4
+ # particular context
5
+ #--
6
+ # TODO implement Alias as a proxy to a method/attribute, inheriting from
7
+ # MethodAttr
8
+
9
+ class RDoc::Alias < RDoc::CodeObject
10
+
11
+ ##
12
+ # Aliased method's name
13
+
14
+ attr_reader :new_name
15
+
16
+ alias name new_name
17
+
18
+ ##
19
+ # Aliasee method's name
20
+
21
+ attr_reader :old_name
22
+
23
+ ##
24
+ # Is this an alias declared in a singleton context?
25
+
26
+ attr_accessor :singleton
27
+
28
+ ##
29
+ # Source file token stream
30
+
31
+ attr_reader :text
32
+
33
+ ##
34
+ # Creates a new Alias with a token stream of +text+ that aliases +old_name+
35
+ # to +new_name+, has +comment+ and is a +singleton+ context.
36
+
37
+ def initialize(text, old_name, new_name, comment, singleton = false)
38
+ super()
39
+
40
+ @text = text
41
+ @singleton = singleton
42
+ @old_name = old_name
43
+ @new_name = new_name
44
+ self.comment = comment
45
+ end
46
+
47
+ ##
48
+ # Order by #singleton then #new_name
49
+
50
+ def <=>(other)
51
+ [@singleton ? 0 : 1, new_name] <=> [other.singleton ? 0 : 1, other.new_name]
52
+ end
53
+
54
+ ##
55
+ # HTML fragment reference for this alias
56
+
57
+ def aref
58
+ type = singleton ? 'c' : 'i'
59
+ "#alias-#{type}-#{html_name}"
60
+ end
61
+
62
+ ##
63
+ # Full old name including namespace
64
+
65
+ def full_old_name
66
+ @full_name || "#{parent.name}#{pretty_old_name}"
67
+ end
68
+
69
+ ##
70
+ # HTML id-friendly version of +#new_name+.
71
+
72
+ def html_name
73
+ CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
74
+ end
75
+
76
+ def inspect # :nodoc:
77
+ parent_name = parent ? parent.name : '(unknown)'
78
+ "#<%s:0x%x %s.alias_method %s, %s>" % [
79
+ self.class, object_id,
80
+ parent_name, @old_name, @new_name,
81
+ ]
82
+ end
83
+
84
+ ##
85
+ # '::' for the alias of a singleton method/attribute, '#' for instance-level.
86
+
87
+ def name_prefix
88
+ singleton ? '::' : '#'
89
+ end
90
+
91
+ ##
92
+ # Old name with prefix '::' or '#'.
93
+
94
+ def pretty_old_name
95
+ "#{singleton ? '::' : '#'}#{@old_name}"
96
+ end
97
+
98
+ ##
99
+ # New name with prefix '::' or '#'.
100
+
101
+ def pretty_new_name
102
+ "#{singleton ? '::' : '#'}#{@new_name}"
103
+ end
104
+
105
+ alias pretty_name pretty_new_name
106
+
107
+ def to_s # :nodoc:
108
+ "alias: #{self.new_name} -> #{self.pretty_old_name} in: #{parent}"
109
+ end
110
+
111
+ end
112
+
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # An anonymous class like:
4
+ #
5
+ # c = Class.new do end
6
+ #
7
+ # AnonClass is currently not used.
8
+
9
+ class RDoc::AnonClass < RDoc::ClassModule
10
+ end
11
+
@@ -0,0 +1,361 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # AnyMethod is the base class for objects representing methods
4
+
5
+ class RDoc::AnyMethod < RDoc::MethodAttr
6
+
7
+ ##
8
+ # 2::
9
+ # RDoc 4
10
+ # Added calls_super
11
+ # Added parent name and class
12
+ # Added section title
13
+ # 3::
14
+ # RDoc 4.1
15
+ # Added is_alias_for
16
+
17
+ MARSHAL_VERSION = 3 # :nodoc:
18
+
19
+ ##
20
+ # Don't rename \#initialize to \::new
21
+
22
+ attr_accessor :dont_rename_initialize
23
+
24
+ ##
25
+ # The C function that implements this method (if it was defined in a C file)
26
+
27
+ attr_accessor :c_function
28
+
29
+ # Parameters for this method
30
+
31
+ attr_accessor :params
32
+
33
+ ##
34
+ # If true this method uses +super+ to call a superclass version
35
+
36
+ attr_accessor :calls_super
37
+
38
+ include RDoc::TokenStream
39
+
40
+ ##
41
+ # Creates a new AnyMethod with a token stream +text+ and +name+
42
+
43
+ def initialize text, name
44
+ super
45
+
46
+ @c_function = nil
47
+ @dont_rename_initialize = false
48
+ @token_stream = nil
49
+ @calls_super = false
50
+ @superclass_method = nil
51
+ end
52
+
53
+ ##
54
+ # Adds +an_alias+ as an alias for this method in +context+.
55
+
56
+ def add_alias an_alias, context = nil
57
+ method = self.class.new an_alias.text, an_alias.new_name
58
+
59
+ method.record_location an_alias.file
60
+ method.singleton = self.singleton
61
+ method.params = self.params
62
+ method.visibility = self.visibility
63
+ method.comment = an_alias.comment
64
+ method.is_alias_for = self
65
+ @aliases << method
66
+ context.add_method method if context
67
+ method
68
+ end
69
+
70
+ ##
71
+ # Prefix for +aref+ is 'method'.
72
+
73
+ def aref_prefix
74
+ 'method'
75
+ end
76
+
77
+ ##
78
+ # The call_seq or the param_seq with method name, if there is no call_seq.
79
+ #
80
+ # Use this for displaying a method's argument lists.
81
+
82
+ def arglists
83
+ if @call_seq then
84
+ @call_seq
85
+ elsif @params then
86
+ "#{name}#{param_seq}"
87
+ end
88
+ end
89
+
90
+ ##
91
+ # Different ways to call this method
92
+
93
+ def call_seq
94
+ unless call_seq = _call_seq
95
+ call_seq = is_alias_for._call_seq if is_alias_for
96
+ end
97
+
98
+ return unless call_seq
99
+
100
+ deduplicate_call_seq(call_seq)
101
+ end
102
+
103
+ ##
104
+ # Sets the different ways you can call this method. If an empty +call_seq+
105
+ # is given nil is assumed.
106
+ #
107
+ # See also #param_seq
108
+
109
+ def call_seq= call_seq
110
+ return if call_seq.empty?
111
+
112
+ @call_seq = call_seq
113
+ end
114
+
115
+ ##
116
+ # Loads is_alias_for from the internal name. Returns nil if the alias
117
+ # cannot be found.
118
+
119
+ def is_alias_for # :nodoc:
120
+ case @is_alias_for
121
+ when RDoc::MethodAttr then
122
+ @is_alias_for
123
+ when Array then
124
+ return nil unless @store
125
+
126
+ klass_name, singleton, method_name = @is_alias_for
127
+
128
+ return nil unless klass = @store.find_class_or_module(klass_name)
129
+
130
+ @is_alias_for = klass.find_method method_name, singleton
131
+ end
132
+ end
133
+
134
+ ##
135
+ # Dumps this AnyMethod for use by ri. See also #marshal_load
136
+
137
+ def marshal_dump
138
+ aliases = @aliases.map do |a|
139
+ [a.name, parse(a.comment)]
140
+ end
141
+
142
+ is_alias_for = [
143
+ @is_alias_for.parent.full_name,
144
+ @is_alias_for.singleton,
145
+ @is_alias_for.name
146
+ ] if @is_alias_for
147
+
148
+ [ MARSHAL_VERSION,
149
+ @name,
150
+ full_name,
151
+ @singleton,
152
+ @visibility,
153
+ parse(@comment),
154
+ @call_seq,
155
+ @block_params,
156
+ aliases,
157
+ @params,
158
+ @file.relative_name,
159
+ @calls_super,
160
+ @parent.name,
161
+ @parent.class,
162
+ @section.title,
163
+ is_alias_for,
164
+ ]
165
+ end
166
+
167
+ ##
168
+ # Loads this AnyMethod from +array+. For a loaded AnyMethod the following
169
+ # methods will return cached values:
170
+ #
171
+ # * #full_name
172
+ # * #parent_name
173
+
174
+ def marshal_load array
175
+ initialize_visibility
176
+
177
+ @dont_rename_initialize = nil
178
+ @token_stream = nil
179
+ @aliases = []
180
+ @parent = nil
181
+ @parent_name = nil
182
+ @parent_class = nil
183
+ @section = nil
184
+ @file = nil
185
+
186
+ version = array[0]
187
+ @name = array[1]
188
+ @full_name = array[2]
189
+ @singleton = array[3]
190
+ @visibility = array[4]
191
+ @comment = array[5]
192
+ @call_seq = array[6]
193
+ @block_params = array[7]
194
+ # 8 handled below
195
+ @params = array[9]
196
+ # 10 handled below
197
+ @calls_super = array[11]
198
+ @parent_name = array[12]
199
+ @parent_title = array[13]
200
+ @section_title = array[14]
201
+ @is_alias_for = array[15]
202
+
203
+ array[8].each do |new_name, comment|
204
+ add_alias RDoc::Alias.new(nil, @name, new_name, comment, @singleton)
205
+ end
206
+
207
+ @parent_name ||= if @full_name =~ /#/ then
208
+ $`
209
+ else
210
+ name = @full_name.split('::')
211
+ name.pop
212
+ name.join '::'
213
+ end
214
+
215
+ @file = RDoc::TopLevel.new array[10] if version > 0
216
+ end
217
+
218
+ ##
219
+ # Method name
220
+ #
221
+ # If the method has no assigned name, it extracts it from #call_seq.
222
+
223
+ def name
224
+ return @name if @name
225
+
226
+ @name =
227
+ @call_seq[/^.*?\.(\w+)/, 1] ||
228
+ @call_seq[/^.*?(\w+)/, 1] ||
229
+ @call_seq if @call_seq
230
+ end
231
+
232
+ ##
233
+ # A list of this method's method and yield parameters. +call-seq+ params
234
+ # are preferred over parsed method and block params.
235
+
236
+ def param_list
237
+ if @call_seq then
238
+ params = @call_seq.split("\n").last
239
+ params = params.sub(/.*?\((.*)\)/, '\1')
240
+ params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2')
241
+ elsif @params then
242
+ params = @params.sub(/\((.*)\)/, '\1')
243
+
244
+ params << ",#{@block_params}" if @block_params
245
+ elsif @block_params then
246
+ params = @block_params
247
+ else
248
+ return []
249
+ end
250
+
251
+ if @block_params then
252
+ # If this method has explicit block parameters, remove any explicit
253
+ # &block
254
+ params = params.sub(/,?\s*&\w+/, '')
255
+ else
256
+ params = params.sub(/\&(\w+)/, '\1')
257
+ end
258
+
259
+ params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
260
+
261
+ params.map { |param| param.sub(/=.*/, '') }
262
+ end
263
+
264
+ ##
265
+ # Pretty parameter list for this method. If the method's parameters were
266
+ # given by +call-seq+ it is preferred over the parsed values.
267
+
268
+ def param_seq
269
+ if @call_seq then
270
+ params = @call_seq.split("\n").last
271
+ params = params.sub(/[^( ]+/, '')
272
+ params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
273
+ elsif @params then
274
+ params = @params.gsub(/\s*\#.*/, '')
275
+ params = params.tr_s("\n ", " ")
276
+ params = "(#{params})" unless params[0] == ?(
277
+ else
278
+ params = ''
279
+ end
280
+
281
+ if @block_params then
282
+ # If this method has explicit block parameters, remove any explicit
283
+ # &block
284
+ params = params.sub(/,?\s*&\w+/, '')
285
+
286
+ block = @block_params.tr_s("\n ", " ")
287
+ if block[0] == ?(
288
+ block = block.sub(/^\(/, '').sub(/\)/, '')
289
+ end
290
+ params << " { |#{block}| ... }"
291
+ end
292
+
293
+ params
294
+ end
295
+
296
+ ##
297
+ # Sets the store for this method and its referenced code objects.
298
+
299
+ def store= store
300
+ super
301
+
302
+ @file = @store.add_file @file.full_name if @file
303
+ end
304
+
305
+ ##
306
+ # For methods that +super+, find the superclass method that would be called.
307
+
308
+ def superclass_method
309
+ return unless @calls_super
310
+ return @superclass_method if @superclass_method
311
+
312
+ parent.each_ancestor do |ancestor|
313
+ if method = ancestor.method_list.find { |m| m.name == @name } then
314
+ @superclass_method = method
315
+ break
316
+ end
317
+ end
318
+
319
+ @superclass_method
320
+ end
321
+
322
+ protected
323
+
324
+ ##
325
+ # call_seq without deduplication and alias lookup.
326
+
327
+ def _call_seq
328
+ @call_seq if defined?(@call_seq) && @call_seq
329
+ end
330
+
331
+ private
332
+
333
+ ##
334
+ # call_seq with alias examples information removed, if this
335
+ # method is an alias method.
336
+
337
+ def deduplicate_call_seq(call_seq)
338
+ return call_seq unless is_alias_for || !aliases.empty?
339
+
340
+ method_name = self.name
341
+ method_name = method_name[0, 1] if method_name =~ /\A\[/
342
+
343
+ entries = call_seq.split "\n"
344
+
345
+ ignore = aliases.map(&:name)
346
+ if is_alias_for
347
+ ignore << is_alias_for.name
348
+ ignore.concat is_alias_for.aliases.map(&:name)
349
+ end
350
+ ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n}
351
+ ignore.delete(method_name)
352
+ ignore = Regexp.union(ignore)
353
+
354
+ matching = entries.reject do |entry|
355
+ entry =~ /^\w*\.?#{ignore}/ or
356
+ entry =~ /\s#{ignore}\s/
357
+ end
358
+
359
+ matching.join "\n"
360
+ end
361
+ end