rdoc 3.9.5 → 3.10.pre.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (183) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +6 -3
  3. data/History.txt +63 -13
  4. data/LICENSE.rdoc +57 -0
  5. data/Manifest.txt +60 -6
  6. data/Rakefile +24 -12
  7. data/TODO.rdoc +30 -0
  8. data/bin/rdoc +0 -2
  9. data/lib/rdoc.rb +55 -2
  10. data/lib/rdoc/alias.rb +0 -2
  11. data/lib/rdoc/anon_class.rb +0 -2
  12. data/lib/rdoc/any_method.rb +0 -3
  13. data/lib/rdoc/attr.rb +0 -2
  14. data/lib/rdoc/class_module.rb +40 -7
  15. data/lib/rdoc/code_object.rb +1 -3
  16. data/lib/rdoc/code_objects.rb +3 -21
  17. data/lib/rdoc/comment.rb +225 -0
  18. data/lib/rdoc/constant.rb +0 -2
  19. data/lib/rdoc/context.rb +37 -120
  20. data/lib/rdoc/context/section.rb +114 -0
  21. data/lib/rdoc/cross_reference.rb +16 -7
  22. data/lib/rdoc/encoding.rb +0 -2
  23. data/lib/rdoc/gauntlet.rb +1 -1
  24. data/lib/rdoc/generator.rb +7 -2
  25. data/lib/rdoc/generator/darkfish.rb +126 -20
  26. data/lib/rdoc/generator/json_index.rb +240 -0
  27. data/lib/rdoc/generator/markup.rb +17 -54
  28. data/lib/rdoc/generator/ri.rb +0 -3
  29. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  30. data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
  41. data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
  42. data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
  43. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  44. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
  48. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
  49. data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
  50. data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
  51. data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
  52. data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
  53. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
  54. data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
  55. data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
  56. data/lib/rdoc/ghost_method.rb +0 -2
  57. data/lib/rdoc/include.rb +0 -2
  58. data/lib/rdoc/markup.rb +204 -43
  59. data/lib/rdoc/markup/attr_changer.rb +25 -0
  60. data/lib/rdoc/markup/attr_span.rb +29 -0
  61. data/lib/rdoc/markup/attribute.rb +51 -0
  62. data/lib/rdoc/markup/document.rb +22 -1
  63. data/lib/rdoc/markup/formatter.rb +4 -11
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -2
  65. data/lib/rdoc/markup/heading.rb +44 -0
  66. data/lib/rdoc/markup/include.rb +42 -0
  67. data/lib/rdoc/markup/inline.rb +1 -144
  68. data/lib/rdoc/markup/list.rb +2 -1
  69. data/lib/rdoc/markup/parser.rb +6 -16
  70. data/lib/rdoc/markup/pre_process.rb +64 -10
  71. data/lib/rdoc/markup/raw.rb +1 -1
  72. data/lib/rdoc/markup/special.rb +40 -0
  73. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
  74. data/lib/rdoc/markup/to_ansi.rb +0 -2
  75. data/lib/rdoc/markup/to_bs.rb +0 -2
  76. data/lib/rdoc/markup/to_html.rb +102 -34
  77. data/lib/rdoc/markup/to_html_crossref.rb +36 -5
  78. data/lib/rdoc/markup/to_html_snippet.rb +270 -0
  79. data/lib/rdoc/markup/to_label.rb +55 -0
  80. data/lib/rdoc/markup/to_rdoc.rb +0 -3
  81. data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
  82. data/lib/rdoc/markup/to_test.rb +0 -3
  83. data/lib/rdoc/markup/to_tt_only.rb +0 -3
  84. data/lib/rdoc/markup/verbatim.rb +18 -0
  85. data/lib/rdoc/meta_method.rb +0 -2
  86. data/lib/rdoc/method_attr.rb +17 -1
  87. data/lib/rdoc/normal_class.rb +0 -2
  88. data/lib/rdoc/normal_module.rb +0 -2
  89. data/lib/rdoc/options.rb +18 -3
  90. data/lib/rdoc/parser.rb +74 -42
  91. data/lib/rdoc/parser/c.rb +79 -118
  92. data/lib/rdoc/parser/rd.rb +22 -0
  93. data/lib/rdoc/parser/ruby.rb +86 -54
  94. data/lib/rdoc/parser/simple.rb +21 -9
  95. data/lib/rdoc/parser/text.rb +11 -0
  96. data/lib/rdoc/rd.rb +95 -0
  97. data/lib/rdoc/rd/block_parser.ry +638 -0
  98. data/lib/rdoc/rd/inline.rb +71 -0
  99. data/lib/rdoc/rd/inline_parser.ry +575 -0
  100. data/lib/rdoc/rdoc.rb +8 -23
  101. data/lib/rdoc/require.rb +0 -2
  102. data/lib/rdoc/ri.rb +4 -2
  103. data/lib/rdoc/ri/driver.rb +2 -6
  104. data/lib/rdoc/ri/store.rb +0 -1
  105. data/lib/rdoc/ruby_lex.rb +43 -20
  106. data/lib/rdoc/ruby_token.rb +44 -2
  107. data/lib/rdoc/single_class.rb +0 -2
  108. data/lib/rdoc/stats.rb +0 -5
  109. data/lib/rdoc/task.rb +2 -6
  110. data/lib/rdoc/test_case.rb +59 -0
  111. data/lib/rdoc/text.rb +42 -30
  112. data/lib/rdoc/token_stream.rb +45 -0
  113. data/lib/rdoc/tom_doc.rb +232 -0
  114. data/lib/rdoc/top_level.rb +36 -4
  115. data/test/test_attribute_manager.rb +26 -29
  116. data/test/test_rdoc_any_method.rb +2 -26
  117. data/test/test_rdoc_attr.rb +4 -4
  118. data/test/test_rdoc_class_module.rb +95 -12
  119. data/test/test_rdoc_code_object.rb +10 -3
  120. data/test/test_rdoc_comment.rb +504 -0
  121. data/test/test_rdoc_context.rb +60 -11
  122. data/test/test_rdoc_context_section.rb +16 -17
  123. data/test/test_rdoc_cross_reference.rb +17 -2
  124. data/test/test_rdoc_encoding.rb +4 -7
  125. data/test/test_rdoc_generator_darkfish.rb +12 -11
  126. data/test/test_rdoc_generator_json_index.rb +255 -0
  127. data/test/test_rdoc_generator_markup.rb +56 -0
  128. data/test/test_rdoc_generator_ri.rb +8 -11
  129. data/test/test_rdoc_markup.rb +9 -5
  130. data/test/test_rdoc_markup_attribute_manager.rb +5 -8
  131. data/test/test_rdoc_markup_document.rb +34 -6
  132. data/test/test_rdoc_markup_formatter.rb +11 -13
  133. data/test/test_rdoc_markup_heading.rb +20 -0
  134. data/test/test_rdoc_markup_include.rb +19 -0
  135. data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
  136. data/test/test_rdoc_markup_paragraph.rb +2 -5
  137. data/test/test_rdoc_markup_parser.rb +87 -7
  138. data/test/test_rdoc_markup_pre_process.rb +60 -9
  139. data/test/test_rdoc_markup_raw.rb +4 -6
  140. data/test/test_rdoc_markup_to_ansi.rb +1 -4
  141. data/test/test_rdoc_markup_to_bs.rb +1 -4
  142. data/test/test_rdoc_markup_to_html.rb +170 -31
  143. data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
  144. data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
  145. data/test/test_rdoc_markup_to_label.rb +50 -0
  146. data/test/test_rdoc_markup_to_rdoc.rb +1 -4
  147. data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
  148. data/test/test_rdoc_markup_to_tt_only.rb +1 -4
  149. data/test/test_rdoc_markup_verbatim.rb +16 -0
  150. data/test/test_rdoc_method_attr.rb +16 -1
  151. data/test/test_rdoc_options.rb +17 -7
  152. data/test/test_rdoc_parser.rb +75 -6
  153. data/test/test_rdoc_parser_c.rb +56 -104
  154. data/test/test_rdoc_parser_rd.rb +52 -0
  155. data/test/test_rdoc_parser_ruby.rb +264 -323
  156. data/test/test_rdoc_parser_simple.rb +33 -17
  157. data/test/test_rdoc_rd.rb +30 -0
  158. data/test/test_rdoc_rd_block_parser.rb +527 -0
  159. data/test/test_rdoc_rd_inline.rb +63 -0
  160. data/test/test_rdoc_rd_inline_parser.rb +173 -0
  161. data/test/test_rdoc_rdoc.rb +7 -9
  162. data/test/test_rdoc_ri_driver.rb +10 -15
  163. data/test/test_rdoc_ri_paths.rb +6 -6
  164. data/test/test_rdoc_ri_store.rb +6 -13
  165. data/test/test_rdoc_ruby_lex.rb +53 -5
  166. data/test/test_rdoc_rubygems_hook.rb +2 -1
  167. data/test/test_rdoc_stats.rb +83 -103
  168. data/test/test_rdoc_task.rb +5 -4
  169. data/test/test_rdoc_text.rb +156 -11
  170. data/test/test_rdoc_token_stream.rb +42 -0
  171. data/test/test_rdoc_tom_doc.rb +458 -0
  172. data/test/test_rdoc_top_level.rb +49 -2
  173. data/test/xref_test_case.rb +4 -8
  174. metadata +217 -111
  175. metadata.gz.sig +0 -0
  176. checksums.yaml +0 -7
  177. checksums.yaml.gz.sig +0 -0
  178. data/CVE-2013-0256.rdoc +0 -49
  179. data/LICENSE.txt +0 -57
  180. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
  181. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  182. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  183. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
data/bin/rdoc CHANGED
@@ -5,8 +5,6 @@
5
5
  #
6
6
  # Copyright (c) 2003 Dave Thomas
7
7
  # Released under the same terms as Ruby
8
- #
9
- # $Revision: 15033 $
10
8
 
11
9
  begin
12
10
  gem 'rdoc'
@@ -94,7 +94,7 @@ module RDoc
94
94
 
95
95
  def self.const_missing const_name # :nodoc:
96
96
  if const_name.to_s == 'RDocError' then
97
- warn "RDoc::RDocError is deprecated"
97
+ warn "RDoc::RDocError is deprecated and will be removed in RDoc 4"
98
98
  return Error
99
99
  end
100
100
 
@@ -104,7 +104,7 @@ module RDoc
104
104
  ##
105
105
  # RDoc version you are using
106
106
 
107
- VERSION = '3.9.5'
107
+ VERSION = '3.10'
108
108
 
109
109
  ##
110
110
  # Method visibilities
@@ -143,5 +143,58 @@ module RDoc
143
143
  METHOD_MODIFIERS = GENERAL_MODIFIERS +
144
144
  %w[arg args yield yields notnew not-new not_new doc]
145
145
 
146
+ autoload :RDoc, 'rdoc/rdoc'
147
+
148
+ autoload :TestCase, 'rdoc/test_case'
149
+
150
+ autoload :CrossReference, 'rdoc/cross_reference'
151
+ autoload :ERBIO, 'rdoc/erbio'
152
+ autoload :Encoding, 'rdoc/encoding'
153
+ autoload :Generator, 'rdoc/generator'
154
+ autoload :Options, 'rdoc/options'
155
+ autoload :Parser, 'rdoc/parser'
156
+ autoload :RI, 'rdoc/ri'
157
+ autoload :Stats, 'rdoc/stats'
158
+ autoload :Task, 'rdoc/task'
159
+ autoload :Text, 'rdoc/text'
160
+
161
+ autoload :Markup, 'rdoc/markup'
162
+ autoload :RD, 'rdoc/rd'
163
+ autoload :TomDoc, 'rdoc/tom_doc'
164
+
165
+ autoload :KNOWN_CLASSES, 'rdoc/known_classes'
166
+
167
+ autoload :RubyLex, 'rdoc/ruby_lex'
168
+ autoload :RubyToken, 'rdoc/ruby_token'
169
+ autoload :TokenStream, 'rdoc/token_stream'
170
+
171
+ autoload :Comment, 'rdoc/comment'
172
+
173
+ # code objects
174
+ #
175
+ # We represent the various high-level code constructs that appear in Ruby
176
+ # programs: classes, modules, methods, and so on.
177
+ autoload :CodeObject, 'rdoc/code_object'
178
+
179
+ autoload :Context, 'rdoc/context'
180
+ autoload :TopLevel, 'rdoc/top_level'
181
+
182
+ autoload :AnonClass, 'rdoc/anon_class'
183
+ autoload :ClassModule, 'rdoc/class_module'
184
+ autoload :NormalClass, 'rdoc/normal_class'
185
+ autoload :NormalModule, 'rdoc/normal_module'
186
+ autoload :SingleClass, 'rdoc/single_class'
187
+
188
+ autoload :Alias, 'rdoc/alias'
189
+ autoload :AnyMethod, 'rdoc/any_method'
190
+ autoload :MethodAttr, 'rdoc/method_attr'
191
+ autoload :GhostMethod, 'rdoc/ghost_method'
192
+ autoload :MetaMethod, 'rdoc/meta_method'
193
+ autoload :Attr, 'rdoc/attr'
194
+
195
+ autoload :Constant, 'rdoc/constant'
196
+ autoload :Include, 'rdoc/include'
197
+ autoload :Require, 'rdoc/require'
198
+
146
199
  end
147
200
 
@@ -1,5 +1,3 @@
1
- require 'rdoc/code_object'
2
-
3
1
  ##
4
2
  # Represent an alias, which is an old_name/new_name pair associated with a
5
3
  # particular context
@@ -1,5 +1,3 @@
1
- require 'rdoc/class_module'
2
-
3
1
  ##
4
2
  # An anonymous class like:
5
3
  #
@@ -1,6 +1,3 @@
1
- require 'rdoc/method_attr'
2
- require 'rdoc/token_stream'
3
-
4
1
  ##
5
2
  # AnyMethod is the base class for objects representing methods
6
3
 
@@ -1,5 +1,3 @@
1
- require 'rdoc/method_attr'
2
-
3
1
  ##
4
2
  # An attribute created by \#attr, \#attr_reader, \#attr_writer or
5
3
  # \#attr_accessor
@@ -1,5 +1,3 @@
1
- require 'rdoc/context'
2
-
3
1
  ##
4
2
  # ClassModule is the base class for objects representing either a class or a
5
3
  # module.
@@ -115,11 +113,16 @@ class RDoc::ClassModule < RDoc::Context
115
113
  # across multiple runs.
116
114
 
117
115
  def add_comment comment, location
118
- return if comment.empty? or not document_self
116
+ return unless document_self
119
117
 
120
118
  original = comment
121
119
 
122
- comment = normalize_comment comment
120
+ comment = case comment
121
+ when RDoc::Comment then
122
+ comment.normalize
123
+ else
124
+ normalize_comment comment
125
+ end
123
126
  @comment_location << [comment, location]
124
127
 
125
128
  self.comment = original
@@ -155,9 +158,13 @@ class RDoc::ClassModule < RDoc::Context
155
158
  # more like <tt>+=</tt>.
156
159
 
157
160
  def comment= comment
158
- return if comment.empty?
161
+ comment = case comment
162
+ when RDoc::Comment then
163
+ comment.normalize
164
+ else
165
+ normalize_comment comment
166
+ end
159
167
 
160
- comment = normalize_comment comment
161
168
  comment = "#{@comment}\n---\n#{comment}" unless @comment.empty?
162
169
 
163
170
  super comment
@@ -175,6 +182,13 @@ class RDoc::ClassModule < RDoc::Context
175
182
  remove_invisible min_visibility
176
183
  end
177
184
 
185
+ ##
186
+ # Does this ClassModule or any of its methods have document_self set?
187
+
188
+ def document_self_or_methods
189
+ document_self || method_list.any?{ |m| m.document_self }
190
+ end
191
+
178
192
  ##
179
193
  # Iterates the ancestors of this class or module for which an
180
194
  # RDoc::ClassModule exists.
@@ -438,11 +452,15 @@ class RDoc::ClassModule < RDoc::Context
438
452
  when Array then
439
453
  docs = comment_location.map do |comment, location|
440
454
  doc = super comment
441
- doc.file = location.absolute_name
455
+ doc.file = location
442
456
  doc
443
457
  end
444
458
 
445
459
  RDoc::Markup::Document.new(*docs)
460
+ when RDoc::Comment then
461
+ doc = super comment_location.text, comment_location.format
462
+ doc.file = comment_location.location
463
+ doc
446
464
  when RDoc::Markup::Document then
447
465
  return comment_location
448
466
  else
@@ -497,6 +515,21 @@ class RDoc::ClassModule < RDoc::Context
497
515
  end
498
516
  end
499
517
 
518
+ ##
519
+ # Search record used by RDoc::Generator::JsonIndex
520
+
521
+ def search_record
522
+ [
523
+ name,
524
+ full_name,
525
+ full_name,
526
+ '',
527
+ path,
528
+ '',
529
+ snippet(@comment_location),
530
+ ]
531
+ end
532
+
500
533
  ##
501
534
  # Get the superclass of this class. Attempts to retrieve the superclass
502
535
  # object, returns the name if it is not known.
@@ -1,6 +1,3 @@
1
- require 'rdoc'
2
- require 'rdoc/text'
3
-
4
1
  ##
5
2
  # Base class for the RDoc code tree.
6
3
  #
@@ -124,6 +121,7 @@ class RDoc::CodeObject
124
121
  @comment = case comment
125
122
  when NilClass then ''
126
123
  when RDoc::Markup::Document then comment
124
+ when RDoc::Comment then comment.normalize
127
125
  else
128
126
  if comment and not comment.empty? then
129
127
  normalize_comment comment
@@ -1,23 +1,5 @@
1
- # We represent the various high-level code constructs that appear in Ruby
2
- # programs: classes, modules, methods, and so on.
1
+ # This file was used to load all the RDoc::CodeObject subclasses at once. Now
2
+ # autoload handles this.
3
3
 
4
- require 'rdoc/code_object'
5
- require 'rdoc/context'
6
- require 'rdoc/top_level'
7
-
8
- require 'rdoc/class_module'
9
- require 'rdoc/normal_class'
10
- require 'rdoc/normal_module'
11
- require 'rdoc/anon_class'
12
- require 'rdoc/single_class'
13
-
14
- require 'rdoc/any_method'
15
- require 'rdoc/alias'
16
- require 'rdoc/ghost_method'
17
- require 'rdoc/meta_method'
18
-
19
- require 'rdoc/attr'
20
- require 'rdoc/constant'
21
- require 'rdoc/require'
22
- require 'rdoc/include'
4
+ require 'rdoc'
23
5
 
@@ -0,0 +1,225 @@
1
+ ##
2
+ # A comment holds the text comment for a RDoc::CodeObject and provides a
3
+ # unified way of cleaning it up and parsing it into an RDoc::Markup::Document.
4
+ #
5
+ # Each comment may have a different markup format set by #format=. By default
6
+ # 'rdoc' is used. The :markup: directive tells RDoc which format to use.
7
+ #
8
+ # See RDoc::Markup@Other+directives for instructions on adding an alternate
9
+ # format.
10
+
11
+ class RDoc::Comment
12
+
13
+ include RDoc::Text
14
+
15
+ ##
16
+ # The format of this comment. Defaults to RDoc::Markup
17
+
18
+ attr_reader :format
19
+
20
+ ##
21
+ # The RDoc::TopLevel this comment was found in
22
+
23
+ attr_accessor :location
24
+
25
+ ##
26
+ # The text for this comment
27
+
28
+ attr_reader :text
29
+
30
+ ##
31
+ # Overrides the content returned by #parse. Use when there is no #text
32
+ # source for this comment
33
+
34
+ attr_writer :document
35
+
36
+ ##
37
+ # Creates a new comment with +text+ that is found in the RDoc::TopLevel
38
+ # +location+.
39
+
40
+ def initialize text = nil, location = nil
41
+ @location = location
42
+ @text = text
43
+
44
+ @document = nil
45
+ @format = 'rdoc'
46
+ @normalized = false
47
+ end
48
+
49
+ ##
50
+ #--
51
+ # TODO deep copy @document
52
+
53
+ def initialize_copy copy # :nodoc:
54
+ @text = copy.text.dup
55
+ end
56
+
57
+ def == other # :nodoc:
58
+ self.class === other and
59
+ other.text == @text and other.location == @location
60
+ end
61
+
62
+ ##
63
+ # Look for a 'call-seq' in the comment to override the normal parameter
64
+ # handling. The :call-seq: is indented from the baseline. All lines of the
65
+ # same indentation level and prefix are consumed.
66
+ #
67
+ # For example, all of the following will be used as the :call-seq:
68
+ #
69
+ # # :call-seq:
70
+ # # ARGF.readlines(sep=$/) -> array
71
+ # # ARGF.readlines(limit) -> array
72
+ # # ARGF.readlines(sep, limit) -> array
73
+ # #
74
+ # # ARGF.to_a(sep=$/) -> array
75
+ # # ARGF.to_a(limit) -> array
76
+ # # ARGF.to_a(sep, limit) -> array
77
+
78
+ def extract_call_seq method
79
+ # we must handle situations like the above followed by an unindented first
80
+ # comment. The difficulty is to make sure not to match lines starting
81
+ # with ARGF at the same indent, but that are after the first description
82
+ # paragraph.
83
+ if @text =~ /^\s*:?call-seq:(.*?(?:\S).*?)^\s*$/m then
84
+ all_start, all_stop = $~.offset(0)
85
+ seq_start, seq_stop = $~.offset(1)
86
+
87
+ # we get the following lines that start with the leading word at the
88
+ # same indent, even if they have blank lines before
89
+ if $1 =~ /(^\s*\n)+^(\s*\w+)/m then
90
+ leading = $2 # ' * ARGF' in the example above
91
+ re = %r%
92
+ \A(
93
+ (^\s*\n)+
94
+ (^#{Regexp.escape leading}.*?\n)+
95
+ )+
96
+ ^\s*$
97
+ %xm
98
+
99
+ if @text[seq_stop..-1] =~ re then
100
+ all_stop = seq_stop + $~.offset(0).last
101
+ seq_stop = seq_stop + $~.offset(1).last
102
+ end
103
+ end
104
+
105
+ seq = @text[seq_start..seq_stop]
106
+ seq.gsub!(/^\s*(\S|\n)/m, '\1')
107
+ @text.slice! all_start...all_stop
108
+
109
+ method.call_seq = seq.chomp
110
+
111
+ elsif @text.sub!(/^\s*:?call-seq:(.*?)(^\s*$|\z)/m, '') then
112
+ seq = $1
113
+ seq.gsub!(/^\s*/, '')
114
+ method.call_seq = seq
115
+ end
116
+ #elsif @text.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '') then
117
+ # method.call_seq = $1.strip
118
+ #end
119
+
120
+ method
121
+ end
122
+
123
+ ##
124
+ # A comment is empty if its text String is empty.
125
+
126
+ def empty?
127
+ @text.empty?
128
+ end
129
+
130
+ ##
131
+ # HACK dubious
132
+
133
+ def force_encoding encoding
134
+ @text.force_encoding encoding
135
+ end
136
+
137
+ ##
138
+ # Sets the format of this comment and resets any parsed document
139
+
140
+ def format= format
141
+ @format = format
142
+ @document = nil
143
+ end
144
+
145
+ def inspect # :nodoc:
146
+ "#<%s:%x %s %p>" % [self.class, object_id, @location.absolute_name, @text]
147
+ end
148
+
149
+ ##
150
+ # Normalizes the text. See RDoc::Text#normalize_comment for details
151
+
152
+ def normalize
153
+ return self unless @text
154
+ return self if @normalized # TODO eliminate duplicate normalization
155
+
156
+ @text = normalize_comment @text
157
+
158
+ @normalized = true
159
+
160
+ self
161
+ end
162
+
163
+ ##
164
+ # Was this text normalized?
165
+
166
+ def normalized? # :nodoc:
167
+ @normalized
168
+ end
169
+
170
+ ##
171
+ # Parses the comment into an RDoc::Markup::Document. The parsed document is
172
+ # cached until the text is changed.
173
+
174
+ def parse
175
+ return @document if @document
176
+
177
+ @document = super @text, @format
178
+ @document.file = @location
179
+ @document
180
+ end
181
+
182
+ ##
183
+ # Removes private sections from this comment. Private sections are flush to
184
+ # the comment marker and start with <tt>--</tt> and end with <tt>++</tt>.
185
+ # For C-style comments, a private marker may not start at the opening of the
186
+ # comment.
187
+ #
188
+ # /*
189
+ # *--
190
+ # * private
191
+ # *++
192
+ # * public
193
+ # */
194
+
195
+ def remove_private
196
+ # Workaround for gsub encoding for Ruby 1.9.2 and earlier
197
+ empty = ''
198
+ empty.force_encoding @text.encoding if Object.const_defined? :Encoding
199
+
200
+ @text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
201
+ @text = @text.sub(%r%^\s*[#*]?--.*%m, '')
202
+ end
203
+
204
+ ##
205
+ # Replaces this comment's text with +text+ and resets the parsed document.
206
+ #
207
+ # An error is raised if the comment contains a document but no text.
208
+
209
+ def text= text
210
+ raise RDoc::Error, 'replacing document-only comment is not allowed' if
211
+ @text.nil? and @document
212
+
213
+ @document = nil
214
+ @text = text
215
+ end
216
+
217
+ ##
218
+ # Returns true if this comment is in TomDoc format.
219
+
220
+ def tomdoc?
221
+ @format == 'tomdoc'
222
+ end
223
+
224
+ end
225
+