rdoc 6.15.1 → 7.1.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +196 -0
  3. data/History.rdoc +1 -1
  4. data/LEGAL.rdoc +6 -0
  5. data/README.md +90 -7
  6. data/doc/markup_reference/markdown.md +558 -0
  7. data/doc/markup_reference/rdoc.rdoc +1169 -0
  8. data/lib/rdoc/code_object/any_method.rb +15 -7
  9. data/lib/rdoc/code_object/class_module.rb +62 -11
  10. data/lib/rdoc/code_object/constant.rb +9 -0
  11. data/lib/rdoc/code_object/context/section.rb +20 -1
  12. data/lib/rdoc/code_object/method_attr.rb +13 -1
  13. data/lib/rdoc/code_object/top_level.rb +31 -18
  14. data/lib/rdoc/comment.rb +190 -8
  15. data/lib/rdoc/cross_reference.rb +30 -21
  16. data/lib/rdoc/generator/aliki.rb +183 -0
  17. data/lib/rdoc/generator/darkfish.rb +8 -2
  18. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  19. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  20. data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
  21. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  22. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  23. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  24. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  25. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +25 -0
  26. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +25 -0
  27. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  28. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  29. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  30. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  31. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  32. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  33. data/lib/rdoc/generator/template/aliki/class.rhtml +220 -0
  34. data/lib/rdoc/generator/template/aliki/css/rdoc.css +1963 -0
  35. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  36. data/lib/rdoc/generator/template/aliki/js/aliki.js +505 -0
  37. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  38. data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  39. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  40. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  41. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  42. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  43. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  44. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  45. data/lib/rdoc/generator/template/darkfish/_head.rhtml +2 -7
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
  48. data/lib/rdoc/generator/template/darkfish/class.rhtml +11 -11
  49. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -0
  50. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +1 -1
  51. data/lib/rdoc/generator/template/json_index/js/searcher.js +5 -1
  52. data/lib/rdoc/generator.rb +1 -0
  53. data/lib/rdoc/markdown.kpeg +1 -5
  54. data/lib/rdoc/markdown.rb +1 -5
  55. data/lib/rdoc/markup/attribute_manager.rb +28 -1
  56. data/lib/rdoc/markup/blank_line.rb +25 -23
  57. data/lib/rdoc/markup/element.rb +21 -0
  58. data/lib/rdoc/markup/hard_break.rb +30 -27
  59. data/lib/rdoc/markup/heading.rb +166 -77
  60. data/lib/rdoc/markup/pre_process.rb +34 -10
  61. data/lib/rdoc/markup/raw.rb +52 -55
  62. data/lib/rdoc/markup/table.rb +48 -40
  63. data/lib/rdoc/markup/to_ansi.rb +4 -0
  64. data/lib/rdoc/markup/to_bs.rb +4 -0
  65. data/lib/rdoc/markup/to_html.rb +37 -15
  66. data/lib/rdoc/markup/to_html_crossref.rb +24 -5
  67. data/lib/rdoc/markup/to_label.rb +11 -1
  68. data/lib/rdoc/markup/to_rdoc.rb +11 -3
  69. data/lib/rdoc/markup/verbatim.rb +1 -1
  70. data/lib/rdoc/markup.rb +3 -2
  71. data/lib/rdoc/options.rb +21 -10
  72. data/lib/rdoc/parser/c.rb +15 -46
  73. data/lib/rdoc/parser/changelog.rb +8 -0
  74. data/lib/rdoc/parser/prism_ruby.rb +121 -113
  75. data/lib/rdoc/parser/ruby.rb +8 -8
  76. data/lib/rdoc/parser/ruby_tools.rb +5 -7
  77. data/lib/rdoc/parser/simple.rb +4 -21
  78. data/lib/rdoc/rdoc.rb +1 -0
  79. data/lib/rdoc/rubygems_hook.rb +3 -3
  80. data/lib/rdoc/text.rb +16 -1
  81. data/lib/rdoc/token_stream.rb +17 -9
  82. data/lib/rdoc/tom_doc.rb +1 -1
  83. data/lib/rdoc/version.rb +1 -1
  84. data/rdoc.gemspec +3 -3
  85. metadata +36 -9
  86. data/CONTRIBUTING.rdoc +0 -219
  87. data/ExampleMarkdown.md +0 -39
  88. data/ExampleRDoc.rdoc +0 -210
@@ -1,52 +1,60 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A section of table
4
2
 
5
- class RDoc::Markup::Table
6
- # headers of each column
7
- attr_accessor :header
3
+ module RDoc
4
+ class Markup
5
+ # A section of table
6
+ class Table < Element
7
+ # Headers of each column
8
+ #: Array[String]
9
+ attr_accessor :header
8
10
 
9
- # alignments of each column
10
- attr_accessor :align
11
+ # Alignments of each column
12
+ #: Array[Symbol?]
13
+ attr_accessor :align
11
14
 
12
- # body texts of each column
13
- attr_accessor :body
15
+ # Body texts of each column
16
+ #: Array[String]
17
+ attr_accessor :body
14
18
 
15
- # Creates new instance
16
- def initialize(header, align, body)
17
- @header, @align, @body = header, align, body
18
- end
19
-
20
- # :stopdoc:
21
- def ==(other)
22
- self.class == other.class and
23
- @header == other.header and
24
- @align == other.align and
25
- @body == other.body
26
- end
19
+ #: (Array[String], Array[Symbol?], Array[String]) -> void
20
+ def initialize(header, align, body)
21
+ @header, @align, @body = header, align, body
22
+ end
27
23
 
28
- def accept(visitor)
29
- visitor.accept_table @header, @body, @align
30
- end
24
+ #: (Object) -> bool
25
+ def ==(other)
26
+ self.class == other.class && @header == other.header &&
27
+ @align == other.align && @body == other.body
28
+ end
31
29
 
32
- def pretty_print(q)
33
- q.group 2, '[Table: ', ']' do
34
- q.group 2, '[Head: ', ']' do
35
- q.seplist @header.zip(@align) do |text, align|
36
- q.pp text
37
- if align
38
- q.text ":"
39
- q.breakable
40
- q.text align.to_s
41
- end
42
- end
30
+ # @override
31
+ #: (untyped) -> void
32
+ def accept(visitor)
33
+ visitor.accept_table(@header, @body, @align)
43
34
  end
44
- q.breakable
45
- q.group 2, '[Body: ', ']' do
46
- q.seplist @body do |body|
47
- q.group 2, '[', ']' do
48
- q.seplist body do |text|
35
+
36
+ # @override
37
+ #: (untyped) -> String
38
+ def pretty_print(q)
39
+ q.group 2, '[Table: ', ']' do
40
+ q.group 2, '[Head: ', ']' do
41
+ q.seplist @header.zip(@align) do |text, align|
49
42
  q.pp text
43
+ if align
44
+ q.text ":"
45
+ q.breakable
46
+ q.text align.to_s
47
+ end
48
+ end
49
+ end
50
+ q.breakable
51
+ q.group 2, '[Body: ', ']' do
52
+ q.seplist @body do |body|
53
+ q.group 2, '[', ']' do
54
+ q.seplist body do |text|
55
+ q.pp text
56
+ end
57
+ end
50
58
  end
51
59
  end
52
60
  end
@@ -81,6 +81,10 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
81
81
  end
82
82
  end
83
83
 
84
+ def calculate_text_width(text)
85
+ text.gsub(/\e\[[\d;]*m/, '').size
86
+ end
87
+
84
88
  ##
85
89
  # Starts accepting with a reset screen
86
90
 
@@ -65,6 +65,10 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
65
65
  end
66
66
  end
67
67
 
68
+ def calculate_text_width(text)
69
+ text.gsub(/_\x08/, '').gsub(/\x08./, '').size
70
+ end
71
+
68
72
  ##
69
73
  # Turns on or off regexp handling for +convert_string+
70
74
 
@@ -221,10 +221,15 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
221
221
 
222
222
  def accept_verbatim(verbatim)
223
223
  text = verbatim.text.rstrip
224
+ format = verbatim.format
224
225
 
225
226
  klass = nil
226
227
 
227
- content = if verbatim.ruby? or parseable? text then
228
+ # Apply Ruby syntax highlighting if
229
+ # - explicitly marked as Ruby (via ruby? which accepts :ruby or :rb)
230
+ # - no format specified but the text is parseable as Ruby
231
+ # Otherwise, add language class when applicable and skip Ruby highlighting
232
+ content = if verbatim.ruby? || (format.nil? && parseable?(text))
228
233
  begin
229
234
  tokens = RDoc::Parser::RipperStateLex.parse text
230
235
  klass = ' class="ruby"'
@@ -236,6 +241,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
236
241
  CGI.escapeHTML text
237
242
  end
238
243
  else
244
+ klass = " class=\"#{format}\"" if format
239
245
  CGI.escapeHTML text
240
246
  end
241
247
 
@@ -306,17 +312,26 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
306
312
  level = [6, heading.level].min
307
313
 
308
314
  label = heading.label @code_object
315
+ legacy_label = heading.legacy_label @code_object
316
+
317
+ # Add legacy anchor before the heading for backward compatibility.
318
+ # This allows old links with label- prefix to still work.
319
+ if @options.output_decoration && !@options.pipe
320
+ @res << "\n<span id=\"#{legacy_label}\" class=\"legacy-anchor\"></span>"
321
+ end
309
322
 
310
323
  @res << if @options.output_decoration
311
324
  "\n<h#{level} id=\"#{label}\">"
312
325
  else
313
326
  "\n<h#{level}>"
314
327
  end
315
- @res << to_html(heading.text)
316
- unless @options.pipe then
317
- @res << "<span><a href=\"##{label}\">&para;</a>"
318
- @res << " <a href=\"#top\">&uarr;</a></span>"
328
+
329
+ if @options.pipe
330
+ @res << to_html(heading.text)
331
+ else
332
+ @res << "<a href=\"##{label}\">#{to_html(heading.text)}</a>"
319
333
  end
334
+
320
335
  @res << "</h#{level}>\n"
321
336
  end
322
337
 
@@ -360,14 +375,18 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
360
375
  end
361
376
 
362
377
  ##
363
- # Generate a link to +url+ with content +text+. Handles the special cases
364
- # for img: and link: described under handle_regexp_HYPERLINK
378
+ # Generates an HTML link or image tag for the given +url+ and +text+.
379
+ #
380
+ # - Image URLs (http/https/link ending in .gif, .png, .jpg, .jpeg, .bmp)
381
+ # become <img> tags
382
+ # - File references (.rb, .rdoc, .md) are converted to .html paths
383
+ # - Anchor URLs (#foo) pass through unchanged for GitHub-style header linking
384
+ # - Footnote links get wrapped in <sup> tags
365
385
 
366
386
  def gen_url(url, text)
367
387
  scheme, url, id = parse_url url
368
388
 
369
- if %w[http https link].include?(scheme) and
370
- url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
389
+ if %w[http https link].include?(scheme) && url =~ /\.(gif|png|jpg|jpeg|bmp)\z/
371
390
  "<img src=\"#{url}\" />"
372
391
  else
373
392
  if scheme != 'link' and %r%\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
@@ -379,9 +398,11 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
379
398
 
380
399
  link = "<a#{id} href=\"#{url}\">#{text}</a>"
381
400
 
382
- link = "<sup>#{link}</sup>" if /"foot/ =~ id
383
-
384
- link
401
+ if /"foot/.match?(id)
402
+ "<sup>#{link}</sup>"
403
+ else
404
+ link
405
+ end
385
406
  end
386
407
  end
387
408
 
@@ -398,9 +419,10 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
398
419
  # Maps attributes to HTML tags
399
420
 
400
421
  def init_tags
401
- add_tag :BOLD, "<strong>", "</strong>"
402
- add_tag :TT, "<code>", "</code>"
403
- add_tag :EM, "<em>", "</em>"
422
+ add_tag :BOLD, "<strong>", "</strong>"
423
+ add_tag :TT, "<code>", "</code>"
424
+ add_tag :EM, "<em>", "</em>"
425
+ add_tag :STRIKE, "<del>", "</del>"
404
426
  end
405
427
 
406
428
  ##
@@ -169,14 +169,33 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
169
169
  end
170
170
 
171
171
  if label
172
+ # Convert label to GitHub-style anchor format
173
+ # First convert + to space (URL encoding), then apply GitHub-style rules
174
+ formatted_label = RDoc::Text.to_anchor(label.tr('+', ' '))
175
+
176
+ # Case 1: Path already has an anchor (e.g., method link)
177
+ # Input: C1#method@label -> path="C1.html#method-i-m"
178
+ # Output: C1.html#method-i-m-label
172
179
  if path =~ /#/
173
- path << "-label-#{label}"
174
- elsif ref&.sections&.any? { |section| label == section.title }
175
- path << "##{label}"
180
+ path << "-#{formatted_label}"
181
+
182
+ # Case 2: Label matches a section title
183
+ # Input: C1@Section -> path="C1.html", section "Section" exists
184
+ # Output: C1.html#section (uses section.aref for GitHub-style)
185
+ elsif (section = ref&.sections&.find { |s| label.tr('+', ' ') == s.title })
186
+ path << "##{section.aref}"
187
+
188
+ # Case 3: Ref has an aref (class/module context)
189
+ # Input: C1@heading -> path="C1.html", ref=C1 class
190
+ # Output: C1.html#class-c1-heading
176
191
  elsif ref.respond_to?(:aref)
177
- path << "##{ref.aref}-label-#{label}"
192
+ path << "##{ref.aref}-#{formatted_label}"
193
+
194
+ # Case 4: No context, just the label (e.g., TopLevel/file)
195
+ # Input: README@section -> path="README_md.html"
196
+ # Output: README_md.html#section
178
197
  else
179
- path << "#label-#{label}"
198
+ path << "##{formatted_label}"
180
199
  end
181
200
  end
182
201
 
@@ -28,11 +28,21 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
28
28
  end
29
29
 
30
30
  ##
31
- # Converts +text+ to an HTML-safe label
31
+ # Converts +text+ to an HTML-safe label using GitHub-style anchor formatting.
32
32
 
33
33
  def convert(text)
34
34
  label = convert_flow @am.flow text
35
35
 
36
+ RDoc::Text.to_anchor(label)
37
+ end
38
+
39
+ ##
40
+ # Converts +text+ to an HTML-safe label using legacy RDoc formatting.
41
+ # Used for generating backward-compatible anchor aliases.
42
+
43
+ def convert_legacy(text)
44
+ label = convert_flow @am.flow text
45
+
36
46
  CGI.escape(label).gsub('%', '-').sub(/^-/, '')
37
47
  end
38
48
 
@@ -250,8 +250,10 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
250
250
  # Adds +table+ to the output
251
251
 
252
252
  def accept_table(header, body, aligns)
253
+ header = header.map { |h| attributes h }
254
+ body = body.map { |row| row.map { |t| attributes t } }
253
255
  widths = header.zip(*body).map do |cols|
254
- cols.map(&:size).max
256
+ cols.map { |col| calculate_text_width(col) }.max
255
257
  end
256
258
  aligns = aligns.map do |a|
257
259
  case a
@@ -264,16 +266,22 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
264
266
  end
265
267
  end
266
268
  @res << header.zip(widths, aligns).map do |h, w, a|
267
- h.__send__(a, w)
269
+ extra_width = h.size - calculate_text_width(h)
270
+ h.__send__(a, w + extra_width)
268
271
  end.join("|").rstrip << "\n"
269
272
  @res << widths.map {|w| "-" * w }.join("|") << "\n"
270
273
  body.each do |row|
271
274
  @res << row.zip(widths, aligns).map do |t, w, a|
272
- t.__send__(a, w)
275
+ extra_width = t.size - calculate_text_width(t)
276
+ t.__send__(a, w + extra_width)
273
277
  end.join("|").rstrip << "\n"
274
278
  end
275
279
  end
276
280
 
281
+ def calculate_text_width(text)
282
+ text.size
283
+ end
284
+
277
285
  ##
278
286
  # Applies attribute-specific markup to +text+ using RDoc::AttributeManager
279
287
 
@@ -70,7 +70,7 @@ class RDoc::Markup::Verbatim < RDoc::Markup::Raw
70
70
 
71
71
  def ruby?
72
72
  @format ||= nil # TODO for older ri data, switch the tree to marshal_dump
73
- @format == :ruby
73
+ @format == :ruby || @format == :rb
74
74
  end
75
75
 
76
76
  ##
data/lib/rdoc/markup.rb CHANGED
@@ -16,7 +16,7 @@
16
16
  #
17
17
  # - +rdoc+:
18
18
  # the +RDoc+ markup format;
19
- # see RDoc::MarkupReference.
19
+ # see {RDoc Markup Reference}[rdoc-ref:doc/markup_reference/rdoc.rdoc]
20
20
  # - +markdown+:
21
21
  # The +markdown+ markup format as described in
22
22
  # the {Markdown Guide}[https://www.markdownguide.org];
@@ -102,7 +102,7 @@
102
102
  #
103
103
  # = \RDoc Markup Reference
104
104
  #
105
- # See RDoc::MarkupReference.
105
+ # See {RDoc Markup Reference}[rdoc-ref:doc/markup_reference/rdoc.rdoc]
106
106
  #
107
107
  #--
108
108
  # Original Author:: Dave Thomas, dave@pragmaticprogrammer.com
@@ -210,6 +210,7 @@ https://github.com/ruby/rdoc/issues
210
210
  autoload :BlankLine, "#{__dir__}/markup/blank_line"
211
211
  autoload :BlockQuote, "#{__dir__}/markup/block_quote"
212
212
  autoload :Document, "#{__dir__}/markup/document"
213
+ autoload :Element, "#{__dir__}/markup/element"
213
214
  autoload :HardBreak, "#{__dir__}/markup/hard_break"
214
215
  autoload :Heading, "#{__dir__}/markup/heading"
215
216
  autoload :Include, "#{__dir__}/markup/include"
data/lib/rdoc/options.rb CHANGED
@@ -378,6 +378,21 @@ class RDoc::Options
378
378
 
379
379
  attr_accessor :canonical_root
380
380
 
381
+ ##
382
+ # Custom footer content configuration for themes that support it.
383
+ # Currently only supported by the Aliki theme.
384
+ #
385
+ # A hash where keys are column titles and values are hashes of link text => URL pairs.
386
+ # Each column will be displayed in the upper footer section.
387
+ #
388
+ # Example:
389
+ # {
390
+ # "DOCUMENTATION" => {"Home" => "/index.html", "Guide" => "/guide.html"},
391
+ # "RESOURCES" => {"RDoc" => "https://ruby.github.io/rdoc/", "GitHub" => "https://github.com/ruby/rdoc"}
392
+ # }
393
+
394
+ attr_accessor :footer_content
395
+
381
396
  def initialize(loaded_options = nil) # :nodoc:
382
397
  init_ivars
383
398
  override loaded_options if loaded_options
@@ -396,10 +411,9 @@ class RDoc::Options
396
411
  @files = nil
397
412
  @force_output = false
398
413
  @force_update = true
399
- @generator = nil
400
- @generator_name = nil
401
- @generator_options = []
414
+ @generator_name = "aliki"
402
415
  @generators = RDoc::RDoc::GENERATORS
416
+ @generator_options = []
403
417
  @hyperlink_all = false
404
418
  @line_numbers = false
405
419
  @locale = nil
@@ -435,6 +449,7 @@ class RDoc::Options
435
449
  @class_module_path_prefix = nil
436
450
  @file_path_prefix = nil
437
451
  @canonical_root = nil
452
+ @footer_content = nil
438
453
  end
439
454
 
440
455
  def init_with(map) # :nodoc:
@@ -463,6 +478,7 @@ class RDoc::Options
463
478
 
464
479
  @apply_default_exclude = map['apply_default_exclude']
465
480
  @autolink_excluded_words = map['autolink_excluded_words']
481
+ @footer_content = map['footer_content']
466
482
 
467
483
  @rdoc_include = sanitize_path map['rdoc_include']
468
484
  @static_path = sanitize_path map['static_path']
@@ -499,6 +515,7 @@ class RDoc::Options
499
515
  @autolink_excluded_words = map['autolink_excluded_words'] if map.has_key?('autolink_excluded_words')
500
516
  @apply_default_exclude = map['apply_default_exclude'] if map.has_key?('apply_default_exclude')
501
517
  @canonical_root = map['canonical_root'] if map.has_key?('canonical_root')
518
+ @footer_content = map['footer_content'] if map.has_key?('footer_content')
502
519
 
503
520
  @warn_missing_rdoc_ref = map['warn_missing_rdoc_ref'] if map.has_key?('warn_missing_rdoc_ref')
504
521
 
@@ -1213,9 +1230,6 @@ Usage: #{opt.program_name} [options] [names...]
1213
1230
  opt.separator nil
1214
1231
  end
1215
1232
 
1216
- setup_generator 'darkfish' if
1217
- argv.grep(/\A(-f|--fmt|--format|-r|-R|--ri|--ri-site)\b/).empty?
1218
-
1219
1233
  deprecated = []
1220
1234
  invalid = []
1221
1235
 
@@ -1233,10 +1247,7 @@ Usage: #{opt.program_name} [options] [names...]
1233
1247
  retry
1234
1248
  end
1235
1249
 
1236
- unless @generator then
1237
- @generator = RDoc::Generator::Darkfish
1238
- @generator_name = 'darkfish'
1239
- end
1250
+ setup_generator unless @generator
1240
1251
 
1241
1252
  if @pipe and not argv.empty? then
1242
1253
  @pipe = false
data/lib/rdoc/parser/c.rb CHANGED
@@ -607,8 +607,6 @@ class RDoc::Parser::C < RDoc::Parser
607
607
  body = args[1]
608
608
  offset, = args[2]
609
609
 
610
- comment.remove_private if comment
611
-
612
610
  # try to find the whole body
613
611
  body = $& if /#{Regexp.escape body}[^(]*?\{.*?^\}/m =~ file_content
614
612
 
@@ -621,11 +619,10 @@ class RDoc::Parser::C < RDoc::Parser
621
619
  override_comment = find_override_comment class_name, meth_obj
622
620
  comment = override_comment if override_comment
623
621
 
624
- comment.normalize
625
622
  find_modifiers comment, meth_obj if comment
626
623
 
627
624
  #meth_obj.params = params
628
- meth_obj.start_collecting_tokens
625
+ meth_obj.start_collecting_tokens(:c)
629
626
  tk = { :line_no => 1, :char_no => 1, :text => body }
630
627
  meth_obj.add_token tk
631
628
  meth_obj.comment = comment
@@ -639,10 +636,9 @@ class RDoc::Parser::C < RDoc::Parser
639
636
 
640
637
  find_body class_name, args[3], meth_obj, file_content, true
641
638
 
642
- comment.normalize
643
639
  find_modifiers comment, meth_obj
644
640
 
645
- meth_obj.start_collecting_tokens
641
+ meth_obj.start_collecting_tokens(:c)
646
642
  tk = { :line_no => 1, :char_no => 1, :text => body }
647
643
  meth_obj.add_token tk
648
644
  meth_obj.comment = comment
@@ -663,7 +659,6 @@ class RDoc::Parser::C < RDoc::Parser
663
659
  comment = find_override_comment class_name, meth_obj
664
660
 
665
661
  if comment then
666
- comment.normalize
667
662
  find_modifiers comment, meth_obj
668
663
  meth_obj.comment = comment
669
664
 
@@ -742,7 +737,6 @@ class RDoc::Parser::C < RDoc::Parser
742
737
  end
743
738
 
744
739
  comment = new_comment comment, @top_level, :c
745
- comment.normalize
746
740
 
747
741
  look_for_directives_in class_mod, comment
748
742
 
@@ -807,9 +801,6 @@ class RDoc::Parser::C < RDoc::Parser
807
801
  # Handles modifiers in +comment+ and updates +meth_obj+ as appropriate.
808
802
 
809
803
  def find_modifiers(comment, meth_obj)
810
- comment.normalize
811
- meth_obj.call_seq = comment.extract_call_seq
812
-
813
804
  look_for_directives_in meth_obj, comment
814
805
  end
815
806
 
@@ -823,10 +814,10 @@ class RDoc::Parser::C < RDoc::Parser
823
814
  comment = if @content =~ %r%Document-method:
824
815
  \s+#{class_name}#{prefix}#{name}
825
816
  \s*?\n((?>.*?\*/))%xm then
826
- "/*#{$1}"
817
+ "/*\n#{$1}"
827
818
  elsif @content =~ %r%Document-method:
828
819
  \s#{name}\s*?\n((?>.*?\*/))%xm then
829
- "/*#{$1}"
820
+ "/*\n#{$1}"
830
821
  end
831
822
 
832
823
  return unless comment
@@ -1061,10 +1052,13 @@ class RDoc::Parser::C < RDoc::Parser
1061
1052
  # Registers a singleton class +sclass_var+ as a singleton of +class_var+
1062
1053
 
1063
1054
  def handle_singleton(sclass_var, class_var)
1064
- class_name = @known_classes[class_var]
1065
-
1066
- @known_classes[sclass_var] = class_name
1067
- @singleton_classes[sclass_var] = class_name
1055
+ if (klass = @classes[class_var])
1056
+ @classes[sclass_var] = klass
1057
+ end
1058
+ if (class_name = @known_classes[class_var])
1059
+ @known_classes[sclass_var] = class_name
1060
+ @singleton_classes[sclass_var] = class_name
1061
+ end
1068
1062
  end
1069
1063
 
1070
1064
  ##
@@ -1102,35 +1096,10 @@ class RDoc::Parser::C < RDoc::Parser
1102
1096
  # Both :main: and :title: directives are deprecated and will be removed in RDoc 7.
1103
1097
 
1104
1098
  def look_for_directives_in(context, comment)
1105
- @preprocess.handle comment, context do |directive, param|
1106
- case directive
1107
- when 'main' then
1108
- @options.main_page = param
1109
-
1110
- warn <<~MSG
1111
- The :main: directive is deprecated and will be removed in RDoc 7.
1112
-
1113
- You can use these options to specify the initial page displayed instead:
1114
- - `--main=#{param}` via the command line
1115
- - `rdoc.main = "#{param}"` if you use `RDoc::Task`
1116
- - `main_page: #{param}` in your `.rdoc_options` file
1117
- MSG
1118
- ''
1119
- when 'title' then
1120
- @options.default_title = param if @options.respond_to? :default_title=
1121
-
1122
- warn <<~MSG
1123
- The :title: directive is deprecated and will be removed in RDoc 7.
1124
-
1125
- You can use these options to specify the title displayed instead:
1126
- - `--title=#{param}` via the command line
1127
- - `rdoc.title = "#{param}"` if you use `RDoc::Task`
1128
- - `title: #{param}` in your `.rdoc_options` file
1129
- MSG
1130
- ''
1131
- end
1132
- end
1133
-
1099
+ comment.text, format = @preprocess.run_pre_processes(comment.text, context, comment.line || 1, :c)
1100
+ comment.format = format if format
1101
+ @preprocess.run_post_processes(comment, context)
1102
+ comment.normalized = true
1134
1103
  comment
1135
1104
  end
1136
1105
 
@@ -293,6 +293,10 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
293
293
  end
294
294
 
295
295
  def aref
296
+ commit
297
+ end
298
+
299
+ def legacy_aref
296
300
  "label-#{commit}"
297
301
  end
298
302
 
@@ -300,6 +304,10 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
300
304
  aref
301
305
  end
302
306
 
307
+ def legacy_label(context = nil)
308
+ legacy_aref
309
+ end
310
+
303
311
  def text
304
312
  case base
305
313
  when nil