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
@@ -89,12 +89,21 @@ class RDoc::Markup::AttributeManager
89
89
  add_word_pair "*", "*", :BOLD, true
90
90
  add_word_pair "_", "_", :EM, true
91
91
  add_word_pair "+", "+", :TT, true
92
+ add_word_pair "`", "`", :TT, true
92
93
 
93
94
  add_html "em", :EM, true
94
95
  add_html "i", :EM, true
95
96
  add_html "b", :BOLD, true
96
97
  add_html "tt", :TT, true
97
98
  add_html "code", :TT, true
99
+ add_html "s", :STRIKE, true
100
+ add_html "del", :STRIKE, true
101
+
102
+ @word_pair_chars = @matching_word_pairs.keys.join
103
+
104
+ # Matches a word pair delimiter (*, _, +, `) that is NOT already protected.
105
+ # Used by #protect_code_markup to escape delimiters inside <code>/<tt> tags.
106
+ @unprotected_word_pair_regexp = /([#{@word_pair_chars}])(?!#{PROTECT_ATTR})/
98
107
  end
99
108
 
100
109
  ##
@@ -164,7 +173,7 @@ class RDoc::Markup::AttributeManager
164
173
  }.keys
165
174
  return if tags.empty?
166
175
  tags = "[#{tags.join("")}](?!#{PROTECT_ATTR})"
167
- all_tags = "[#{@matching_word_pairs.keys.join("")}](?!#{PROTECT_ATTR})"
176
+ all_tags = "[#{@word_pair_chars}](?!#{PROTECT_ATTR})"
168
177
 
169
178
  re = /(?:^|\W|#{all_tags})\K(#{tags})(\1*[#\\]?[\w:#{PROTECT_ATTR}.\/\[\]-]+?\S?)\1(?!\1)(?=#{all_tags}|\W|$)/
170
179
 
@@ -245,6 +254,23 @@ class RDoc::Markup::AttributeManager
245
254
  @str.gsub!(/\\(\\[#{Regexp.escape @protectable.join}])/m, "\\1")
246
255
  end
247
256
 
257
+ ##
258
+ # Protects word pair delimiters (*, _, +) inside
259
+ # <code> and <tt> tags from being processed as inline formatting.
260
+ # For example, *bold* in +*bold*+ will NOT be rendered as bold.
261
+
262
+ def protect_code_markup
263
+ @str.gsub!(/<(code|tt)>(.*?)<\/\1>/im) do
264
+ tag = $1
265
+ content = $2
266
+ # Protect word pair delimiters (*, _, +) from being processed
267
+ escaped = content.gsub(@unprotected_word_pair_regexp, "\\1#{PROTECT_ATTR}")
268
+ # Protect HTML-like tags from being processed (e.g., <del> inside code)
269
+ escaped = escaped.gsub(/<(?!#{PROTECT_ATTR})/, "<#{PROTECT_ATTR}")
270
+ "<#{tag}>#{escaped}</#{tag}>"
271
+ end
272
+ end
273
+
248
274
  ##
249
275
  # Unescapes regexp handling sequences of text
250
276
 
@@ -308,6 +334,7 @@ class RDoc::Markup::AttributeManager
308
334
  @str = str.dup
309
335
 
310
336
  mask_protected_sequences
337
+ protect_code_markup
311
338
 
312
339
  @attrs = RDoc::Markup::AttrSpan.new @str.length, @exclusive_bitmap
313
340
 
@@ -1,27 +1,29 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # An empty line. This class is a singleton.
4
2
 
5
- class RDoc::Markup::BlankLine
6
-
7
- @instance = new
8
-
9
- ##
10
- # RDoc::Markup::BlankLine is a singleton
11
-
12
- def self.new
13
- @instance
3
+ module RDoc
4
+ class Markup
5
+ # An empty line
6
+ class BlankLine < Element
7
+ @instance = new
8
+
9
+ # RDoc::Markup::BlankLine is a singleton
10
+ #: () -> BlankLine
11
+ def self.new
12
+ @instance
13
+ end
14
+
15
+ # Calls #accept_blank_line on +visitor+
16
+ # @override
17
+ #: (untyped) -> void
18
+ def accept(visitor)
19
+ visitor.accept_blank_line(self)
20
+ end
21
+
22
+ # @override
23
+ #: (PP) -> void
24
+ def pretty_print(q) # :nodoc:
25
+ q.text("blankline")
26
+ end
27
+ end
14
28
  end
15
-
16
- ##
17
- # Calls #accept_blank_line on +visitor+
18
-
19
- def accept(visitor)
20
- visitor.accept_blank_line self
21
- end
22
-
23
- def pretty_print(q) # :nodoc:
24
- q.text 'blankline'
25
- end
26
-
27
29
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RDoc
4
+ class Markup
5
+ # Base class defining the interface for all markup elements found in documentation
6
+ # @abstract
7
+ class Element
8
+ # @abstract
9
+ #: (untyped) -> void
10
+ def accept(visitor)
11
+ raise NotImplementedError, "#{self.class} must implement the accept method"
12
+ end
13
+
14
+ # @abstract
15
+ #: (PP) -> void
16
+ def pretty_print(q)
17
+ raise NotImplementedError, "#{self.class} must implement the pretty_print method"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,31 +1,34 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A hard-break in the middle of a paragraph.
4
2
 
5
- class RDoc::Markup::HardBreak
6
-
7
- @instance = new
8
-
9
- ##
10
- # RDoc::Markup::HardBreak is a singleton
11
-
12
- def self.new
13
- @instance
14
- end
15
-
16
- ##
17
- # Calls #accept_hard_break on +visitor+
18
-
19
- def accept(visitor)
20
- visitor.accept_hard_break self
3
+ module RDoc
4
+ class Markup
5
+ # A hard-break in the middle of a paragraph.
6
+ class HardBreak < Element
7
+ @instance = new
8
+
9
+ # RDoc::Markup::HardBreak is a singleton
10
+ #: () -> HardBreak
11
+ def self.new
12
+ @instance
13
+ end
14
+
15
+ # Calls #accept_hard_break on +visitor+
16
+ # @override
17
+ #: (untyped) -> void
18
+ def accept(visitor)
19
+ visitor.accept_hard_break(self)
20
+ end
21
+
22
+ #: (top) -> bool
23
+ def ==(other) # :nodoc:
24
+ self.class === other
25
+ end
26
+
27
+ # @override
28
+ #: (PP) -> void
29
+ def pretty_print(q) # :nodoc:
30
+ q.text("[break]")
31
+ end
32
+ end
21
33
  end
22
-
23
- def ==(other) # :nodoc:
24
- self.class === other
25
- end
26
-
27
- def pretty_print(q) # :nodoc:
28
- q.text "[break]"
29
- end
30
-
31
34
  end
@@ -1,84 +1,173 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A heading with a level (1-6) and text
4
2
 
5
- RDoc::Markup::Heading =
6
- Struct.new :level, :text do
7
-
8
- @to_html = nil
9
- @to_label = nil
10
-
11
- ##
12
- # A singleton RDoc::Markup::ToLabel formatter for headings.
13
-
14
- def self.to_label
15
- @to_label ||= RDoc::Markup::ToLabel.new
16
- end
17
-
18
- ##
19
- # A singleton plain HTML formatter for headings. Used for creating labels
20
- # for the Table of Contents
21
-
22
- def self.to_html
23
- return @to_html if @to_html
24
-
25
- markup = RDoc::Markup.new
26
- markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
27
-
28
- @to_html = RDoc::Markup::ToHtml.new nil
29
-
30
- def @to_html.handle_regexp_CROSSREF(target)
31
- target.text.sub(/^\\/, '')
3
+ module RDoc
4
+ class Markup
5
+ # IMPORTANT! This weird workaround is required to ensure that RDoc can correctly deserializing Marshal data from
6
+ # older rubies. Older rubies have `Heading` as a struct, so if we change it to a class, deserialization fails
7
+ if RUBY_VERSION.start_with?("4.")
8
+ class Heading < Element
9
+ #: String
10
+ attr_reader :text
11
+
12
+ #: Integer
13
+ attr_accessor :level
14
+
15
+ #: (Integer, String) -> void
16
+ def initialize(level, text)
17
+ super()
18
+
19
+ @level = level
20
+ @text = text
21
+ end
22
+
23
+ #: (Object) -> bool
24
+ def ==(other)
25
+ other.is_a?(Heading) && other.level == @level && other.text == @text
26
+ end
27
+ end
28
+ else
29
+ Heading = Struct.new(:level, :text)
32
30
  end
33
31
 
34
- @to_html
35
- end
36
-
37
- ##
38
- # Calls #accept_heading on +visitor+
39
-
40
- def accept(visitor)
41
- visitor.accept_heading self
42
- end
43
-
44
- ##
45
- # An HTML-safe anchor reference for this header.
46
-
47
- def aref
48
- "label-#{self.class.to_label.convert text.dup}"
49
- end
50
-
51
- ##
52
- # Creates a fully-qualified label which will include the label from
53
- # +context+. This helps keep ids unique in HTML.
54
-
55
- def label(context = nil)
56
- label = aref
57
-
58
- label = [context.aref, label].compact.join '-' if
59
- context and context.respond_to? :aref
60
-
61
- label
62
- end
63
-
64
- ##
65
- # HTML markup of the text of this label without the surrounding header
66
- # element.
67
-
68
- def plain_html
69
- text = self.text.dup
70
-
71
- if matched = text.match(/rdoc-image:[^:]+:(.*)/)
72
- text = matched[1]
32
+ # A heading with a level (1-6) and text
33
+ #
34
+ # RDoc syntax:
35
+ # = Heading 1
36
+ # == Heading 2
37
+ # === Heading 3
38
+ #
39
+ # Markdown syntax:
40
+ # # Heading 1
41
+ # ## Heading 2
42
+ # ### Heading 3
43
+ #
44
+ class Heading
45
+ # A singleton RDoc::Markup::ToLabel formatter for headings.
46
+ #: () -> RDoc::Markup::ToLabel
47
+ def self.to_label
48
+ @to_label ||= Markup::ToLabel.new
49
+ end
50
+
51
+ # A singleton plain HTML formatter for headings. Used for creating labels for the Table of Contents
52
+ #: () -> RDoc::Markup::ToHtml
53
+ def self.to_html
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
59
+
60
+ def to_html.handle_regexp_CROSSREF(target)
61
+ target.text.sub(/^\\/, '')
62
+ end
63
+
64
+ to_html
65
+ end
66
+ end
67
+
68
+ # @override
69
+ #: (untyped) -> void
70
+ def accept(visitor)
71
+ visitor.accept_heading(self)
72
+ end
73
+
74
+ # An HTML-safe anchor reference for this header using GitHub-style formatting:
75
+ # - Lowercase
76
+ # - Spaces converted to hyphens
77
+ # - Special characters removed (except hyphens)
78
+ #
79
+ # Examples:
80
+ # "Hello" -> "hello"
81
+ # "Hello World" -> "hello-world"
82
+ # "Foo Bar Baz" -> "foo-bar-baz"
83
+ #
84
+ #: () -> String
85
+ def aref
86
+ self.class.to_label.convert text.dup
87
+ end
88
+
89
+ # An HTML-safe anchor reference using legacy RDoc formatting:
90
+ # - Prefixed with "label-"
91
+ # - Original case preserved
92
+ # - Spaces converted to + (URL encoding style)
93
+ # - Special characters percent-encoded
94
+ #
95
+ # Returns nil if it would be the same as the GitHub-style aref (no alias needed).
96
+ #
97
+ # Examples:
98
+ # "hello" -> "label-hello" (different due to label- prefix)
99
+ # "Hello" -> "label-Hello"
100
+ # "Hello World" -> "label-Hello+World"
101
+ # "Foo Bar Baz" -> "label-Foo+Bar+Baz"
102
+ #
103
+ #: () -> String?
104
+ def legacy_aref
105
+ "label-#{self.class.to_label.convert_legacy text.dup}"
106
+ end
107
+
108
+ # Creates a fully-qualified label (GitHub-style) which includes the context's aref prefix.
109
+ # This helps keep IDs unique in HTML when headings appear within class/method documentation.
110
+ #
111
+ # Examples (without context):
112
+ # "Hello World" -> "hello-world"
113
+ #
114
+ # Examples (with context being class Foo):
115
+ # "Hello World" -> "class-foo-hello-world"
116
+ #
117
+ # Examples (with context being method #bar):
118
+ # "Hello World" -> "method-i-bar-hello-world"
119
+ #
120
+ #: (RDoc::Context?) -> String
121
+ def label(context = nil)
122
+ result = +""
123
+ result << "#{context.aref}-" if context&.respond_to?(:aref)
124
+ result << aref
125
+ result
126
+ end
127
+
128
+ # Creates a fully-qualified legacy label for backward compatibility.
129
+ # This is used to generate a secondary ID attribute on the heading's inner anchor,
130
+ # allowing old-style links (e.g., #label-Hello+World) to continue working.
131
+ #
132
+ # Examples (without context):
133
+ # "hello" -> "label-hello"
134
+ # "Hello World" -> "label-Hello+World"
135
+ #
136
+ # Examples (with context being class Foo):
137
+ # "hello" -> "class-Foo-label-hello"
138
+ # "Hello World" -> "class-Foo-label-Hello+World"
139
+ #
140
+ #: (RDoc::Context?) -> String
141
+ def legacy_label(context = nil)
142
+ result = +""
143
+ if context&.respond_to?(:legacy_aref)
144
+ result << "#{context.legacy_aref}-"
145
+ elsif context&.respond_to?(:aref)
146
+ result << "#{context.aref}-"
147
+ end
148
+ result << legacy_aref
149
+ result
150
+ end
151
+
152
+ # HTML markup of the text of this label without the surrounding header element.
153
+ #: () -> String
154
+ def plain_html
155
+ no_image_text = text
156
+
157
+ if matched = no_image_text.match(/rdoc-image:[^:]+:(.*)/)
158
+ no_image_text = matched[1]
159
+ end
160
+
161
+ self.class.to_html.to_html(no_image_text)
162
+ end
163
+
164
+ # @override
165
+ #: (PP) -> void
166
+ def pretty_print(q)
167
+ q.group 2, "[head: #{level} ", ']' do
168
+ q.pp text
169
+ end
170
+ end
73
171
  end
74
-
75
- self.class.to_html.to_html(text)
76
172
  end
77
-
78
- def pretty_print(q) # :nodoc:
79
- q.group 2, "[head: #{level} ", ']' do
80
- q.pp text
81
- end
82
- end
83
-
84
173
  end
@@ -97,18 +97,15 @@ class RDoc::Markup::PreProcess
97
97
  # RDoc::CodeObject#metadata for details.
98
98
 
99
99
  def handle(text, code_object = nil, &block)
100
- first_line = 1
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
  ##
@@ -151,7 +175,7 @@ class RDoc::Markup::PreProcess
151
175
  # When 1.8.7 support is ditched prefix can be defaulted to ''
152
176
 
153
177
  def handle_directive(prefix, directive, param, code_object = nil,
154
- encoding = nil, line = 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
@@ -1,69 +1,66 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A section of text that is added to the output document as-is
4
2
 
5
- class RDoc::Markup::Raw
6
-
7
- ##
8
- # The component parts of the list
9
-
10
- attr_reader :parts
11
-
12
- ##
13
- # Creates a new Raw containing +parts+
14
-
15
- def initialize *parts
16
- @parts = []
17
- @parts.concat parts
18
- end
19
-
20
- ##
21
- # Appends +text+
3
+ module RDoc
4
+ class Markup
5
+ # A section of text that is added to the output document as-is
6
+ class Raw
7
+ # The component parts of the list
8
+ #: Array[String]
9
+ attr_reader :parts
10
+
11
+ # Creates a new Raw containing +parts+
12
+ #: (*String) -> void
13
+ def initialize(*parts)
14
+ @parts = parts
15
+ end
22
16
 
23
- def <<(text)
24
- @parts << text
25
- end
17
+ # Appends +text+
18
+ #: (String) -> void
19
+ def <<(text)
20
+ @parts << text
21
+ end
26
22
 
27
- def ==(other) # :nodoc:
28
- self.class == other.class and @parts == other.parts
29
- end
23
+ #: (top) -> bool
24
+ def ==(other) # :nodoc:
25
+ self.class == other.class && @parts == other.parts
26
+ end
30
27
 
31
- ##
32
- # Calls #accept_raw+ on +visitor+
28
+ # Calls #accept_raw+ on +visitor+
29
+ # @override
30
+ #: (untyped) -> void
31
+ def accept(visitor)
32
+ visitor.accept_raw(self)
33
+ end
33
34
 
34
- def accept(visitor)
35
- visitor.accept_raw self
36
- end
35
+ # Appends +other+'s parts
36
+ #: (Raw) -> void
37
+ def merge(other)
38
+ @parts.concat(other.parts)
39
+ end
37
40
 
38
- ##
39
- # Appends +other+'s parts
41
+ # @override
42
+ #: (PP) -> void
43
+ def pretty_print(q) # :nodoc:
44
+ self.class.name =~ /.*::(\w{1,4})/i
40
45
 
41
- def merge(other)
42
- @parts.concat other.parts
43
- end
46
+ q.group(2, "[#{$1.downcase}: ", ']') do
47
+ q.seplist(@parts) do |part|
48
+ q.pp(part)
49
+ end
50
+ end
51
+ end
44
52
 
45
- def pretty_print(q) # :nodoc:
46
- self.class.name =~ /.*::(\w{1,4})/i
53
+ # Appends +texts+ onto this Paragraph
54
+ #: (*String) -> void
55
+ def push(*texts)
56
+ self.parts.concat(texts)
57
+ end
47
58
 
48
- q.group 2, "[#{$1.downcase}: ", ']' do
49
- q.seplist @parts do |part|
50
- q.pp part
59
+ # The raw text
60
+ #: () -> String
61
+ def text
62
+ @parts.join(" ")
51
63
  end
52
64
  end
53
65
  end
54
-
55
- ##
56
- # Appends +texts+ onto this Paragraph
57
-
58
- def push *texts
59
- self.parts.concat texts
60
- end
61
-
62
- ##
63
- # The raw text
64
-
65
- def text
66
- @parts.join ' '
67
- end
68
-
69
66
  end