rdoc 6.13.0 → 6.17.0

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.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +1 -1
  3. data/README.md +112 -0
  4. data/RI.md +1 -1
  5. data/lib/rdoc/code_object/any_method.rb +4 -4
  6. data/lib/rdoc/code_object/attr.rb +3 -3
  7. data/lib/rdoc/code_object/class_module.rb +18 -16
  8. data/lib/rdoc/code_object/constant.rb +5 -5
  9. data/lib/rdoc/code_object/context/section.rb +8 -7
  10. data/lib/rdoc/code_object/context.rb +19 -19
  11. data/lib/rdoc/code_object/method_attr.rb +7 -6
  12. data/lib/rdoc/code_object/mixin.rb +3 -3
  13. data/lib/rdoc/code_object/normal_class.rb +1 -1
  14. data/lib/rdoc/code_object/normal_module.rb +1 -1
  15. data/lib/rdoc/code_object/single_class.rb +1 -1
  16. data/lib/rdoc/code_object/top_level.rb +28 -33
  17. data/lib/rdoc/code_object.rb +3 -3
  18. data/lib/rdoc/comment.rb +196 -14
  19. data/lib/rdoc/cross_reference.rb +4 -4
  20. data/lib/rdoc/encoding.rb +4 -4
  21. data/lib/rdoc/erb_partial.rb +1 -1
  22. data/lib/rdoc/erbio.rb +2 -2
  23. data/lib/rdoc/generator/aliki.rb +42 -0
  24. data/lib/rdoc/generator/darkfish.rb +20 -16
  25. data/lib/rdoc/generator/json_index.rb +3 -3
  26. data/lib/rdoc/generator/markup.rb +12 -0
  27. data/lib/rdoc/generator/pot/message_extractor.rb +4 -4
  28. data/lib/rdoc/generator/pot/po.rb +1 -1
  29. data/lib/rdoc/generator/pot/po_entry.rb +7 -7
  30. data/lib/rdoc/generator/pot.rb +1 -1
  31. data/lib/rdoc/generator/ri.rb +1 -1
  32. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  33. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  34. data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
  35. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  36. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  37. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  38. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  39. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +25 -0
  40. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +25 -0
  41. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  42. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  43. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  44. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  45. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  46. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  47. data/lib/rdoc/generator/template/aliki/class.rhtml +220 -0
  48. data/lib/rdoc/generator/template/aliki/css/rdoc.css +1737 -0
  49. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  50. data/lib/rdoc/generator/template/aliki/js/aliki.js +483 -0
  51. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  52. data/lib/rdoc/generator/template/aliki/js/search.js +120 -0
  53. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  54. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  55. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  56. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  57. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  58. data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -16
  59. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
  60. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
  61. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  62. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
  63. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +19 -19
  64. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
  65. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
  66. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
  67. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
  68. data/lib/rdoc/generator/template/darkfish/class.rhtml +62 -60
  69. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +2 -0
  70. data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
  71. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +21 -1
  72. data/lib/rdoc/generator/template/darkfish/js/search.js +11 -1
  73. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
  74. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
  75. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
  76. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
  77. data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
  78. data/lib/rdoc/generator.rb +1 -0
  79. data/lib/rdoc/markdown.kpeg +72 -18
  80. data/lib/rdoc/markdown.rb +411 -547
  81. data/lib/rdoc/markup/attribute_manager.rb +5 -5
  82. data/lib/rdoc/markup/attributes.rb +3 -3
  83. data/lib/rdoc/markup/blank_line.rb +2 -2
  84. data/lib/rdoc/markup/block_quote.rb +1 -1
  85. data/lib/rdoc/markup/document.rb +8 -8
  86. data/lib/rdoc/markup/formatter.rb +12 -12
  87. data/lib/rdoc/markup/hard_break.rb +3 -3
  88. data/lib/rdoc/markup/heading.rb +4 -4
  89. data/lib/rdoc/markup/include.rb +3 -3
  90. data/lib/rdoc/markup/indented_paragraph.rb +3 -3
  91. data/lib/rdoc/markup/list.rb +4 -4
  92. data/lib/rdoc/markup/list_item.rb +4 -4
  93. data/lib/rdoc/markup/paragraph.rb +2 -2
  94. data/lib/rdoc/markup/parser.rb +11 -11
  95. data/lib/rdoc/markup/pre_process.rb +39 -15
  96. data/lib/rdoc/markup/raw.rb +5 -5
  97. data/lib/rdoc/markup/rule.rb +2 -2
  98. data/lib/rdoc/markup/table.rb +4 -4
  99. data/lib/rdoc/markup/to_ansi.rb +7 -3
  100. data/lib/rdoc/markup/to_bs.rb +10 -6
  101. data/lib/rdoc/markup/to_html.rb +182 -30
  102. data/lib/rdoc/markup/to_html_crossref.rb +58 -28
  103. data/lib/rdoc/markup/to_html_snippet.rb +17 -17
  104. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
  105. data/lib/rdoc/markup/to_label.rb +6 -5
  106. data/lib/rdoc/markup/to_markdown.rb +12 -12
  107. data/lib/rdoc/markup/to_rdoc.rb +40 -31
  108. data/lib/rdoc/markup/to_table_of_contents.rb +3 -3
  109. data/lib/rdoc/markup/to_test.rb +1 -1
  110. data/lib/rdoc/markup/to_tt_only.rb +8 -8
  111. data/lib/rdoc/markup/verbatim.rb +3 -3
  112. data/lib/rdoc/markup.rb +3 -3
  113. data/lib/rdoc/options.rb +53 -23
  114. data/lib/rdoc/parser/c.rb +31 -62
  115. data/lib/rdoc/parser/changelog.rb +9 -9
  116. data/lib/rdoc/parser/prism_ruby.rb +122 -114
  117. data/lib/rdoc/parser/ruby.rb +51 -51
  118. data/lib/rdoc/parser/ruby_tools.rb +5 -7
  119. data/lib/rdoc/parser/simple.rb +5 -22
  120. data/lib/rdoc/parser.rb +8 -8
  121. data/lib/rdoc/rd/inline.rb +4 -4
  122. data/lib/rdoc/rd.rb +1 -1
  123. data/lib/rdoc/rdoc.rb +9 -8
  124. data/lib/rdoc/ri/driver.rb +49 -49
  125. data/lib/rdoc/ri/paths.rb +2 -2
  126. data/lib/rdoc/ri/task.rb +3 -3
  127. data/lib/rdoc/rubygems_hook.rb +14 -11
  128. data/lib/rdoc/servlet.rb +15 -15
  129. data/lib/rdoc/stats/normal.rb +1 -1
  130. data/lib/rdoc/stats/quiet.rb +1 -1
  131. data/lib/rdoc/stats/verbose.rb +3 -3
  132. data/lib/rdoc/stats.rb +12 -12
  133. data/lib/rdoc/store.rb +32 -32
  134. data/lib/rdoc/task.rb +6 -6
  135. data/lib/rdoc/text.rb +11 -11
  136. data/lib/rdoc/token_stream.rb +14 -2
  137. data/lib/rdoc/tom_doc.rb +8 -8
  138. data/lib/rdoc/version.rb +1 -1
  139. data/man/ri.1 +2 -0
  140. data/rdoc.gemspec +72 -0
  141. metadata +61 -6
  142. data/README.rdoc +0 -142
@@ -107,7 +107,7 @@ class RDoc::Markup::AttributeManager
107
107
  ##
108
108
  # Changes the current attribute from +current+ to +new+
109
109
 
110
- def change_attribute current, new
110
+ def change_attribute(current, new)
111
111
  diff = current ^ new
112
112
  attribute(new & diff, current & diff)
113
113
  end
@@ -116,7 +116,7 @@ class RDoc::Markup::AttributeManager
116
116
  # Used by the tests to change attributes by name from +current_set+ to
117
117
  # +new_set+
118
118
 
119
- def changed_attribute_by_name current_set, new_set
119
+ def changed_attribute_by_name(current_set, new_set)
120
120
  current = new = 0
121
121
  current_set.each do |name|
122
122
  current |= @attributes.bitmap_for(name)
@@ -220,7 +220,7 @@ class RDoc::Markup::AttributeManager
220
220
  ##
221
221
  # Converts regexp handling sequences to RDoc attributes
222
222
 
223
- def convert_regexp_handlings str, attrs, exclusive = false
223
+ def convert_regexp_handlings(str, attrs, exclusive = false)
224
224
  @regexp_handlings.each do |regexp, attribute|
225
225
  next unless exclusive == exclusive?(attribute)
226
226
  str.scan(regexp) do
@@ -295,7 +295,7 @@ class RDoc::Markup::AttributeManager
295
295
  #
296
296
  # @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK)
297
297
 
298
- def add_regexp_handling pattern, name, exclusive = false
298
+ def add_regexp_handling(pattern, name, exclusive = false)
299
299
  bitmap = @attributes.bitmap_for(name)
300
300
  @regexp_handlings << [pattern, bitmap]
301
301
  @exclusive_bitmap |= bitmap if exclusive
@@ -304,7 +304,7 @@ class RDoc::Markup::AttributeManager
304
304
  ##
305
305
  # Processes +str+ converting attributes, HTML and regexp handlings
306
306
 
307
- def flow str
307
+ def flow(str)
308
308
  @str = str.dup
309
309
 
310
310
  mask_protected_sequences
@@ -26,7 +26,7 @@ class RDoc::Markup::Attributes
26
26
  ##
27
27
  # Returns a unique bit for +name+
28
28
 
29
- def bitmap_for name
29
+ def bitmap_for(name)
30
30
  bitmap = @name_to_bitmap.assoc name
31
31
 
32
32
  unless bitmap then
@@ -43,7 +43,7 @@ class RDoc::Markup::Attributes
43
43
  ##
44
44
  # Returns a string representation of +bitmap+
45
45
 
46
- def as_string bitmap
46
+ def as_string(bitmap)
47
47
  return 'none' if bitmap.zero?
48
48
  res = []
49
49
 
@@ -57,7 +57,7 @@ class RDoc::Markup::Attributes
57
57
  ##
58
58
  # yields each attribute name in +bitmap+
59
59
 
60
- def each_name_of bitmap
60
+ def each_name_of(bitmap)
61
61
  return enum_for __method__, bitmap unless block_given?
62
62
 
63
63
  @name_to_bitmap.each do |name, bit|
@@ -16,11 +16,11 @@ class RDoc::Markup::BlankLine
16
16
  ##
17
17
  # Calls #accept_blank_line on +visitor+
18
18
 
19
- def accept visitor
19
+ def accept(visitor)
20
20
  visitor.accept_blank_line self
21
21
  end
22
22
 
23
- def pretty_print q # :nodoc:
23
+ def pretty_print(q) # :nodoc:
24
24
  q.text 'blankline'
25
25
  end
26
26
 
@@ -7,7 +7,7 @@ class RDoc::Markup::BlockQuote < RDoc::Markup::Raw
7
7
  ##
8
8
  # Calls #accept_block_quote on +visitor+
9
9
 
10
- def accept visitor
10
+ def accept(visitor)
11
11
  visitor.accept_block_quote self
12
12
  end
13
13
 
@@ -37,7 +37,7 @@ class RDoc::Markup::Document
37
37
  ##
38
38
  # Appends +part+ to the document
39
39
 
40
- def << part
40
+ def <<(part)
41
41
  case part
42
42
  when RDoc::Markup::Document then
43
43
  unless part.empty? then
@@ -53,7 +53,7 @@ class RDoc::Markup::Document
53
53
  end
54
54
  end
55
55
 
56
- def == other # :nodoc:
56
+ def ==(other) # :nodoc:
57
57
  self.class == other.class and
58
58
  @file == other.file and
59
59
  @parts == other.parts
@@ -62,7 +62,7 @@ class RDoc::Markup::Document
62
62
  ##
63
63
  # Runs this document and all its #items through +visitor+
64
64
 
65
- def accept visitor
65
+ def accept(visitor)
66
66
  visitor.start_accepting
67
67
 
68
68
  visitor.accept_document self
@@ -73,14 +73,14 @@ class RDoc::Markup::Document
73
73
  ##
74
74
  # Concatenates the given +parts+ onto the document
75
75
 
76
- def concat parts
76
+ def concat(parts)
77
77
  self.parts.concat parts
78
78
  end
79
79
 
80
80
  ##
81
81
  # Enumerator for the parts of this document
82
82
 
83
- def each &block
83
+ def each(&block)
84
84
  @parts.each(&block)
85
85
  end
86
86
 
@@ -94,7 +94,7 @@ class RDoc::Markup::Document
94
94
  ##
95
95
  # The file this Document was created from.
96
96
 
97
- def file= location
97
+ def file=(location)
98
98
  @file = case location
99
99
  when RDoc::TopLevel then
100
100
  location.relative_name
@@ -111,7 +111,7 @@ class RDoc::Markup::Document
111
111
  #
112
112
  # The information in +other+ is preferred over the receiver
113
113
 
114
- def merge other
114
+ def merge(other)
115
115
  if empty? then
116
116
  @parts = other.parts
117
117
  return self
@@ -135,7 +135,7 @@ class RDoc::Markup::Document
135
135
  RDoc::Markup::Document === @parts.first
136
136
  end
137
137
 
138
- def pretty_print q # :nodoc:
138
+ def pretty_print(q) # :nodoc:
139
139
  start = @file ? "[doc (#{@file}): " : '[doc: '
140
140
 
141
141
  q.group 2, start, ']' do
@@ -21,7 +21,7 @@ class RDoc::Markup::Formatter
21
21
  ##
22
22
  # Converts a target url to one that is relative to a given path
23
23
 
24
- def self.gen_relative_url path, target
24
+ def self.gen_relative_url(path, target)
25
25
  from = File.dirname path
26
26
  to, to_file = File.split target
27
27
 
@@ -45,7 +45,7 @@ class RDoc::Markup::Formatter
45
45
  ##
46
46
  # Creates a new Formatter
47
47
 
48
- def initialize options, markup = nil
48
+ def initialize(options, markup = nil)
49
49
  @options = options
50
50
 
51
51
  @markup = markup || RDoc::Markup.new
@@ -66,7 +66,7 @@ class RDoc::Markup::Formatter
66
66
  ##
67
67
  # Adds +document+ to the output
68
68
 
69
- def accept_document document
69
+ def accept_document(document)
70
70
  document.parts.each do |item|
71
71
  case item
72
72
  when RDoc::Markup::Document then # HACK
@@ -117,7 +117,7 @@ class RDoc::Markup::Formatter
117
117
  ##
118
118
  # Marks up +content+
119
119
 
120
- def convert content
120
+ def convert(content)
121
121
  @markup.convert content, self
122
122
  end
123
123
 
@@ -147,7 +147,7 @@ class RDoc::Markup::Formatter
147
147
  ##
148
148
  # Converts added regexp handlings. See RDoc::Markup#add_regexp_handling
149
149
 
150
- def convert_regexp_handling target
150
+ def convert_regexp_handling(target)
151
151
  return target.text if in_tt?
152
152
 
153
153
  handled = false
@@ -173,7 +173,7 @@ class RDoc::Markup::Formatter
173
173
  ##
174
174
  # Converts a string to be fancier if desired
175
175
 
176
- def convert_string string
176
+ def convert_string(string)
177
177
  string
178
178
  end
179
179
 
@@ -195,7 +195,7 @@ class RDoc::Markup::Formatter
195
195
  @in_tt > 0
196
196
  end
197
197
 
198
- def tt_tag? attr_mask, reverse = false
198
+ def tt_tag?(attr_mask, reverse = false)
199
199
  each_attr_tag(attr_mask, reverse) do |tag|
200
200
  return true if tt? tag
201
201
  end
@@ -205,7 +205,7 @@ class RDoc::Markup::Formatter
205
205
  ##
206
206
  # Turns on tags for +item+ on +res+
207
207
 
208
- def on_tags res, item
208
+ def on_tags(res, item)
209
209
  each_attr_tag(item.turn_on) do |tag|
210
210
  res << annotate(tag.on)
211
211
  @in_tt += 1 if tt? tag
@@ -215,14 +215,14 @@ class RDoc::Markup::Formatter
215
215
  ##
216
216
  # Turns off tags for +item+ on +res+
217
217
 
218
- def off_tags res, item
218
+ def off_tags(res, item)
219
219
  each_attr_tag(item.turn_off, true) do |tag|
220
220
  @in_tt -= 1 if tt? tag
221
221
  res << annotate(tag.off)
222
222
  end
223
223
  end
224
224
 
225
- def each_attr_tag attr_mask, reverse = false
225
+ def each_attr_tag(attr_mask, reverse = false)
226
226
  return if attr_mask.zero?
227
227
 
228
228
  @attr_tags.public_send(reverse ? :reverse_each : :each) do |tag|
@@ -235,7 +235,7 @@ class RDoc::Markup::Formatter
235
235
  ##
236
236
  # Extracts and a scheme, url and an anchor id from +url+ and returns them.
237
237
 
238
- def parse_url url
238
+ def parse_url(url)
239
239
  case url
240
240
  when /^rdoc-label:([^:]*)(?::(.*))?/ then
241
241
  scheme = 'link'
@@ -265,7 +265,7 @@ class RDoc::Markup::Formatter
265
265
  ##
266
266
  # Is +tag+ a tt tag?
267
267
 
268
- def tt? tag
268
+ def tt?(tag)
269
269
  tag.bit == @tt_bit
270
270
  end
271
271
 
@@ -16,15 +16,15 @@ class RDoc::Markup::HardBreak
16
16
  ##
17
17
  # Calls #accept_hard_break on +visitor+
18
18
 
19
- def accept visitor
19
+ def accept(visitor)
20
20
  visitor.accept_hard_break self
21
21
  end
22
22
 
23
- def == other # :nodoc:
23
+ def ==(other) # :nodoc:
24
24
  self.class === other
25
25
  end
26
26
 
27
- def pretty_print q # :nodoc:
27
+ def pretty_print(q) # :nodoc:
28
28
  q.text "[break]"
29
29
  end
30
30
 
@@ -27,7 +27,7 @@ RDoc::Markup::Heading =
27
27
 
28
28
  @to_html = RDoc::Markup::ToHtml.new nil
29
29
 
30
- def @to_html.handle_regexp_CROSSREF target
30
+ def @to_html.handle_regexp_CROSSREF(target)
31
31
  target.text.sub(/^\\/, '')
32
32
  end
33
33
 
@@ -37,7 +37,7 @@ RDoc::Markup::Heading =
37
37
  ##
38
38
  # Calls #accept_heading on +visitor+
39
39
 
40
- def accept visitor
40
+ def accept(visitor)
41
41
  visitor.accept_heading self
42
42
  end
43
43
 
@@ -52,7 +52,7 @@ RDoc::Markup::Heading =
52
52
  # Creates a fully-qualified label which will include the label from
53
53
  # +context+. This helps keep ids unique in HTML.
54
54
 
55
- def label context = nil
55
+ def label(context = nil)
56
56
  label = aref
57
57
 
58
58
  label = [context.aref, label].compact.join '-' if
@@ -75,7 +75,7 @@ RDoc::Markup::Heading =
75
75
  self.class.to_html.to_html(text)
76
76
  end
77
77
 
78
- def pretty_print q # :nodoc:
78
+ def pretty_print(q) # :nodoc:
79
79
  q.group 2, "[head: #{level} ", ']' do
80
80
  q.pp text
81
81
  end
@@ -20,17 +20,17 @@ class RDoc::Markup::Include
20
20
  ##
21
21
  # Creates a new include that will import +file+ from +include_path+
22
22
 
23
- def initialize file, include_path
23
+ def initialize(file, include_path)
24
24
  @file = file
25
25
  @include_path = include_path
26
26
  end
27
27
 
28
- def == other # :nodoc:
28
+ def ==(other) # :nodoc:
29
29
  self.class === other and
30
30
  @file == other.file and @include_path == other.include_path
31
31
  end
32
32
 
33
- def pretty_print q # :nodoc:
33
+ def pretty_print(q) # :nodoc:
34
34
  q.group 2, '[incl ', ']' do
35
35
  q.text file
36
36
  q.breakable
@@ -19,14 +19,14 @@ class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
19
19
  super(*parts)
20
20
  end
21
21
 
22
- def == other # :nodoc:
22
+ def ==(other) # :nodoc:
23
23
  super and indent == other.indent
24
24
  end
25
25
 
26
26
  ##
27
27
  # Calls #accept_indented_paragraph on +visitor+
28
28
 
29
- def accept visitor
29
+ def accept(visitor)
30
30
  visitor.accept_indented_paragraph self
31
31
  end
32
32
 
@@ -34,7 +34,7 @@ class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
34
34
  # Joins the raw paragraph text and converts inline HardBreaks to the
35
35
  # +hard_break+ text followed by the indent.
36
36
 
37
- def text hard_break = nil
37
+ def text(hard_break = nil)
38
38
  @parts.map do |part|
39
39
  if RDoc::Markup::HardBreak === part then
40
40
  '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break
@@ -46,11 +46,11 @@ class RDoc::Markup::List
46
46
  ##
47
47
  # Appends +item+ to the list
48
48
 
49
- def << item
49
+ def <<(item)
50
50
  @items << item
51
51
  end
52
52
 
53
- def == other # :nodoc:
53
+ def ==(other) # :nodoc:
54
54
  self.class == other.class and
55
55
  @type == other.type and
56
56
  @items == other.items
@@ -59,7 +59,7 @@ class RDoc::Markup::List
59
59
  ##
60
60
  # Runs this list and all its #items through +visitor+
61
61
 
62
- def accept visitor
62
+ def accept(visitor)
63
63
  visitor.accept_list_start self
64
64
 
65
65
  @items.each do |item|
@@ -83,7 +83,7 @@ class RDoc::Markup::List
83
83
  @items.last
84
84
  end
85
85
 
86
- def pretty_print q # :nodoc:
86
+ def pretty_print(q) # :nodoc:
87
87
  q.group 2, "[list: #{@type} ", ']' do
88
88
  q.seplist @items do |item|
89
89
  q.pp item
@@ -33,11 +33,11 @@ class RDoc::Markup::ListItem
33
33
  ##
34
34
  # Appends +part+ to the ListItem
35
35
 
36
- def << part
36
+ def <<(part)
37
37
  @parts << part
38
38
  end
39
39
 
40
- def == other # :nodoc:
40
+ def ==(other) # :nodoc:
41
41
  self.class == other.class and
42
42
  @label == other.label and
43
43
  @parts == other.parts
@@ -46,7 +46,7 @@ class RDoc::Markup::ListItem
46
46
  ##
47
47
  # Runs this list item and all its #parts through +visitor+
48
48
 
49
- def accept visitor
49
+ def accept(visitor)
50
50
  visitor.accept_list_item_start self
51
51
 
52
52
  @parts.each do |part|
@@ -70,7 +70,7 @@ class RDoc::Markup::ListItem
70
70
  @parts.length
71
71
  end
72
72
 
73
- def pretty_print q # :nodoc:
73
+ def pretty_print(q) # :nodoc:
74
74
  q.group 2, '[item: ', ']' do
75
75
  case @label
76
76
  when Array then
@@ -7,7 +7,7 @@ class RDoc::Markup::Paragraph < RDoc::Markup::Raw
7
7
  ##
8
8
  # Calls #accept_paragraph on +visitor+
9
9
 
10
- def accept visitor
10
+ def accept(visitor)
11
11
  visitor.accept_paragraph self
12
12
  end
13
13
 
@@ -15,7 +15,7 @@ class RDoc::Markup::Paragraph < RDoc::Markup::Raw
15
15
  # Joins the raw paragraph text and converts inline HardBreaks to the
16
16
  # +hard_break+ text.
17
17
 
18
- def text hard_break = ''
18
+ def text(hard_break = '')
19
19
  @parts.map do |part|
20
20
  if RDoc::Markup::HardBreak === part then
21
21
  hard_break
@@ -57,7 +57,7 @@ class RDoc::Markup::Parser
57
57
  #
58
58
  # Use RDoc::Markup#parse instead of this method.
59
59
 
60
- def self.parse str
60
+ def self.parse(str)
61
61
  parser = new
62
62
  parser.tokenize str
63
63
  doc = RDoc::Markup::Document.new
@@ -67,7 +67,7 @@ class RDoc::Markup::Parser
67
67
  ##
68
68
  # Returns a token stream for +str+, for testing
69
69
 
70
- def self.tokenize str
70
+ def self.tokenize(str)
71
71
  parser = new
72
72
  parser.tokenize str
73
73
  parser.tokens
@@ -87,7 +87,7 @@ class RDoc::Markup::Parser
87
87
  ##
88
88
  # Builds a Heading of +level+
89
89
 
90
- def build_heading level
90
+ def build_heading(level)
91
91
  type, text, = get
92
92
 
93
93
  text = case type
@@ -105,7 +105,7 @@ class RDoc::Markup::Parser
105
105
  ##
106
106
  # Builds a List flush to +margin+
107
107
 
108
- def build_list margin
108
+ def build_list(margin)
109
109
  p :list_start => margin if @debug
110
110
 
111
111
  list = RDoc::Markup::List.new
@@ -205,7 +205,7 @@ class RDoc::Markup::Parser
205
205
  ##
206
206
  # Builds a Paragraph that is flush to +margin+
207
207
 
208
- def build_paragraph margin
208
+ def build_paragraph(margin)
209
209
  p :paragraph_start => margin if @debug
210
210
 
211
211
  paragraph = RDoc::Markup::Paragraph.new
@@ -240,7 +240,7 @@ class RDoc::Markup::Parser
240
240
  # terminated by a newline. Blank lines always consist of a single newline
241
241
  # character, and there is never a single newline at the end of the verbatim.
242
242
 
243
- def build_verbatim margin
243
+ def build_verbatim(margin)
244
244
  p :verbatim_begin => margin if @debug
245
245
  verbatim = RDoc::Markup::Verbatim.new
246
246
 
@@ -339,7 +339,7 @@ class RDoc::Markup::Parser
339
339
  #
340
340
  # Returns +parent+.
341
341
 
342
- def parse parent, indent = 0
342
+ def parse(parent, indent = 0)
343
343
  p :parse_start => indent if @debug
344
344
 
345
345
  until @tokens.empty? do
@@ -403,7 +403,7 @@ class RDoc::Markup::Parser
403
403
  ##
404
404
  # Small hook that is overridden by RDoc::TomDoc
405
405
 
406
- def parse_text parent, indent # :nodoc:
406
+ def parse_text(parent, indent) # :nodoc:
407
407
  parent << build_paragraph(indent)
408
408
  end
409
409
 
@@ -465,7 +465,7 @@ class RDoc::Markup::Parser
465
465
  ##
466
466
  # Creates the StringScanner
467
467
 
468
- def setup_scanner input
468
+ def setup_scanner(input)
469
469
  @s = MyStringScanner.new input
470
470
  end
471
471
 
@@ -474,7 +474,7 @@ class RDoc::Markup::Parser
474
474
  #
475
475
  # Optionally raises an error if the next token is not of the expected type.
476
476
 
477
- def skip token_type, error = true
477
+ def skip(token_type, error = true)
478
478
  type, = get
479
479
  return unless type # end of stream
480
480
  return @current_token if token_type == type
@@ -485,7 +485,7 @@ class RDoc::Markup::Parser
485
485
  ##
486
486
  # Turns text +input+ into a stream of tokens
487
487
 
488
- def tokenize input
488
+ def tokenize(input)
489
489
  setup_scanner input
490
490
 
491
491
  until @s.eos? do
@@ -27,7 +27,7 @@ class RDoc::Markup::PreProcess
27
27
  # with the result RDoc::Comment (or text String) and the code object for the
28
28
  # comment (if any).
29
29
 
30
- def self.post_process &block
30
+ def self.post_process(&block)
31
31
  @post_processors << block
32
32
  end
33
33
 
@@ -50,7 +50,7 @@ class RDoc::Markup::PreProcess
50
50
  # # replace text, etc.
51
51
  # end
52
52
 
53
- def self.register directive, &block
53
+ def self.register(directive, &block)
54
54
  @registered[directive] = block
55
55
  end
56
56
 
@@ -96,19 +96,16 @@ class RDoc::Markup::PreProcess
96
96
  # directive's parameter is set as metadata on the +code_object+. See
97
97
  # RDoc::CodeObject#metadata for details.
98
98
 
99
- def handle text, code_object = nil, &block
100
- first_line = 1
99
+ def handle(text, code_object = nil, &block)
101
100
  if RDoc::Comment === text then
102
101
  comment = text
103
102
  text = text.text
104
- first_line = comment.line || 1
105
103
  end
106
104
 
107
105
  # regexp helper (square brackets for optional)
108
106
  # $1 $2 $3 $4 $5
109
107
  # [prefix][\]:directive:[spaces][param]newline
110
- text = text.lines.map.with_index(first_line) do |line, num|
111
- next line unless line =~ /\A([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):([\w-]+):([ \t]*)(.+)?(\r?\n|$)/
108
+ text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):([\w-]+):([ \t]*)(.+)?(\r?\n|$)/) do
112
109
  # skip something like ':toto::'
113
110
  next $& if $4.empty? and $5 and $5[0, 1] == ':'
114
111
 
@@ -122,9 +119,8 @@ class RDoc::Markup::PreProcess
122
119
  comment.format = $5.downcase
123
120
  next "#{$1.strip}\n"
124
121
  end
125
-
126
- handle_directive $1, $3, $5, code_object, text.encoding, num, &block
127
- end.join
122
+ handle_directive $1, $3, $5, code_object, text.encoding, &block
123
+ end
128
124
 
129
125
  if comment then
130
126
  comment.text = text
@@ -132,11 +128,39 @@ class RDoc::Markup::PreProcess
132
128
  comment = text
133
129
  end
134
130
 
131
+ run_post_processes(comment, code_object)
132
+
133
+ text
134
+ end
135
+
136
+ # Apply directives to a code object
137
+
138
+ def run_pre_processes(comment_text, code_object, start_line_no, type)
139
+ comment_text, directives = parse_comment(comment_text, start_line_no, type)
140
+ directives.each do |directive, (param, line_no)|
141
+ handle_directive('', directive, param, code_object)
142
+ end
143
+ if code_object.is_a?(RDoc::AnyMethod) && (call_seq, = directives['call-seq']) && call_seq
144
+ code_object.call_seq = call_seq.lines.map(&:chomp).reject(&:empty?).join("\n")
145
+ end
146
+ format, = directives['markup']
147
+ [comment_text, format]
148
+ end
149
+
150
+ # Perform post preocesses to a code object
151
+
152
+ def run_post_processes(comment, code_object)
135
153
  self.class.post_processors.each do |handler|
136
154
  handler.call comment, code_object
137
155
  end
156
+ end
138
157
 
139
- text
158
+ # Parse comment and return [normalized_comment_text, directives_hash]
159
+
160
+ def parse_comment(text, line_no, type)
161
+ RDoc::Comment.parse(text, @input_file_name, line_no, type) do |filename, prefix_indent|
162
+ include_file(filename, prefix_indent, text.encoding)
163
+ end
140
164
  end
141
165
 
142
166
  ##
@@ -150,8 +174,8 @@ class RDoc::Markup::PreProcess
150
174
  #--
151
175
  # When 1.8.7 support is ditched prefix can be defaulted to ''
152
176
 
153
- def handle_directive prefix, directive, param, code_object = nil,
154
- encoding = nil, line = nil
177
+ def handle_directive(prefix, directive, param, code_object = nil,
178
+ encoding = nil)
155
179
  blankline = "#{prefix.strip}\n"
156
180
  directive = directive.downcase
157
181
 
@@ -244,7 +268,7 @@ class RDoc::Markup::PreProcess
244
268
 
245
269
  blankline
246
270
  else
247
- result = yield directive, param, line if block_given?
271
+ result = yield directive, param if block_given?
248
272
 
249
273
  case result
250
274
  when nil then
@@ -279,7 +303,7 @@ class RDoc::Markup::PreProcess
279
303
  # TODO shift left the whole file content in that case
280
304
  # TODO comment stop/start #-- and #++ in included file must be processed here
281
305
 
282
- def include_file name, indent, encoding
306
+ def include_file(name, indent, encoding)
283
307
  full_name = find_include_file name
284
308
 
285
309
  unless full_name then