rdoc 6.2.1 → 6.3.3

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +16 -14
  3. data/lib/rdoc/any_method.rb +52 -7
  4. data/lib/rdoc/context/section.rb +0 -13
  5. data/lib/rdoc/context.rb +10 -2
  6. data/lib/rdoc/cross_reference.rb +2 -2
  7. data/lib/rdoc/erb_partial.rb +1 -1
  8. data/lib/rdoc/erbio.rb +2 -2
  9. data/lib/rdoc/generator/darkfish.rb +3 -3
  10. data/lib/rdoc/generator/pot.rb +3 -3
  11. data/lib/rdoc/generator/template/darkfish/_head.rhtml +4 -5
  12. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  13. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  14. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  15. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  16. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  17. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  18. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  19. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  20. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  21. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  22. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  23. data/lib/rdoc/generator/template/darkfish/class.rhtml +44 -44
  24. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +21 -1
  25. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  26. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  27. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  28. data/lib/rdoc/i18n.rb +1 -1
  29. data/lib/rdoc/markdown/literals.rb +7 -8
  30. data/lib/rdoc/markdown.kpeg +20 -2
  31. data/lib/rdoc/markdown.rb +458 -61
  32. data/lib/rdoc/markup/attr_span.rb +8 -2
  33. data/lib/rdoc/markup/attribute_manager.rb +93 -28
  34. data/lib/rdoc/markup/formatter.rb +1 -1
  35. data/lib/rdoc/markup/pre_process.rb +1 -1
  36. data/lib/rdoc/markup/table.rb +47 -0
  37. data/lib/rdoc/markup/to_html.rb +46 -6
  38. data/lib/rdoc/markup/to_html_crossref.rb +13 -5
  39. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -0
  40. data/lib/rdoc/markup/to_rdoc.rb +28 -0
  41. data/lib/rdoc/markup/to_table_of_contents.rb +1 -0
  42. data/lib/rdoc/markup.rb +1 -0
  43. data/lib/rdoc/options.rb +34 -2
  44. data/lib/rdoc/parser/c.rb +24 -58
  45. data/lib/rdoc/parser/changelog.rb +145 -14
  46. data/lib/rdoc/parser.rb +7 -7
  47. data/lib/rdoc/rd/block_parser.rb +1 -1
  48. data/lib/rdoc/rd/inline_parser.rb +1 -1
  49. data/lib/rdoc/rdoc.rb +35 -22
  50. data/lib/rdoc/ri/driver.rb +9 -5
  51. data/lib/rdoc/ri/paths.rb +3 -17
  52. data/lib/rdoc/ri/task.rb +1 -1
  53. data/lib/rdoc/rubygems_hook.rb +2 -2
  54. data/lib/rdoc/servlet.rb +6 -1
  55. data/lib/rdoc/store.rb +2 -2
  56. data/lib/rdoc/version.rb +1 -1
  57. data/lib/rdoc.rb +21 -0
  58. data/man/ri.1 +247 -0
  59. data/rdoc.gemspec +4 -1
  60. metadata +23 -7
@@ -7,16 +7,22 @@ class RDoc::Markup::AttrSpan
7
7
  ##
8
8
  # Creates a new AttrSpan for +length+ characters
9
9
 
10
- def initialize(length)
10
+ def initialize(length, exclusive)
11
11
  @attrs = Array.new(length, 0)
12
+ @exclusive = exclusive
12
13
  end
13
14
 
14
15
  ##
15
16
  # Toggles +bits+ from +start+ to +length+
16
17
  def set_attrs(start, length, bits)
18
+ updated = false
17
19
  for i in start ... (start+length)
18
- @attrs[i] |= bits
20
+ if (@exclusive & @attrs[i]) == 0 || (@exclusive & bits) != 0
21
+ @attrs[i] |= bits
22
+ updated = true
23
+ end
19
24
  end
25
+ updated
20
26
  end
21
27
 
22
28
  ##
@@ -58,6 +58,10 @@ class RDoc::Markup::AttributeManager
58
58
 
59
59
  attr_reader :regexp_handlings
60
60
 
61
+ ##
62
+ # A bits of exclusive maps
63
+ attr_reader :exclusive_bitmap
64
+
61
65
  ##
62
66
  # Creates a new attribute manager that understands bold, emphasized and
63
67
  # teletype text.
@@ -68,17 +72,18 @@ class RDoc::Markup::AttributeManager
68
72
  @protectable = %w[<]
69
73
  @regexp_handlings = []
70
74
  @word_pair_map = {}
75
+ @exclusive_bitmap = 0
71
76
  @attributes = RDoc::Markup::Attributes.new
72
77
 
73
- add_word_pair "*", "*", :BOLD
74
- add_word_pair "_", "_", :EM
75
- add_word_pair "+", "+", :TT
78
+ add_word_pair "*", "*", :BOLD, true
79
+ add_word_pair "_", "_", :EM, true
80
+ add_word_pair "+", "+", :TT, true
76
81
 
77
- add_html "em", :EM
78
- add_html "i", :EM
79
- add_html "b", :BOLD
80
- add_html "tt", :TT
81
- add_html "code", :TT
82
+ add_html "em", :EM, true
83
+ add_html "i", :EM, true
84
+ add_html "b", :BOLD, true
85
+ add_html "tt", :TT, true
86
+ add_html "code", :TT, true
82
87
  end
83
88
 
84
89
  ##
@@ -122,29 +127,67 @@ class RDoc::Markup::AttributeManager
122
127
  res
123
128
  end
124
129
 
130
+ def exclusive?(attr)
131
+ (attr & @exclusive_bitmap) != 0
132
+ end
133
+
134
+ NON_PRINTING_START = "\1" # :nodoc:
135
+ NON_PRINTING_END = "\2" # :nodoc:
136
+
125
137
  ##
126
138
  # Map attributes like <b>text</b>to the sequence
127
139
  # \001\002<char>\001\003<char>, where <char> is a per-attribute specific
128
140
  # character
129
141
 
130
- def convert_attrs(str, attrs)
142
+ def convert_attrs(str, attrs, exclusive = false)
143
+ convert_attrs_matching_word_pairs(str, attrs, exclusive)
144
+ convert_attrs_word_pair_map(str, attrs, exclusive)
145
+ end
146
+
147
+ def convert_attrs_matching_word_pairs(str, attrs, exclusive)
131
148
  # first do matching ones
132
- tags = @matching_word_pairs.keys.join("")
149
+ tags = @matching_word_pairs.select { |start, bitmap|
150
+ if exclusive && exclusive?(bitmap)
151
+ true
152
+ elsif !exclusive && !exclusive?(bitmap)
153
+ true
154
+ else
155
+ false
156
+ end
157
+ }.keys
158
+ return if tags.empty?
159
+ all_tags = @matching_word_pairs.keys
133
160
 
134
- re = /(^|\W)([#{tags}])([#\\]?[\w:.\/-]+?\S?)\2(\W|$)/
161
+ re = /(^|\W|[#{all_tags.join("")}])([#{tags.join("")}])(\2*[#\\]?[\w:.\/\[\]-]+?\S?)\2(?!\2)([#{all_tags.join("")}]|\W|$)/
135
162
 
136
- 1 while str.gsub!(re) do
163
+ 1 while str.gsub!(re) { |orig|
137
164
  attr = @matching_word_pairs[$2]
138
- attrs.set_attrs($`.length + $1.length + $2.length, $3.length, attr)
139
- $1 + NULL * $2.length + $3 + NULL * $2.length + $4
140
- end
165
+ attr_updated = attrs.set_attrs($`.length + $1.length + $2.length, $3.length, attr)
166
+ if attr_updated
167
+ $1 + NULL * $2.length + $3 + NULL * $2.length + $4
168
+ else
169
+ $1 + NON_PRINTING_START + $2 + NON_PRINTING_END + $3 + NON_PRINTING_START + $2 + NON_PRINTING_END + $4
170
+ end
171
+ }
172
+ str.delete!(NON_PRINTING_START + NON_PRINTING_END)
173
+ end
141
174
 
175
+ def convert_attrs_word_pair_map(str, attrs, exclusive)
142
176
  # then non-matching
143
177
  unless @word_pair_map.empty? then
144
178
  @word_pair_map.each do |regexp, attr|
145
- str.gsub!(regexp) {
146
- attrs.set_attrs($`.length + $1.length, $2.length, attr)
147
- NULL * $1.length + $2 + NULL * $3.length
179
+ if !exclusive
180
+ next if exclusive?(attr)
181
+ else
182
+ next if !exclusive?(attr)
183
+ end
184
+ 1 while str.gsub!(regexp) { |orig|
185
+ updated = attrs.set_attrs($`.length + $1.length, $2.length, attr)
186
+ if updated
187
+ NULL * $1.length + $2 + NULL * $3.length
188
+ else
189
+ orig
190
+ end
148
191
  }
149
192
  end
150
193
  end
@@ -153,10 +196,18 @@ class RDoc::Markup::AttributeManager
153
196
  ##
154
197
  # Converts HTML tags to RDoc attributes
155
198
 
156
- def convert_html(str, attrs)
157
- tags = @html_tags.keys.join '|'
199
+ def convert_html(str, attrs, exclusive = false)
200
+ tags = @html_tags.select { |start, bitmap|
201
+ if exclusive && exclusive?(bitmap)
202
+ true
203
+ elsif !exclusive && !exclusive?(bitmap)
204
+ true
205
+ else
206
+ false
207
+ end
208
+ }.keys.join '|'
158
209
 
159
- 1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) {
210
+ 1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig|
160
211
  attr = @html_tags[$1.downcase]
161
212
  html_length = $1.length + 2
162
213
  seq = NULL * html_length
@@ -168,8 +219,13 @@ class RDoc::Markup::AttributeManager
168
219
  ##
169
220
  # Converts regexp handling sequences to RDoc attributes
170
221
 
171
- def convert_regexp_handlings str, attrs
222
+ def convert_regexp_handlings str, attrs, exclusive = false
172
223
  @regexp_handlings.each do |regexp, attribute|
224
+ if exclusive
225
+ next if !exclusive?(attribute)
226
+ else
227
+ next if exclusive?(attribute)
228
+ end
173
229
  str.scan(regexp) do
174
230
  capture = $~.size == 1 ? 0 : 1
175
231
 
@@ -205,7 +261,7 @@ class RDoc::Markup::AttributeManager
205
261
  #
206
262
  # am.add_word_pair '*', '*', :BOLD
207
263
 
208
- def add_word_pair(start, stop, name)
264
+ def add_word_pair(start, stop, name, exclusive = false)
209
265
  raise ArgumentError, "Word flags may not start with '<'" if
210
266
  start[0,1] == '<'
211
267
 
@@ -220,6 +276,8 @@ class RDoc::Markup::AttributeManager
220
276
 
221
277
  @protectable << start[0,1]
222
278
  @protectable.uniq!
279
+
280
+ @exclusive_bitmap |= bitmap if exclusive
223
281
  end
224
282
 
225
283
  ##
@@ -228,8 +286,10 @@ class RDoc::Markup::AttributeManager
228
286
  #
229
287
  # am.add_html 'em', :EM
230
288
 
231
- def add_html(tag, name)
232
- @html_tags[tag.downcase] = @attributes.bitmap_for name
289
+ def add_html(tag, name, exclusive = false)
290
+ bitmap = @attributes.bitmap_for name
291
+ @html_tags[tag.downcase] = bitmap
292
+ @exclusive_bitmap |= bitmap if exclusive
233
293
  end
234
294
 
235
295
  ##
@@ -238,8 +298,10 @@ class RDoc::Markup::AttributeManager
238
298
  #
239
299
  # @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK)
240
300
 
241
- def add_regexp_handling pattern, name
242
- @regexp_handlings << [pattern, @attributes.bitmap_for(name)]
301
+ def add_regexp_handling pattern, name, exclusive = false
302
+ bitmap = @attributes.bitmap_for(name)
303
+ @regexp_handlings << [pattern, bitmap]
304
+ @exclusive_bitmap |= bitmap if exclusive
243
305
  end
244
306
 
245
307
  ##
@@ -250,8 +312,11 @@ class RDoc::Markup::AttributeManager
250
312
 
251
313
  mask_protected_sequences
252
314
 
253
- @attrs = RDoc::Markup::AttrSpan.new @str.length
315
+ @attrs = RDoc::Markup::AttrSpan.new @str.length, @exclusive_bitmap
254
316
 
317
+ convert_attrs @str, @attrs, true
318
+ convert_html @str, @attrs, true
319
+ convert_regexp_handlings @str, @attrs, true
255
320
  convert_attrs @str, @attrs
256
321
  convert_html @str, @attrs
257
322
  convert_regexp_handlings @str, @attrs
@@ -156,7 +156,7 @@ class RDoc::Markup::Formatter
156
156
  method_name = "handle_regexp_#{name}"
157
157
 
158
158
  if respond_to? method_name then
159
- target.text = send method_name, target
159
+ target.text = public_send method_name, target
160
160
  handled = true
161
161
  end
162
162
  end
@@ -178,7 +178,7 @@ class RDoc::Markup::PreProcess
178
178
 
179
179
  blankline
180
180
  when 'include' then
181
- filename = param.split.first
181
+ filename = param.split(' ', 2).first
182
182
  include_file filename, prefix, encoding
183
183
  when 'main' then
184
184
  @options.main_page = param if @options.respond_to? :main_page
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # A section of table
4
+
5
+ class RDoc::Markup::Table
6
+ attr_accessor :header, :align, :body
7
+
8
+ def initialize header, align, body
9
+ @header, @align, @body = header, align, body
10
+ end
11
+
12
+ def == other
13
+ self.class == other.class and
14
+ @header == other.header and
15
+ @align == other.align and
16
+ @body == other.body
17
+ end
18
+
19
+ def accept visitor
20
+ visitor.accept_table @header, @body, @align
21
+ end
22
+
23
+ def pretty_print q # :nodoc:
24
+ q.group 2, '[Table: ', ']' do
25
+ q.group 2, '[Head: ', ']' do
26
+ q.seplist @header.zip(@align) do |text, align|
27
+ q.pp text
28
+ if align
29
+ q.text ":"
30
+ q.breakable
31
+ q.text align.to_s
32
+ end
33
+ end
34
+ end
35
+ q.breakable
36
+ q.group 2, '[Body: ', ']' do
37
+ q.seplist @body do |body|
38
+ q.group 2, '[', ']' do
39
+ q.seplist body do |text|
40
+ q.pp text
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -52,12 +52,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
52
52
  @th = nil
53
53
  @hard_break = "<br>\n"
54
54
 
55
- # external links
56
- @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/,
57
- :HYPERLINK)
58
-
59
- add_regexp_handling_RDOCLINK
60
- add_regexp_handling_TIDYLINK
55
+ init_regexp_handlings
61
56
 
62
57
  init_tags
63
58
  end
@@ -66,6 +61,24 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
66
61
  #
67
62
  # These methods are used by regexp handling markup added by RDoc::Markup#add_regexp_handling.
68
63
 
64
+ ##
65
+ # Adds regexp handlings.
66
+
67
+ def init_regexp_handlings
68
+ # external links
69
+ @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/,
70
+ :HYPERLINK)
71
+ init_link_notation_regexp_handlings
72
+ end
73
+
74
+ ##
75
+ # Adds regexp handlings about link notations.
76
+
77
+ def init_link_notation_regexp_handlings
78
+ add_regexp_handling_RDOCLINK
79
+ add_regexp_handling_TIDYLINK
80
+ end
81
+
69
82
  def handle_RDOCLINK url # :nodoc:
70
83
  case url
71
84
  when /^rdoc-ref:/
@@ -301,6 +314,29 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
301
314
  @res << raw.parts.join("\n")
302
315
  end
303
316
 
317
+ ##
318
+ # Adds +table+ to the output
319
+
320
+ def accept_table header, body, aligns
321
+ @res << "\n<table role=\"table\">\n<thead>\n<tr>\n"
322
+ header.zip(aligns) do |text, align|
323
+ @res << '<th'
324
+ @res << ' align="' << align << '"' if align
325
+ @res << '>' << CGI.escapeHTML(text) << "</th>\n"
326
+ end
327
+ @res << "</tr>\n</thead>\n<tbody>\n"
328
+ body.each do |row|
329
+ @res << "<tr>\n"
330
+ row.zip(aligns) do |text, align|
331
+ @res << '<td'
332
+ @res << ' align="' << align << '"' if align
333
+ @res << '>' << CGI.escapeHTML(text) << "</td>\n"
334
+ end
335
+ @res << "</tr>\n"
336
+ end
337
+ @res << "</tbody>\n</table>\n"
338
+ end
339
+
304
340
  # :section: Utilities
305
341
 
306
342
  ##
@@ -321,6 +357,10 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
321
357
  url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
322
358
  "<img src=\"#{url}\" />"
323
359
  else
360
+ if scheme != 'link' and /\.(?:rb|rdoc|md)\z/i =~ url
361
+ url = url.sub(%r%\A([./]*)(.*)\z%) { "#$1#{$2.tr('.', '_')}.html" }
362
+ end
363
+
324
364
  text = text.sub %r%^#{scheme}:/*%i, ''
325
365
  text = text.sub %r%^[*\^](\d+)$%, '\1'
326
366
 
@@ -39,10 +39,18 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
39
39
  @hyperlink_all = @options.hyperlink_all
40
40
  @show_hash = @options.show_hash
41
41
 
42
- crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
42
+ @cross_reference = RDoc::CrossReference.new @context
43
+ end
44
+
45
+ def init_link_notation_regexp_handlings
46
+ add_regexp_handling_RDOCLINK
47
+
48
+ # The crossref must be linked before tidylink because Klass.method[:sym]
49
+ # will be processed as a tidylink first and will be broken.
50
+ crossref_re = @options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
43
51
  @markup.add_regexp_handling crossref_re, :CROSSREF
44
52
 
45
- @cross_reference = RDoc::CrossReference.new @context
53
+ add_regexp_handling_TIDYLINK
46
54
  end
47
55
 
48
56
  ##
@@ -54,7 +62,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
54
62
 
55
63
  name = name[1..-1] unless @show_hash if name[0, 1] == '#'
56
64
 
57
- if name =~ /(.*[^#:])@/
65
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
58
66
  text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
59
67
  code = false
60
68
  else
@@ -130,7 +138,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
130
138
  # Creates an HTML link to +name+ with the given +text+.
131
139
 
132
140
  def link name, text, code = true
133
- if name =~ /(.*[^#:])@/ then
141
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
134
142
  name = $1
135
143
  label = $'
136
144
  end
@@ -144,7 +152,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
144
152
  path = ref.as_href @from_path
145
153
 
146
154
  if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
147
- text = "<code>#{text}</code>"
155
+ text = "<code>#{CGI.escapeHTML text}</code>"
148
156
  end
149
157
 
150
158
  if path =~ /#/ then
@@ -41,6 +41,7 @@ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
41
41
  alias accept_raw ignore
42
42
  alias accept_rule ignore
43
43
  alias accept_verbatim ignore
44
+ alias accept_table ignore
44
45
 
45
46
  end
46
47
 
@@ -237,6 +237,34 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
237
237
  @res << "\n"
238
238
  end
239
239
 
240
+ ##
241
+ # Adds +table+ to the output
242
+
243
+ def accept_table header, body, aligns
244
+ widths = header.zip(body) do |h, b|
245
+ [h.size, b.size].max
246
+ end
247
+ aligns = aligns.map do |a|
248
+ case a
249
+ when nil
250
+ :center
251
+ when :left
252
+ :ljust
253
+ when :right
254
+ :rjust
255
+ end
256
+ end
257
+ @res << header.zip(widths, aligns) do |h, w, a|
258
+ h.__send__(a, w)
259
+ end.join("|").rstrip << "\n"
260
+ @res << widths.map {|w| "-" * w }.join("|") << "\n"
261
+ body.each do |row|
262
+ @res << row.zip(widths, aligns) do |t, w, a|
263
+ t.__send__(a, w)
264
+ end.join("|").rstrip << "\n"
265
+ end
266
+ end
267
+
240
268
  ##
241
269
  # Applies attribute-specific markup to +text+ using RDoc::AttributeManager
242
270
 
@@ -82,6 +82,7 @@ class RDoc::Markup::ToTableOfContents < RDoc::Markup::Formatter
82
82
  alias accept_list_item_end ignore
83
83
  alias accept_list_end_bullet ignore
84
84
  alias accept_list_start ignore
85
+ alias accept_table ignore
85
86
  # :startdoc:
86
87
 
87
88
  end
data/lib/rdoc/markup.rb CHANGED
@@ -843,6 +843,7 @@ https://github.com/ruby/rdoc/issues
843
843
  autoload :List, 'rdoc/markup/list'
844
844
  autoload :ListItem, 'rdoc/markup/list_item'
845
845
  autoload :Paragraph, 'rdoc/markup/paragraph'
846
+ autoload :Table, 'rdoc/markup/table'
846
847
  autoload :Raw, 'rdoc/markup/raw'
847
848
  autoload :Rule, 'rdoc/markup/rule'
848
849
  autoload :Verbatim, 'rdoc/markup/verbatim'
data/lib/rdoc/options.rb CHANGED
@@ -338,8 +338,9 @@ class RDoc::Options
338
338
 
339
339
  attr_reader :visibility
340
340
 
341
- def initialize # :nodoc:
341
+ def initialize loaded_options = nil # :nodoc:
342
342
  init_ivars
343
+ override loaded_options if loaded_options
343
344
  end
344
345
 
345
346
  def init_ivars # :nodoc:
@@ -417,6 +418,37 @@ class RDoc::Options
417
418
  init_with map
418
419
  end
419
420
 
421
+ def override map # :nodoc:
422
+ if map.has_key?('encoding')
423
+ encoding = map['encoding']
424
+ @encoding = encoding ? Encoding.find(encoding) : encoding
425
+ end
426
+
427
+ @charset = map['charset'] if map.has_key?('charset')
428
+ @exclude = map['exclude'] if map.has_key?('exclude')
429
+ @generator_name = map['generator_name'] if map.has_key?('generator_name')
430
+ @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
431
+ @line_numbers = map['line_numbers'] if map.has_key?('line_numbers')
432
+ @locale_name = map['locale_name'] if map.has_key?('locale_name')
433
+ @locale_dir = map['locale_dir'] if map.has_key?('locale_dir')
434
+ @main_page = map['main_page'] if map.has_key?('main_page')
435
+ @markup = map['markup'] if map.has_key?('markup')
436
+ @op_dir = map['op_dir'] if map.has_key?('op_dir')
437
+ @show_hash = map['show_hash'] if map.has_key?('show_hash')
438
+ @tab_width = map['tab_width'] if map.has_key?('tab_width')
439
+ @template_dir = map['template_dir'] if map.has_key?('template_dir')
440
+ @title = map['title'] if map.has_key?('title')
441
+ @visibility = map['visibility'] if map.has_key?('visibility')
442
+ @webcvs = map['webcvs'] if map.has_key?('webcvs')
443
+
444
+ if map.has_key?('rdoc_include')
445
+ @rdoc_include = sanitize_path map['rdoc_include']
446
+ end
447
+ if map.has_key?('static_path')
448
+ @static_path = sanitize_path map['static_path']
449
+ end
450
+ end
451
+
420
452
  def == other # :nodoc:
421
453
  self.class === other and
422
454
  @encoding == other.encoding and
@@ -755,7 +787,7 @@ Usage: #{opt.program_name} [options] [names...]
755
787
 
756
788
  opt.on("--[no-]force-update", "-U",
757
789
  "Forces rdoc to scan all sources even if",
758
- "newer than the flag file.") do |value|
790
+ "no files are newer than the flag file.") do |value|
759
791
  @force_update = value
760
792
  end
761
793
 
data/lib/rdoc/parser/c.rb CHANGED
@@ -209,48 +209,6 @@ class RDoc::Parser::C < RDoc::Parser
209
209
  end
210
210
  end
211
211
 
212
- ##
213
- # Removes duplicate call-seq entries for methods using the same
214
- # implementation.
215
-
216
- def deduplicate_call_seq
217
- @methods.each do |var_name, functions|
218
- class_name = @known_classes[var_name]
219
- next unless class_name
220
- class_obj = find_class var_name, class_name
221
-
222
- functions.each_value do |method_names|
223
- next if method_names.length == 1
224
-
225
- method_names.each do |method_name|
226
- deduplicate_method_name class_obj, method_name
227
- end
228
- end
229
- end
230
- end
231
-
232
- ##
233
- # If two ruby methods share a C implementation (and comment) this
234
- # deduplicates the examples in the call_seq for the method to reduce
235
- # confusion in the output.
236
-
237
- def deduplicate_method_name class_obj, method_name # :nodoc:
238
- return unless
239
- method = class_obj.method_list.find { |m| m.name == method_name }
240
- return unless call_seq = method.call_seq
241
-
242
- method_name = method_name[0, 1] if method_name =~ /\A\[/
243
-
244
- entries = call_seq.split "\n"
245
-
246
- matching = entries.select do |entry|
247
- entry =~ /^\w*\.?#{Regexp.escape method_name}/ or
248
- entry =~ /\s#{Regexp.escape method_name}\s/
249
- end
250
-
251
- method.call_seq = matching.join "\n"
252
- end
253
-
254
212
  ##
255
213
  # Scans #content for rb_define_alias
256
214
 
@@ -269,23 +227,29 @@ class RDoc::Parser::C < RDoc::Parser
269
227
  end
270
228
 
271
229
  class_obj = find_class var_name, class_name
272
-
273
- al = RDoc::Alias.new '', old_name, new_name, ''
274
- al.singleton = @singleton_classes.key? var_name
275
-
276
230
  comment = find_alias_comment var_name, new_name, old_name
277
-
278
231
  comment.normalize
279
-
280
- al.comment = comment
281
-
282
- al.record_location @top_level
283
-
284
- class_obj.add_alias al
285
- @stats.add_alias al
232
+ if comment.to_s.empty? and existing_method = class_obj.method_list.find { |m| m.name == old_name}
233
+ comment = existing_method.comment
234
+ end
235
+ add_alias(var_name, class_obj, old_name, new_name, comment)
286
236
  end
287
237
  end
288
238
 
239
+ ##
240
+ # Add alias, either from a direct alias definition, or from two
241
+ # method that reference the same function.
242
+
243
+ def add_alias(var_name, class_obj, old_name, new_name, comment)
244
+ al = RDoc::Alias.new '', old_name, new_name, ''
245
+ al.singleton = @singleton_classes.key? var_name
246
+ al.comment = comment
247
+ al.record_location @top_level
248
+ class_obj.add_alias al
249
+ @stats.add_alias al
250
+ al
251
+ end
252
+
289
253
  ##
290
254
  # Scans #content for rb_attr and rb_define_attr
291
255
 
@@ -354,7 +318,7 @@ class RDoc::Parser::C < RDoc::Parser
354
318
  \s*"(?<module_name_1>\w+)"\s*
355
319
  \)
356
320
  |
357
- _under\s*\( # rb_define_module_under(module_under, module_name_1)
321
+ _under\s*\( # rb_define_module_under(module_under, module_name_2)
358
322
  \s*(?<module_under>\w+),
359
323
  \s*"(?<module_name_2>\w+)"
360
324
  \s*\)
@@ -608,7 +572,7 @@ class RDoc::Parser::C < RDoc::Parser
608
572
  ((?>/\*.*?\*/\s*)?)
609
573
  ((?:(?:\w+)\s+)?
610
574
  (?:intern\s+)?VALUE\s+(\w+)
611
- \s*(?:\([^)]*\))(?:[^;]|$))
575
+ \s*(?:\([^)]*\))(?:[^\);]|$))
612
576
  | ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
613
577
  | ^\s*\#\s*define\s+(\w+)\s+(\w+)
614
578
  }xm) do
@@ -1021,6 +985,10 @@ class RDoc::Parser::C < RDoc::Parser
1021
985
 
1022
986
  class_obj = find_class var_name, class_name
1023
987
 
988
+ if existing_method = class_obj.method_list.find { |m| m.c_function == function }
989
+ add_alias(var_name, class_obj, existing_method.name, meth_name, existing_method.comment)
990
+ end
991
+
1024
992
  if class_obj then
1025
993
  if meth_name == 'initialize' then
1026
994
  meth_name = 'new'
@@ -1249,8 +1217,6 @@ class RDoc::Parser::C < RDoc::Parser
1249
1217
  do_aliases
1250
1218
  do_attrs
1251
1219
 
1252
- deduplicate_call_seq
1253
-
1254
1220
  @store.add_c_variables self
1255
1221
 
1256
1222
  @top_level