rdoc 7.2.0 → 8.0.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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +3 -4
  3. data/LICENSE.rdoc +4 -0
  4. data/README.md +43 -2
  5. data/doc/markup_reference/markdown.md +104 -3
  6. data/lib/rdoc/code_object/alias.rb +2 -8
  7. data/lib/rdoc/code_object/any_method.rb +11 -6
  8. data/lib/rdoc/code_object/attr.rb +11 -6
  9. data/lib/rdoc/code_object/class_module.rb +62 -32
  10. data/lib/rdoc/code_object/constant.rb +29 -3
  11. data/lib/rdoc/code_object/context/section.rb +4 -35
  12. data/lib/rdoc/code_object/context.rb +39 -34
  13. data/lib/rdoc/code_object/method_attr.rb +9 -15
  14. data/lib/rdoc/code_object/mixin.rb +2 -2
  15. data/lib/rdoc/code_object/top_level.rb +9 -3
  16. data/lib/rdoc/code_object.rb +2 -4
  17. data/lib/rdoc/comment.rb +0 -65
  18. data/lib/rdoc/cross_reference.rb +7 -27
  19. data/lib/rdoc/encoding.rb +3 -3
  20. data/lib/rdoc/generator/aliki.rb +17 -0
  21. data/lib/rdoc/generator/darkfish.rb +12 -6
  22. data/lib/rdoc/generator/json_index.rb +2 -2
  23. data/lib/rdoc/generator/markup.rb +56 -31
  24. data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  25. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
  26. data/lib/rdoc/generator/template/aliki/_head.rhtml +1 -1
  27. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
  28. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
  29. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
  30. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +2 -2
  31. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
  32. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
  33. data/lib/rdoc/generator/template/aliki/class.rhtml +56 -46
  34. data/lib/rdoc/generator/template/aliki/css/rdoc.css +337 -111
  35. data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
  36. data/lib/rdoc/generator/template/aliki/js/aliki.js +20 -18
  37. data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
  38. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
  39. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
  46. data/lib/rdoc/generator/template/darkfish/class.rhtml +18 -21
  47. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +0 -1
  48. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  49. data/lib/rdoc/i18n/text.rb +3 -3
  50. data/lib/rdoc/markdown.kpeg +15 -10
  51. data/lib/rdoc/markdown.rb +289 -104
  52. data/lib/rdoc/markup/document.rb +2 -2
  53. data/lib/rdoc/markup/formatter.rb +24 -34
  54. data/lib/rdoc/markup/heading.rb +1 -4
  55. data/lib/rdoc/markup/indented_paragraph.rb +1 -1
  56. data/lib/rdoc/markup/list.rb +2 -2
  57. data/lib/rdoc/markup/list_item.rb +2 -2
  58. data/lib/rdoc/markup/pre_process.rb +0 -25
  59. data/lib/rdoc/markup/to_ansi.rb +1 -1
  60. data/lib/rdoc/markup/to_bs.rb +1 -1
  61. data/lib/rdoc/markup/to_html.rb +131 -53
  62. data/lib/rdoc/markup/to_html_crossref.rb +97 -71
  63. data/lib/rdoc/markup/to_html_snippet.rb +5 -5
  64. data/lib/rdoc/markup/to_joined_paragraph.rb +0 -5
  65. data/lib/rdoc/markup/to_label.rb +2 -2
  66. data/lib/rdoc/markup/to_markdown.rb +1 -1
  67. data/lib/rdoc/markup/to_rdoc.rb +2 -2
  68. data/lib/rdoc/markup/to_table_of_contents.rb +1 -1
  69. data/lib/rdoc/markup/to_tt_only.rb +0 -7
  70. data/lib/rdoc/markup/verbatim.rb +1 -1
  71. data/lib/rdoc/options.rb +36 -51
  72. data/lib/rdoc/parser/c.rb +7 -6
  73. data/lib/rdoc/parser/rbs.rb +275 -0
  74. data/lib/rdoc/parser/ruby.rb +954 -2066
  75. data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  76. data/lib/rdoc/parser.rb +3 -2
  77. data/lib/rdoc/rbs_helper.rb +186 -0
  78. data/lib/rdoc/rdoc.rb +196 -24
  79. data/lib/rdoc/ri/driver.rb +8 -2
  80. data/lib/rdoc/ri/paths.rb +1 -1
  81. data/lib/rdoc/{servlet.rb → ri/servlet.rb} +5 -5
  82. data/lib/rdoc/ri.rb +4 -3
  83. data/lib/rdoc/rubygems_hook.rb +11 -11
  84. data/lib/rdoc/server.rb +460 -0
  85. data/lib/rdoc/stats.rb +147 -124
  86. data/lib/rdoc/store.rb +212 -4
  87. data/lib/rdoc/task.rb +16 -15
  88. data/lib/rdoc/text.rb +1 -118
  89. data/lib/rdoc/token_stream.rb +11 -33
  90. data/lib/rdoc/version.rb +1 -1
  91. data/lib/rdoc.rb +35 -7
  92. data/lib/rubygems_plugin.rb +2 -11
  93. data/rdoc-logo.svg +43 -0
  94. data/rdoc.gemspec +6 -4
  95. metadata +35 -18
  96. data/lib/rdoc/code_object/anon_class.rb +0 -10
  97. data/lib/rdoc/code_object/ghost_method.rb +0 -6
  98. data/lib/rdoc/code_object/meta_method.rb +0 -6
  99. data/lib/rdoc/parser/prism_ruby.rb +0 -1112
  100. data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
  101. data/lib/rdoc/parser/ruby_tools.rb +0 -163
@@ -26,7 +26,7 @@ class RDoc::Markup::Document
26
26
  ##
27
27
  # Creates a new Document with +parts+
28
28
 
29
- def initialize *parts
29
+ def initialize(*parts)
30
30
  @parts = []
31
31
  @parts.concat parts
32
32
 
@@ -148,7 +148,7 @@ class RDoc::Markup::Document
148
148
  ##
149
149
  # Appends +parts+ to the document
150
150
 
151
- def push *parts
151
+ def push(*parts)
152
152
  self.parts.concat parts
153
153
  end
154
154
 
@@ -14,13 +14,6 @@ require 'rdoc/markup/inline_parser'
14
14
 
15
15
  class RDoc::Markup::Formatter
16
16
 
17
- ##
18
- # Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
19
- # +off+ triggers.
20
-
21
- InlineTag = Struct.new(:bit, :on, :off)
22
-
23
-
24
17
  ##
25
18
  # Converts a target url to one that is relative to a given path
26
19
 
@@ -48,10 +41,8 @@ class RDoc::Markup::Formatter
48
41
  ##
49
42
  # Creates a new Formatter
50
43
 
51
- def initialize(options, markup = nil)
52
- @options = options
53
-
54
- @markup = markup || RDoc::Markup.new
44
+ def initialize
45
+ @markup = RDoc::Markup.new
55
46
 
56
47
  @from_path = '.'
57
48
  end
@@ -94,31 +85,30 @@ class RDoc::Markup::Formatter
94
85
  # Applies regexp handling to +text+ and returns an array of [text, converted?] pairs.
95
86
 
96
87
  def apply_regexp_handling(text)
97
- output = []
98
- start = 0
99
- loop do
100
- pos = text.size
101
- matched_name = matched_text = nil
102
- @markup.regexp_handlings.each do |pattern, name|
103
- m = text.match(pattern, start)
104
- next unless m
88
+ matched = []
89
+ @markup.regexp_handlings.each_with_index do |(pattern, name), priority|
90
+ text.scan(pattern) do
91
+ m = Regexp.last_match
105
92
  idx = m[1] ? 1 : 0
106
- if m.begin(idx) < pos
107
- pos = m.begin(idx)
108
- matched_text = m[idx]
109
- matched_name = name
110
- end
93
+ matched << [m.begin(idx), m.end(idx), m[idx], name, priority]
111
94
  end
112
- output << [text[start...pos], false] if pos > start
113
- if matched_name
114
- handled = public_send(:"handle_regexp_#{matched_name}", matched_text)
115
- output << [handled, true]
116
- start = pos + matched_text.size
117
- else
118
- start = pos
119
- end
120
- break if pos == text.size
121
95
  end
96
+ # If the start positions are the same, prefer the earlier-registered one
97
+ # (lower numeric priority from each_with_index).
98
+ matched.sort_by! {|beg_pos, _, _, _, priority| [beg_pos, priority] }
99
+
100
+ pos = 0
101
+ output = []
102
+ matched.each do |beg_pos, end_pos, s, name|
103
+ next if beg_pos < pos
104
+
105
+ output << [text[pos...beg_pos], false] if beg_pos != pos
106
+ handled = public_send(:"handle_regexp_#{name}", s)
107
+ output << [handled, true]
108
+ pos = end_pos
109
+ end
110
+
111
+ output << [text[pos..], false] if pos < text.size
122
112
  output
123
113
  end
124
114
 
@@ -252,7 +242,7 @@ class RDoc::Markup::Formatter
252
242
  #
253
243
  # alias accept_raw ignore
254
244
 
255
- def ignore *node
245
+ def ignore(*node)
256
246
  end
257
247
 
258
248
  ##
@@ -52,10 +52,7 @@ module RDoc
52
52
  #: () -> RDoc::Markup::ToHtml
53
53
  def self.to_html
54
54
  @to_html ||= begin
55
- markup = Markup.new
56
- markup.add_regexp_handling CrossReference::CROSSREF_REGEXP, :CROSSREF
57
-
58
- to_html = Markup::ToHtml.new nil
55
+ to_html = Markup::ToHtml.new
59
56
 
60
57
  def to_html.handle_regexp_CROSSREF(text)
61
58
  text.sub(/^\\/, '')
@@ -13,7 +13,7 @@ class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
13
13
  # Creates a new IndentedParagraph containing +parts+ indented with +indent+
14
14
  # spaces
15
15
 
16
- def initialize indent, *parts
16
+ def initialize(indent, *parts)
17
17
  @indent = indent
18
18
 
19
19
  super(*parts)
@@ -37,7 +37,7 @@ class RDoc::Markup::List
37
37
  # Creates a new list of +type+ with +items+. Valid list types are:
38
38
  # +:BULLET+, +:LABEL+, +:LALPHA+, +:NOTE+, +:NUMBER+, +:UALPHA+
39
39
 
40
- def initialize type = nil, *items
40
+ def initialize(type = nil, *items)
41
41
  @type = type
42
42
  @items = []
43
43
  @items.concat items
@@ -94,7 +94,7 @@ class RDoc::Markup::List
94
94
  ##
95
95
  # Appends +items+ to the list
96
96
 
97
- def push *items
97
+ def push(*items)
98
98
  @items.concat items
99
99
  end
100
100
 
@@ -24,7 +24,7 @@ class RDoc::Markup::ListItem
24
24
  ##
25
25
  # Creates a new ListItem with an optional +label+ containing +parts+
26
26
 
27
- def initialize label = nil, *parts
27
+ def initialize(label = nil, *parts)
28
28
  @label = label
29
29
  @parts = []
30
30
  @parts.concat parts
@@ -92,7 +92,7 @@ class RDoc::Markup::ListItem
92
92
  ##
93
93
  # Adds +parts+ to the ListItem
94
94
 
95
- def push *parts
95
+ def push(*parts)
96
96
  @parts.concat parts
97
97
  end
98
98
 
@@ -209,18 +209,6 @@ class RDoc::Markup::PreProcess
209
209
  when 'include' then
210
210
  filename = param.split(' ', 2).first
211
211
  include_file filename, prefix, encoding
212
- when 'main' then
213
- @options.main_page = param if @options.respond_to? :main_page
214
- warn <<~MSG
215
- The :main: directive is deprecated and will be removed in RDoc 7.
216
-
217
- You can use these options to specify the initial page displayed instead:
218
- - `--main=#{param}` via the command line
219
- - `rdoc.main = "#{param}"` if you use `RDoc::Task`
220
- - `main_page: #{param}` in your `.rdoc_options` file
221
- MSG
222
-
223
- blankline
224
212
  when 'nodoc' then
225
213
  return blankline unless code_object
226
214
  code_object.document_self = nil # notify nodoc
@@ -245,19 +233,6 @@ class RDoc::Markup::PreProcess
245
233
 
246
234
  code_object.stop_doc
247
235
 
248
- blankline
249
- when 'title' then
250
- @options.default_title = param if @options.respond_to? :default_title=
251
-
252
- warn <<~MSG
253
- The :title: directive is deprecated and will be removed in RDoc 7.
254
-
255
- You can use these options to specify the title displayed instead:
256
- - `--title=#{param}` via the command line
257
- - `rdoc.title = "#{param}"` if you use `RDoc::Task`
258
- - `title: #{param}` in your `.rdoc_options` file
259
- MSG
260
-
261
236
  blankline
262
237
  when 'yield', 'yields' then
263
238
  return blankline unless code_object
@@ -7,7 +7,7 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
7
7
  ##
8
8
  # Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
9
9
 
10
- def initialize(markup = nil)
10
+ def initialize
11
11
  super
12
12
 
13
13
  @headings.clear
@@ -10,7 +10,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
10
10
  ##
11
11
  # Returns a new ToBs that is ready for hot backspace action!
12
12
 
13
- def initialize(markup = nil)
13
+ def initialize
14
14
  super
15
15
 
16
16
  @in_b = false
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'cgi/escape'
3
3
  require 'cgi/util' unless defined?(CGI::EscapeExt)
4
+ require 'prism'
4
5
 
5
6
  ##
6
7
  # Outputs RDoc markup as HTML.
@@ -40,17 +41,100 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
40
41
 
41
42
  # :section:
42
43
 
44
+ # Maps an encoding to a Hash of characters properly transcoded for that
45
+ # encoding.
46
+ #
47
+ # See also encode_fallback.
48
+
49
+ TO_HTML_CHARACTERS = Hash.new do |h, encoding|
50
+ h[encoding] = {
51
+ close_dquote: encode_fallback('”', encoding, '"'),
52
+ close_squote: encode_fallback('’', encoding, '\''),
53
+ copyright: encode_fallback('©', encoding, '(c)'),
54
+ ellipsis: encode_fallback('…', encoding, '...'),
55
+ dot_ellipsis: encode_fallback('.…', encoding, '....'),
56
+ em_dash: encode_fallback('—', encoding, '---'),
57
+ en_dash: encode_fallback('–', encoding, '--'),
58
+ open_dquote: encode_fallback('“', encoding, '"'),
59
+ open_squote: encode_fallback('‘', encoding, '\''),
60
+ trademark: encode_fallback('®', encoding, '(r)'),
61
+ }
62
+ end
63
+
64
+ HTML_CHARACTER_ALIASES = {
65
+ '(c)' => :copyright,
66
+ '(C)' => :copyright,
67
+ '(r)' => :trademark,
68
+ '(R)' => :trademark,
69
+ '---' => :em_dash,
70
+ '--' => :en_dash,
71
+ '....' => :dot_ellipsis,
72
+ '...' => :ellipsis,
73
+ '``' => :open_dquote,
74
+ "''" => :close_dquote,
75
+ }
76
+
77
+ # Transcodes +character+ to +encoding+ with a +fallback+ character.
78
+
79
+ def self.encode_fallback(character, encoding, fallback)
80
+ character.encode(
81
+ encoding,
82
+ fallback: { character => fallback },
83
+ undef: :replace,
84
+ replace: fallback
85
+ )
86
+ end
87
+
88
+ # Converts ascii quote pairs to multibyte quote characters
89
+ class QuoteConverter
90
+
91
+ def initialize
92
+ @in_dquote = false
93
+ @in_squote = false
94
+ end
95
+
96
+ def convert(quote, after_word:)
97
+ case quote
98
+ when '"'
99
+ type = @in_dquote ? :close_dquote : :open_dquote
100
+ @in_dquote = !@in_dquote
101
+ when "'"
102
+ if @in_squote
103
+ type = :close_squote
104
+ @in_squote = false
105
+ elsif after_word
106
+ # Mary's dog, my parents' house: do not start paired quotes
107
+ type = :close_squote
108
+ else
109
+ type = :open_squote
110
+ @in_squote = true
111
+ end
112
+ when '`'
113
+ # Opening quote of <tt>`quoted sentence'</tt>.
114
+ # This will conflict with code blocks <tt>`puts('hello')`</tt> in the future.
115
+ if !@in_squote && !after_word
116
+ type = :open_squote
117
+ @in_squote = true
118
+ end
119
+ end
120
+ TO_HTML_CHARACTERS[quote.encoding][type] if type
121
+ end
122
+ end
123
+
43
124
  ##
44
125
  # Creates a new formatter that will output HTML
45
126
 
46
- def initialize(options, markup = nil)
47
- super
127
+ def initialize(pipe: false, output_decoration: true)
128
+ super()
48
129
 
130
+ @pipe = pipe
131
+ @output_decoration = output_decoration
49
132
  @code_object = nil
50
133
  @from_path = ''
51
134
  @in_list_entry = nil
52
135
  @list = nil
53
136
  @th = nil
137
+ @quote_converter = nil
54
138
  @in_tidylink_label = false
55
139
  @hard_break = "<br>\n"
56
140
 
@@ -75,6 +159,11 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
75
159
  # suppress crossref: \#method \::method \ClassName \method_with_underscores
76
160
  @markup.add_regexp_handling(/\\(?:[#:A-Z]|[a-z]+_[a-z0-9])/, :SUPPRESSED_CROSSREF)
77
161
 
162
+ @markup.add_regexp_handling(Regexp.union(HTML_CHARACTER_ALIASES.keys), :HTML_CHARACTERS)
163
+
164
+ @markup.add_regexp_handling(/\b['"`]/, :QUOTE_AFTER_WORD)
165
+ @markup.add_regexp_handling(/\B['"`]/, :QUOTE_NOT_AFTER_WORD)
166
+
78
167
  init_link_notation_regexp_handlings
79
168
  end
80
169
 
@@ -227,12 +316,28 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
227
316
 
228
317
  def handle_inline(text) # :nodoc:
229
318
  @inline_output = +''
319
+ @quote_converter = QuoteConverter.new
230
320
  super
231
321
  out = @inline_output
232
322
  @inline_output = nil
323
+ @quote_converter = nil
233
324
  out
234
325
  end
235
326
 
327
+ # Converts <tt>(c), (r), --, --- , ..., ...., ``, ''</tt> to HTML characters.
328
+ def handle_regexp_HTML_CHARACTERS(text)
329
+ name = HTML_CHARACTER_ALIASES[text]
330
+ TO_HTML_CHARACTERS[text.encoding][name] if name
331
+ end
332
+
333
+ def handle_regexp_QUOTE_NOT_AFTER_WORD(text)
334
+ @quote_converter.convert(text, after_word: false) || convert_string(text)
335
+ end
336
+
337
+ def handle_regexp_QUOTE_AFTER_WORD(text)
338
+ @quote_converter.convert(text, after_word: true) || convert_string(text)
339
+ end
340
+
236
341
  # Converts suppressed cross-reference +text+ to HTML by removing the leading backslash.
237
342
 
238
343
  def handle_regexp_SUPPRESSED_CROSSREF(text)
@@ -311,13 +416,22 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
311
416
  def accept_paragraph(paragraph)
312
417
  @res << "\n<p>"
313
418
  text = paragraph.text @hard_break
314
- text = text.gsub(/(#{SPACE_SEPARATED_LETTER_CLASS})?\K\r?\n(?=(?(1)(#{SPACE_SEPARATED_LETTER_CLASS})?))/o) {
419
+ text = text.gsub(/(#{SPACE_SEPARATED_LETTER_CLASS})?\K(?:\r?\n)+(?=(?(1)(#{SPACE_SEPARATED_LETTER_CLASS})?))/o) {
315
420
  defined?($2) && ' '
316
421
  }
317
422
  @res << to_html(text)
318
423
  @res << "</p>\n"
319
424
  end
320
425
 
426
+ # Generate syntax highlighted html for ruby-like text.
427
+
428
+ def parsable_text_to_html(text)
429
+ tokens = RDoc::Parser::RubyColorizer.colorize(text)
430
+ result = RDoc::TokenStream.to_html tokens
431
+ result = result + "\n" unless result.end_with?("\n")
432
+ result
433
+ end
434
+
321
435
  ##
322
436
  # Adds +verbatim+ to the output
323
437
 
@@ -325,29 +439,19 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
325
439
  text = verbatim.text.rstrip
326
440
  format = verbatim.format
327
441
 
328
- klass = nil
329
-
330
442
  # Apply Ruby syntax highlighting if
331
443
  # - explicitly marked as Ruby (via ruby? which accepts :ruby or :rb)
332
444
  # - no format specified but the text is parseable as Ruby
333
445
  # Otherwise, add language class when applicable and skip Ruby highlighting
334
- content = if verbatim.ruby? || (format.nil? && parseable?(text))
335
- begin
336
- tokens = RDoc::Parser::RipperStateLex.parse text
337
- klass = ' class="ruby"'
338
-
339
- result = RDoc::TokenStream.to_html tokens
340
- result = result + "\n" unless "\n" == result[-1]
341
- result
342
- rescue
343
- CGI.escapeHTML text
344
- end
345
- else
346
- klass = " class=\"#{format}\"" if format
347
- CGI.escapeHTML text
348
- end
349
-
350
- if @options.pipe then
446
+ if verbatim.ruby? || (format.nil? && parseable?(text))
447
+ content = parsable_text_to_html(text)
448
+ klass = ' class="ruby"'
449
+ else
450
+ content = CGI.escapeHTML text
451
+ klass = " class=\"#{format}\"" if format
452
+ end
453
+
454
+ if @pipe
351
455
  @res << "\n<pre><code>#{CGI.escapeHTML text}\n</code></pre>\n"
352
456
  else
353
457
  @res << "\n<pre#{klass}>#{content}</pre>\n"
@@ -418,17 +522,17 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
418
522
 
419
523
  # Add legacy anchor before the heading for backward compatibility.
420
524
  # This allows old links with label- prefix to still work.
421
- if @options.output_decoration && !@options.pipe
525
+ if @output_decoration && !@pipe
422
526
  @res << "\n<span id=\"#{legacy_label}\" class=\"legacy-anchor\"></span>"
423
527
  end
424
528
 
425
- @res << if @options.output_decoration
529
+ @res << if @output_decoration
426
530
  "\n<h#{level} id=\"#{label}\">"
427
531
  else
428
532
  "\n<h#{level}>"
429
533
  end
430
534
 
431
- if @options.pipe
535
+ if @pipe
432
536
  @res << to_html(heading.text)
433
537
  else
434
538
  @res << "<a href=\"##{label}\">#{to_html(heading.text)}</a>"
@@ -566,39 +670,13 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
566
670
  # Returns true if text is valid ruby syntax
567
671
 
568
672
  def parseable?(text)
569
- verbose, $VERBOSE = $VERBOSE, nil
570
- catch(:valid) do
571
- eval("BEGIN { throw :valid, true }\n#{text}")
572
- end
573
- rescue SyntaxError
574
- false
575
- ensure
576
- $VERBOSE = verbose
673
+ Prism.parse_success?(text)
577
674
  end
578
675
 
579
676
  ##
580
677
  # Converts +item+ to HTML using RDoc::Text#to_html
581
678
 
582
679
  def to_html(item)
583
- # Ideally, we should convert html characters at handle_PLAIN_TEXT or somewhere else,
584
- # but we need to convert it here for now because to_html_characters converts pair of backticks to ’‘ and pair of double backticks to ”“.
585
- # Known bugs: `...` in `<code>def f(...); end</code>` and `(c) in `<a href="(c)">` will be wrongly converted.
586
- to_html_characters(handle_inline(item))
587
- end
588
- end
589
-
590
- ##
591
- # Formatter dedicated to rendering tidy link labels without mutating the
592
- # calling formatter's state.
593
-
594
- class RDoc::Markup::LinkLabelToHtml < RDoc::Markup::ToHtml
595
- def self.render(label, options, from_path)
596
- new(options, from_path).to_html(label)
597
- end
598
-
599
- def initialize(options, from_path = nil)
600
- super(options)
601
-
602
- self.from_path = from_path if from_path
680
+ handle_inline(item)
603
681
  end
604
682
  end