rdoc 7.2.0 → 8.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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +4 -7
  3. data/LICENSE.rdoc +4 -0
  4. data/README.md +43 -2
  5. data/RI.md +75 -75
  6. data/doc/markup_reference/markdown.md +104 -3
  7. data/exe/rdoc +2 -2
  8. data/lib/rdoc/code_object/alias.rb +70 -74
  9. data/lib/rdoc/code_object/any_method.rb +305 -298
  10. data/lib/rdoc/code_object/attr.rb +150 -143
  11. data/lib/rdoc/code_object/class_module.rb +801 -765
  12. data/lib/rdoc/code_object/constant.rb +178 -150
  13. data/lib/rdoc/code_object/context/section.rb +133 -160
  14. data/lib/rdoc/code_object/context.rb +925 -952
  15. data/lib/rdoc/code_object/extend.rb +7 -5
  16. data/lib/rdoc/code_object/include.rb +7 -5
  17. data/lib/rdoc/code_object/method_attr.rb +325 -324
  18. data/lib/rdoc/code_object/mixin.rb +97 -95
  19. data/lib/rdoc/code_object/normal_class.rb +77 -78
  20. data/lib/rdoc/code_object/normal_module.rb +61 -59
  21. data/lib/rdoc/code_object/require.rb +23 -39
  22. data/lib/rdoc/code_object/single_class.rb +21 -19
  23. data/lib/rdoc/code_object/top_level.rb +212 -213
  24. data/lib/rdoc/code_object.rb +305 -305
  25. data/lib/rdoc/comment.rb +274 -337
  26. data/lib/rdoc/cross_reference.rb +194 -212
  27. data/lib/rdoc/encoding.rb +105 -103
  28. data/lib/rdoc/erb_partial.rb +13 -11
  29. data/lib/rdoc/erbio.rb +29 -27
  30. data/lib/rdoc/generator/aliki.rb +165 -140
  31. data/lib/rdoc/generator/darkfish.rb +647 -631
  32. data/lib/rdoc/generator/json_index.rb +233 -229
  33. data/lib/rdoc/generator/markup.rb +165 -122
  34. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  35. data/lib/rdoc/generator/pot/po.rb +52 -51
  36. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  37. data/lib/rdoc/generator/pot.rb +85 -81
  38. data/lib/rdoc/generator/ri.rb +23 -19
  39. data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
  40. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
  41. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  42. data/lib/rdoc/generator/template/aliki/_head.rhtml +11 -11
  43. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  44. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
  45. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
  46. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
  47. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +2 -2
  48. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  49. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
  50. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
  51. data/lib/rdoc/generator/template/aliki/class.rhtml +56 -46
  52. data/lib/rdoc/generator/template/aliki/css/rdoc.css +538 -283
  53. data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
  54. data/lib/rdoc/generator/template/aliki/js/aliki.js +80 -102
  55. data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
  56. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
  57. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
  58. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  59. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
  60. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
  61. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
  62. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
  63. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
  64. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
  65. data/lib/rdoc/generator/template/darkfish/class.rhtml +18 -21
  66. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +0 -1
  67. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  68. data/lib/rdoc/generator.rb +48 -46
  69. data/lib/rdoc/i18n/locale.rb +99 -95
  70. data/lib/rdoc/i18n/text.rb +109 -105
  71. data/lib/rdoc/i18n.rb +7 -5
  72. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  73. data/lib/rdoc/markdown.kpeg +30 -21
  74. data/lib/rdoc/markdown.rb +329 -151
  75. data/lib/rdoc/markup/block_quote.rb +12 -8
  76. data/lib/rdoc/markup/document.rb +127 -123
  77. data/lib/rdoc/markup/formatter.rb +215 -221
  78. data/lib/rdoc/markup/heading.rb +1 -4
  79. data/lib/rdoc/markup/include.rb +33 -29
  80. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  81. data/lib/rdoc/markup/inline_parser.rb +281 -277
  82. data/lib/rdoc/markup/list.rb +80 -88
  83. data/lib/rdoc/markup/list_item.rb +73 -85
  84. data/lib/rdoc/markup/paragraph.rb +23 -19
  85. data/lib/rdoc/markup/parser.rb +501 -497
  86. data/lib/rdoc/markup/pre_process.rb +284 -305
  87. data/lib/rdoc/markup/raw.rb +2 -2
  88. data/lib/rdoc/markup/rule.rb +16 -12
  89. data/lib/rdoc/markup/to_ansi.rb +143 -139
  90. data/lib/rdoc/markup/to_bs.rb +72 -68
  91. data/lib/rdoc/markup/to_html.rb +600 -493
  92. data/lib/rdoc/markup/to_html_crossref.rb +221 -191
  93. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  94. data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
  95. data/lib/rdoc/markup/to_label.rb +63 -59
  96. data/lib/rdoc/markup/to_markdown.rb +212 -208
  97. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  98. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  99. data/lib/rdoc/markup/to_test.rb +60 -56
  100. data/lib/rdoc/markup/to_tt_only.rb +83 -86
  101. data/lib/rdoc/markup/verbatim.rb +62 -58
  102. data/lib/rdoc/markup.rb +198 -196
  103. data/lib/rdoc/options.rb +1063 -1076
  104. data/lib/rdoc/parser/c.rb +1039 -1036
  105. data/lib/rdoc/parser/changelog.rb +319 -315
  106. data/lib/rdoc/parser/markdown.rb +17 -13
  107. data/lib/rdoc/parser/rbs.rb +279 -0
  108. data/lib/rdoc/parser/rd.rb +17 -13
  109. data/lib/rdoc/parser/ruby.rb +1231 -2222
  110. data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
  111. data/lib/rdoc/parser/simple.rb +31 -27
  112. data/lib/rdoc/parser/text.rb +12 -8
  113. data/lib/rdoc/parser.rb +230 -221
  114. data/lib/rdoc/rbs_helper.rb +186 -0
  115. data/lib/rdoc/rd/inline.rb +57 -53
  116. data/lib/rdoc/rd.rb +90 -88
  117. data/lib/rdoc/rdoc.rb +547 -366
  118. data/lib/rdoc/ri/driver.rb +1141 -1130
  119. data/lib/rdoc/ri/formatter.rb +7 -3
  120. data/lib/rdoc/ri/paths.rb +140 -136
  121. data/lib/rdoc/ri/servlet.rb +456 -0
  122. data/lib/rdoc/ri/store.rb +4 -2
  123. data/lib/rdoc/ri/task.rb +55 -51
  124. data/lib/rdoc/ri.rb +14 -11
  125. data/lib/rdoc/rubygems_hook.rb +194 -192
  126. data/lib/rdoc/server.rb +462 -0
  127. data/lib/rdoc/stats/normal.rb +46 -42
  128. data/lib/rdoc/stats/quiet.rb +39 -35
  129. data/lib/rdoc/stats/verbose.rb +35 -31
  130. data/lib/rdoc/stats.rb +363 -338
  131. data/lib/rdoc/store.rb +919 -725
  132. data/lib/rdoc/task.rb +260 -255
  133. data/lib/rdoc/text.rb +130 -245
  134. data/lib/rdoc/token_stream.rb +101 -115
  135. data/lib/rdoc/tom_doc.rb +203 -201
  136. data/lib/rdoc/version.rb +1 -1
  137. data/lib/rdoc.rb +35 -7
  138. data/lib/rubygems_plugin.rb +2 -11
  139. data/rdoc-logo.svg +43 -0
  140. data/rdoc.gemspec +6 -4
  141. metadata +36 -20
  142. data/lib/rdoc/code_object/anon_class.rb +0 -10
  143. data/lib/rdoc/code_object/ghost_method.rb +0 -6
  144. data/lib/rdoc/code_object/meta_method.rb +0 -6
  145. data/lib/rdoc/markdown/literals.kpeg +0 -21
  146. data/lib/rdoc/markdown/literals.rb +0 -454
  147. data/lib/rdoc/parser/prism_ruby.rb +0 -1112
  148. data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
  149. data/lib/rdoc/parser/ruby_tools.rb +0 -163
  150. data/lib/rdoc/servlet.rb +0 -452
@@ -0,0 +1,303 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'prism'
4
+ require 'set'
5
+
6
+ module RDoc
7
+ class Parser
8
+ # Ruby code syntax highlighter.
9
+ # Colorize result is an array of +RDoc::Parser::RubyColorizer::ColoredToken+
10
+ # Actual color for each token kind is determined elsewhere (e.g., HTML generator)
11
+ module RubyColorizer
12
+
13
+ ColoredToken = Struct.new(:kind, :text)
14
+
15
+ # Defers colorization for all nodes in one source file until first access.
16
+ class DeferredContext # :nodoc:
17
+ #: (String) -> void
18
+ def initialize(source)
19
+ @source = source
20
+ @token_streams = {}
21
+ end
22
+
23
+ #: (Integer) -> ^() -> Array[ColoredToken]
24
+ def token_stream_loader(node_id)
25
+ @token_streams[node_id] = nil
26
+ -> { token_stream_for(node_id) }
27
+ end
28
+
29
+ #: (Integer) -> Array[ColoredToken]
30
+ def token_stream_for(node_id)
31
+ materialize unless materialized?
32
+ @token_streams.fetch(node_id)
33
+ end
34
+
35
+ private
36
+
37
+ #: () -> Boolean
38
+ def materialized?
39
+ !@source
40
+ end
41
+
42
+ #: () -> void
43
+ def materialize
44
+ program_node, unordered_tokens = Prism.parse_lex(@source).value
45
+ prism_tokens = unordered_tokens.map(&:first).sort_by! { |token| token.location.start_offset }
46
+ staged_tokens = {}
47
+ nodes = [program_node]
48
+ until nodes.empty?
49
+ node = nodes.pop
50
+ if @token_streams.key?(node.node_id)
51
+ staged_tokens[node.node_id] = RubyColorizer.partial_colorize(@source, node, prism_tokens)
52
+ end
53
+ nodes.concat(node.compact_child_nodes)
54
+ end
55
+
56
+ @token_streams = staged_tokens
57
+ @source = nil
58
+ end
59
+ end
60
+
61
+ # Prism operator token types except assignment '='
62
+ OP_TOKENS = %i[
63
+ AMPERSAND AMPERSAND_AMPERSAND
64
+ BANG BANG_EQUAL BANG_TILDE CARET COLON COLON_COLON
65
+ EQUAL_EQUAL EQUAL_GREATER EQUAL_TILDE
66
+ GREATER GREATER_GREATER
67
+ LESS LESS_EQUAL LESS_EQUAL_GREATER LESS_LESS
68
+ MINUS MINUS_GREATER PERCENT PIPE PIPE_PIPE PLUS
69
+ QUESTION_MARK SLASH STAR STAR_STAR TILDE
70
+ UAMPERSAND UMINUS UPLUS USTAR USTAR_STAR
71
+ ].to_set
72
+
73
+ # Prism token type to ColoredToken kind map
74
+ TOKEN_TYPE_MAP = {
75
+ IDENTIFIER: :identifier,
76
+ METHOD_NAME: :identifier,
77
+ INSTANCE_VARIABLE: :ivar,
78
+ CLASS_VARIABLE: :identifier,
79
+ GLOBAL_VARIABLE: :identifier,
80
+ BACK_REFERENCE: :identifier,
81
+ NUMBERED_REFERENCE: :identifier,
82
+ CONSTANT: :constant,
83
+ LABEL: :value,
84
+ INTEGER: :value,
85
+ INTEGER_IMAGINARY: :value,
86
+ INTEGER_RATIONAL: :value,
87
+ INTEGER_RATIONAL_IMAGINARY: :value,
88
+ FLOAT: :value,
89
+ FLOAT_IMAGINARY: :value,
90
+ FLOAT_RATIONAL: :value,
91
+ FLOAT_RATIONAL_IMAGINARY: :value,
92
+ COMMENT: :comment,
93
+ EMBDOC_BEGIN: :comment,
94
+ EMBDOC_LINE: :comment,
95
+ EMBDOC_END: :comment
96
+ }
97
+
98
+ class << self
99
+
100
+ # Colorize the entire +code+ and returns colored token stream.
101
+ def colorize(code)
102
+ result = Prism.parse_lex(code)
103
+ program_node, unordered_tokens = result.value
104
+ prism_tokens = unordered_tokens.map(&:first).sort_by! { |token| token.location.start_offset }
105
+ partial_colorize(code, program_node, prism_tokens, 0, code.bytesize)
106
+ end
107
+
108
+ # Colorize partial +node+ in +whole_code+ and returns colored token stream.
109
+ def partial_colorize(whole_code, node, prism_tokens, start_offset = nil, end_offset = nil)
110
+ start_offset ||= node.location.start_offset
111
+ end_offset ||= node.location.end_offset
112
+ visitor = NodeColorizeVisitor.new
113
+ node.accept(visitor)
114
+ prior_tokens = visitor.tokens.sort_by {|_, start_offset, _| start_offset }
115
+ normal_tokens = normal_tokens(slice_by_location(prism_tokens, start_offset, end_offset))
116
+ colored_tokens = unify_tokens(whole_code, prior_tokens, normal_tokens, start_offset, end_offset)
117
+ colored_tokens.unshift(ColoredToken.new(:plain, ' ' * node.location.start_column)) if node.location.start_column > 0
118
+ colored_tokens
119
+ end
120
+
121
+ private
122
+
123
+ def slice_by_location(items, start_offset, end_offset)
124
+ start_index = items.bsearch_index { |item| item.location.end_offset > start_offset } || items.size
125
+ end_index = items.bsearch_index { |item| item.location.start_offset >= end_offset } || items.size
126
+ items[start_index...end_index]
127
+ end
128
+
129
+ # Unify prior tokens and normal tokens into a single token stream.
130
+ # Prior tokens have higher priority than normal tokens.
131
+ # Also adds missing text (spaces, newlines, etc.) as :plain tokens
132
+ # so that the entire range is covered.
133
+ def unify_tokens(whole_code, prior_tokens, normal_tokens, start_offset, end_offset)
134
+ tokens = []
135
+ offset = start_offset
136
+
137
+ # Add missing text such as spaces and newlines as a separate :plain token
138
+ flush = -> next_offset {
139
+ return if offset == next_offset
140
+
141
+ whole_code.byteslice(offset...next_offset).scan(/\n|\s+|[^\s]+/) do |text|
142
+ tokens << ColoredToken.new(:plain, text)
143
+ end
144
+ }
145
+
146
+ until prior_tokens.empty? && normal_tokens.empty?
147
+ ptok = prior_tokens.first
148
+ ntok = normal_tokens.first
149
+ if ntok && (!ptok || ntok[2] <= ptok[1])
150
+ token = normal_tokens.shift
151
+ else
152
+ token = prior_tokens.shift
153
+ end
154
+ kind, start_pos, end_pos = token
155
+ next if start_pos < offset
156
+
157
+ flush.call(start_pos)
158
+ tokens << ColoredToken.new(kind, whole_code.byteslice(start_pos...end_pos))
159
+ offset = end_pos
160
+ end
161
+ flush.call(end_offset)
162
+ tokens
163
+ end
164
+
165
+ # Convert normal Prism tokens to [kind, start_offset, end_offset]
166
+ def normal_tokens(tokens)
167
+ tokens.map do |token,|
168
+ kind =
169
+ if token.type.start_with?('KEYWORD_')
170
+ :keyword
171
+ elsif OP_TOKENS.include?(token.type.to_sym)
172
+ :operator
173
+ else
174
+ TOKEN_TYPE_MAP[token.type] || :plain
175
+ end
176
+ [kind, token.location.start_offset, token.location.end_offset]
177
+ end
178
+ end
179
+ end
180
+
181
+ # Visitor to determine node colorizing which can't be determined by tokens.
182
+ # STRING_CONTENT/EMBEXPR_BEGIN/EMBEXPR_END in string/regexp/symbol have different colorizing
183
+ class NodeColorizeVisitor < Prism::Visitor # :nodoc:
184
+ attr_reader :tokens
185
+
186
+ def initialize
187
+ @tokens = []
188
+ end
189
+
190
+ def visit_symbol_node(node)
191
+ # SymbolNode#location may contain heredoc content and closing
192
+ # e.g., `<<A; :\\\nA\nsymbol`
193
+ # So we need to colorize opening, content and closing separately.
194
+ push_location(:symbol, node.opening_loc)
195
+ push_location(:symbol, node.value_loc)
196
+ push_location(:symbol, node.closing_loc)
197
+ end
198
+
199
+ def visit_interpolated_symbol_node(node)
200
+ push_location(:symbol, node.opening_loc)
201
+ handle_interpolated_parts(:symbol, node.parts)
202
+ push_location(:symbol, node.closing_loc)
203
+ end
204
+
205
+ def visit_regular_expression_node(node)
206
+ push_location(:regexp, node.location)
207
+ end
208
+
209
+ def visit_interpolated_regular_expression_node(node)
210
+ push_location(:regexp, node.opening_loc)
211
+ handle_interpolated_parts(:regexp, node.parts)
212
+ push_location(:regexp, node.closing_loc)
213
+ end
214
+
215
+ alias visit_match_last_line_node visit_regular_expression_node
216
+ alias visit_interpolated_match_last_line_node visit_interpolated_regular_expression_node
217
+
218
+ def visit_string_node(node)
219
+ # Node's location may not cover the entire string literal.
220
+ # For example, in a heredoc string, the node's location covers only the heredoc opening.
221
+ # We need to colorize opening, content and closing separately.
222
+ push_location(:string, node.opening_loc)
223
+ push_location(:string, node.content_loc)
224
+ push_location(:string, node.closing_loc)
225
+ end
226
+
227
+ def visit_interpolated_string_node(node)
228
+ push_location(:string, node.opening_loc)
229
+ handle_interpolated_parts(:string, node.parts)
230
+ push_location(:string, node.closing_loc)
231
+ end
232
+
233
+ def visit_x_string_node(node)
234
+ # Same as visit_string_node, node.location of <<`X` only covers opening,
235
+ # so we need to colorize opening, content and closing separately.
236
+ push_location(:x_string, node.opening_loc)
237
+ push_location(:x_string, node.content_loc)
238
+ push_location(:x_string, node.closing_loc)
239
+ end
240
+
241
+ def visit_interpolated_x_string_node(node)
242
+ push_location(:x_string, node.opening_loc)
243
+ handle_interpolated_parts(:x_string, node.parts)
244
+ push_location(:x_string, node.closing_loc)
245
+ end
246
+
247
+ def visit_array_node(node)
248
+ super
249
+ # Colorize %w[...] array literal like string literals, and %i[...] like symbol literals
250
+ case node.opening
251
+ when /\A%[wW].\z/
252
+ push_location(:string, node.opening_loc)
253
+ push_location(:string, node.closing_loc)
254
+ when /\A%[iI].\z/
255
+ push_location(:symbol, node.opening_loc)
256
+ push_location(:symbol, node.closing_loc)
257
+ end
258
+ end
259
+
260
+ def visit_def_node(node)
261
+ # For special colorizing of method name in def node
262
+ # e.g., `def <=>; end`
263
+ push_location(:identifier, node.name_loc)
264
+ super
265
+ end
266
+
267
+ private
268
+
269
+ def push_location(kind, location)
270
+ # Only push tokens that have a non-zero length
271
+ if location && location.start_offset < location.end_offset
272
+ @tokens << [kind, location.start_offset, location.end_offset]
273
+ end
274
+ end
275
+
276
+ def handle_interpolated_parts(kind, parts)
277
+ # StringNode, EmbeddedStatementsNode brackets, and EmbeddedVariableNode hash in
278
+ # interpolated regexp/symbol/string parts should be colored as regexp/symbol/string respectively.
279
+ parts.each do |part|
280
+ case part
281
+ when Prism::StringNode
282
+ # InterpolatedStringNode#parts may have its own opening/closing. e.g., `'a' "b"`
283
+ push_location(kind, part.opening_loc)
284
+ push_location(kind, part.content_loc)
285
+ push_location(kind, part.closing_loc)
286
+ when Prism::InterpolatedStringNode
287
+ # InterpolatedStringNode#parts may contain InterpolatedStringNode. e.g., `'a' "#{}"`
288
+ part.accept(self)
289
+ when Prism::EmbeddedStatementsNode
290
+ push_location(kind, part.opening_loc)
291
+ push_location(kind, part.closing_loc)
292
+ part.accept(self)
293
+ when Prism::EmbeddedVariableNode
294
+ push_location(kind, part.operator_loc)
295
+ end
296
+ end
297
+ end
298
+ end
299
+
300
+ private_constant :NodeColorizeVisitor
301
+ end
302
+ end
303
+ end
@@ -1,44 +1,48 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # Parse a non-source file. We basically take the whole thing as one big
4
- # comment.
2
+ module RDoc
3
+ class Parser
4
+ ##
5
+ # Parse a non-source file. We basically take the whole thing as one big
6
+ # comment.
5
7
 
6
- class RDoc::Parser::Simple < RDoc::Parser
8
+ class Simple < Parser
7
9
 
8
- include RDoc::Parser::Text
10
+ include Parser::Text
9
11
 
10
- parse_files_matching(//)
12
+ parse_files_matching(//)
11
13
 
12
- attr_reader :content # :nodoc:
14
+ attr_reader :content # :nodoc:
13
15
 
14
- ##
15
- # Prepare to parse a plain file
16
+ ##
17
+ # Prepare to parse a plain file
16
18
 
17
- def initialize(top_level, content, options, stats)
18
- super
19
+ def initialize(top_level, content, options, stats)
20
+ super
19
21
 
20
- preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
22
+ preprocess = Markup::PreProcess.new @file_name, @options.rdoc_include
21
23
 
22
- content = RDoc::Text.expand_tabs(@content)
23
- @content, = preprocess.run_pre_processes(content, @top_level, 1, :simple)
24
- end
24
+ content = ::RDoc::Text.expand_tabs(@content)
25
+ @content, = preprocess.run_pre_processes(content, @top_level, 1, :simple)
26
+ end
25
27
 
26
- ##
27
- # Extract the file contents and attach them to the TopLevel as a comment
28
+ ##
29
+ # Extract the file contents and attach them to the TopLevel as a comment
28
30
 
29
- def scan
30
- content = remove_coding_comment @content
31
+ def scan
32
+ content = remove_coding_comment @content
31
33
 
32
- comment = RDoc::Comment.new content, @top_level
34
+ comment = Comment.new content, @top_level
33
35
 
34
- @top_level.comment = comment
35
- @top_level
36
- end
36
+ @top_level.comment = comment
37
+ @top_level
38
+ end
37
39
 
38
- ##
39
- # Removes the encoding magic comment from +text+
40
+ ##
41
+ # Removes the encoding magic comment from +text+
40
42
 
41
- def remove_coding_comment(text)
42
- text.sub(/\A# .*coding[=:].*$/, '')
43
+ def remove_coding_comment(text)
44
+ text.sub(/\A# .*coding[=:].*$/, '')
45
+ end
46
+ end
43
47
  end
44
48
  end
@@ -1,11 +1,15 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # Indicates this parser is text and doesn't contain code constructs.
4
- #
5
- # Include this module in a RDoc::Parser subclass to make it show up as a file,
6
- # not as part of a class or module.
7
- #--
8
- # This is not named File to avoid overriding ::File
2
+ module RDoc
3
+ class Parser
4
+ ##
5
+ # Indicates this parser is text and doesn't contain code constructs.
6
+ #
7
+ # Include this module in a RDoc::Parser subclass to make it show up as a file,
8
+ # not as part of a class or module.
9
+ #--
10
+ # This is not named File to avoid overriding ::File
9
11
 
10
- module RDoc::Parser::Text
12
+ module Text
13
+ end
14
+ end
11
15
  end