rdoc 6.17.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 (169) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +193 -0
  3. data/LEGAL.rdoc +6 -0
  4. data/LICENSE.rdoc +4 -0
  5. data/README.md +132 -8
  6. data/RI.md +75 -75
  7. data/doc/markup_reference/markdown.md +659 -0
  8. data/doc/markup_reference/rdoc.rdoc +1169 -0
  9. data/exe/rdoc +2 -2
  10. data/lib/rdoc/code_object/alias.rb +70 -74
  11. data/lib/rdoc/code_object/any_method.rb +308 -293
  12. data/lib/rdoc/code_object/attr.rb +150 -142
  13. data/lib/rdoc/code_object/class_module.rb +802 -715
  14. data/lib/rdoc/code_object/constant.rb +181 -144
  15. data/lib/rdoc/code_object/context/section.rb +140 -130
  16. data/lib/rdoc/code_object/context.rb +925 -941
  17. data/lib/rdoc/code_object/extend.rb +7 -5
  18. data/lib/rdoc/code_object/include.rb +7 -5
  19. data/lib/rdoc/code_object/method_attr.rb +328 -315
  20. data/lib/rdoc/code_object/mixin.rb +97 -92
  21. data/lib/rdoc/code_object/normal_class.rb +77 -78
  22. data/lib/rdoc/code_object/normal_module.rb +61 -59
  23. data/lib/rdoc/code_object/require.rb +23 -39
  24. data/lib/rdoc/code_object/single_class.rb +21 -19
  25. data/lib/rdoc/code_object/top_level.rb +215 -202
  26. data/lib/rdoc/code_object.rb +305 -305
  27. data/lib/rdoc/comment.rb +274 -337
  28. data/lib/rdoc/cross_reference.rb +195 -206
  29. data/lib/rdoc/encoding.rb +105 -103
  30. data/lib/rdoc/erb_partial.rb +13 -11
  31. data/lib/rdoc/erbio.rb +29 -27
  32. data/lib/rdoc/generator/aliki.rb +196 -30
  33. data/lib/rdoc/generator/darkfish.rb +647 -629
  34. data/lib/rdoc/generator/json_index.rb +233 -229
  35. data/lib/rdoc/generator/markup.rb +165 -122
  36. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  37. data/lib/rdoc/generator/pot/po.rb +52 -51
  38. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  39. data/lib/rdoc/generator/pot.rb +85 -81
  40. data/lib/rdoc/generator/ri.rb +23 -19
  41. data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
  42. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
  43. data/lib/rdoc/generator/template/aliki/_footer.rhtml +2 -2
  44. data/lib/rdoc/generator/template/aliki/_head.rhtml +15 -10
  45. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  46. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
  47. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
  48. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
  49. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +3 -3
  50. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +3 -3
  51. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
  52. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
  53. data/lib/rdoc/generator/template/aliki/class.rhtml +71 -61
  54. data/lib/rdoc/generator/template/aliki/css/rdoc.css +796 -323
  55. data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
  56. data/lib/rdoc/generator/template/aliki/js/aliki.js +119 -113
  57. data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  58. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +1 -1
  59. data/lib/rdoc/generator/template/aliki/js/{search.js → search_controller.js} +16 -7
  60. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  61. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  62. data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
  63. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
  64. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
  65. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  66. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
  67. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
  68. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
  69. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +2 -2
  70. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
  71. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
  72. data/lib/rdoc/generator/template/darkfish/class.rhtml +29 -32
  73. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -1
  74. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  75. data/lib/rdoc/generator.rb +48 -46
  76. data/lib/rdoc/i18n/locale.rb +99 -95
  77. data/lib/rdoc/i18n/text.rb +109 -105
  78. data/lib/rdoc/i18n.rb +7 -5
  79. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  80. data/lib/rdoc/markdown.kpeg +52 -33
  81. data/lib/rdoc/markdown.rb +365 -177
  82. data/lib/rdoc/markup/blank_line.rb +25 -23
  83. data/lib/rdoc/markup/block_quote.rb +12 -8
  84. data/lib/rdoc/markup/document.rb +127 -123
  85. data/lib/rdoc/markup/element.rb +21 -0
  86. data/lib/rdoc/markup/formatter.rb +220 -203
  87. data/lib/rdoc/markup/hard_break.rb +30 -27
  88. data/lib/rdoc/markup/heading.rb +163 -77
  89. data/lib/rdoc/markup/include.rb +33 -29
  90. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  91. data/lib/rdoc/markup/inline_parser.rb +316 -0
  92. data/lib/rdoc/markup/list.rb +80 -88
  93. data/lib/rdoc/markup/list_item.rb +73 -85
  94. data/lib/rdoc/markup/paragraph.rb +23 -19
  95. data/lib/rdoc/markup/parser.rb +501 -497
  96. data/lib/rdoc/markup/pre_process.rb +284 -305
  97. data/lib/rdoc/markup/raw.rb +52 -55
  98. data/lib/rdoc/markup/rule.rb +16 -12
  99. data/lib/rdoc/markup/table.rb +48 -40
  100. data/lib/rdoc/markup/to_ansi.rb +143 -92
  101. data/lib/rdoc/markup/to_bs.rb +86 -102
  102. data/lib/rdoc/markup/to_html.rb +608 -506
  103. data/lib/rdoc/markup/to_html_crossref.rb +219 -210
  104. data/lib/rdoc/markup/to_html_snippet.rb +210 -205
  105. data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
  106. data/lib/rdoc/markup/to_label.rb +64 -51
  107. data/lib/rdoc/markup/to_markdown.rb +212 -184
  108. data/lib/rdoc/markup/to_rdoc.rb +341 -277
  109. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  110. data/lib/rdoc/markup/to_test.rb +62 -50
  111. data/lib/rdoc/markup/to_tt_only.rb +83 -92
  112. data/lib/rdoc/markup/verbatim.rb +62 -58
  113. data/lib/rdoc/markup.rb +196 -215
  114. data/lib/rdoc/options.rb +1063 -1076
  115. data/lib/rdoc/parser/c.rb +1039 -1036
  116. data/lib/rdoc/parser/changelog.rb +320 -287
  117. data/lib/rdoc/parser/markdown.rb +17 -13
  118. data/lib/rdoc/parser/rbs.rb +279 -0
  119. data/lib/rdoc/parser/rd.rb +17 -13
  120. data/lib/rdoc/parser/ruby.rb +1231 -2222
  121. data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
  122. data/lib/rdoc/parser/simple.rb +31 -27
  123. data/lib/rdoc/parser/text.rb +12 -8
  124. data/lib/rdoc/parser.rb +230 -221
  125. data/lib/rdoc/rbs_helper.rb +186 -0
  126. data/lib/rdoc/rd/inline.rb +57 -53
  127. data/lib/rdoc/rd.rb +90 -88
  128. data/lib/rdoc/rdoc.rb +547 -366
  129. data/lib/rdoc/ri/driver.rb +1141 -1130
  130. data/lib/rdoc/ri/formatter.rb +7 -3
  131. data/lib/rdoc/ri/paths.rb +140 -136
  132. data/lib/rdoc/ri/servlet.rb +456 -0
  133. data/lib/rdoc/ri/store.rb +4 -2
  134. data/lib/rdoc/ri/task.rb +55 -51
  135. data/lib/rdoc/ri.rb +14 -11
  136. data/lib/rdoc/rubygems_hook.rb +194 -192
  137. data/lib/rdoc/server.rb +462 -0
  138. data/lib/rdoc/stats/normal.rb +46 -42
  139. data/lib/rdoc/stats/quiet.rb +39 -35
  140. data/lib/rdoc/stats/verbose.rb +35 -31
  141. data/lib/rdoc/stats.rb +363 -338
  142. data/lib/rdoc/store.rb +919 -725
  143. data/lib/rdoc/task.rb +260 -255
  144. data/lib/rdoc/text.rb +164 -240
  145. data/lib/rdoc/token_stream.rb +88 -106
  146. data/lib/rdoc/tom_doc.rb +203 -201
  147. data/lib/rdoc/version.rb +1 -1
  148. data/lib/rdoc.rb +35 -7
  149. data/lib/rubygems_plugin.rb +2 -11
  150. data/rdoc-logo.svg +43 -0
  151. data/rdoc.gemspec +9 -7
  152. metadata +46 -32
  153. data/CONTRIBUTING.rdoc +0 -219
  154. data/ExampleMarkdown.md +0 -39
  155. data/ExampleRDoc.rdoc +0 -210
  156. data/lib/rdoc/code_object/anon_class.rb +0 -10
  157. data/lib/rdoc/code_object/ghost_method.rb +0 -6
  158. data/lib/rdoc/code_object/meta_method.rb +0 -6
  159. data/lib/rdoc/markdown/literals.kpeg +0 -21
  160. data/lib/rdoc/markdown/literals.rb +0 -454
  161. data/lib/rdoc/markup/attr_changer.rb +0 -22
  162. data/lib/rdoc/markup/attr_span.rb +0 -35
  163. data/lib/rdoc/markup/attribute_manager.rb +0 -405
  164. data/lib/rdoc/markup/attributes.rb +0 -70
  165. data/lib/rdoc/markup/regexp_handling.rb +0 -40
  166. data/lib/rdoc/parser/prism_ruby.rb +0 -1100
  167. data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
  168. data/lib/rdoc/parser/ruby_tools.rb +0 -163
  169. data/lib/rdoc/servlet.rb +0 -452
@@ -10,263 +10,280 @@
10
10
  # RDoc::Markup::FormatterTestCase. If you're writing a text-output formatter
11
11
  # use RDoc::Markup::TextFormatterTestCase which provides extra test cases.
12
12
 
13
- class RDoc::Markup::Formatter
13
+ require 'rdoc/markup/inline_parser'
14
14
 
15
- ##
16
- # Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
17
- # +off+ triggers.
15
+ module RDoc
16
+ class Markup
17
+ class Formatter
18
18
 
19
- InlineTag = Struct.new(:bit, :on, :off)
19
+ ##
20
+ # Converts a target url to one that is relative to a given path
20
21
 
21
- ##
22
- # Converts a target url to one that is relative to a given path
22
+ def self.gen_relative_url(path, target)
23
+ from = File.dirname path
24
+ to, to_file = File.split target
23
25
 
24
- def self.gen_relative_url(path, target)
25
- from = File.dirname path
26
- to, to_file = File.split target
26
+ from = from.split "/"
27
+ to = to.split "/"
27
28
 
28
- from = from.split "/"
29
- to = to.split "/"
29
+ from.delete '.'
30
+ to.delete '.'
30
31
 
31
- from.delete '.'
32
- to.delete '.'
32
+ while from.size > 0 and to.size > 0 and from[0] == to[0] do
33
+ from.shift
34
+ to.shift
35
+ end
33
36
 
34
- while from.size > 0 and to.size > 0 and from[0] == to[0] do
35
- from.shift
36
- to.shift
37
- end
38
-
39
- from.fill ".."
40
- from.concat to
41
- from << to_file
42
- File.join(*from)
43
- end
44
-
45
- ##
46
- # Creates a new Formatter
37
+ from.fill ".."
38
+ from.concat to
39
+ from << to_file
40
+ File.join(*from)
41
+ end
47
42
 
48
- def initialize(options, markup = nil)
49
- @options = options
43
+ ##
44
+ # Creates a new Formatter
50
45
 
51
- @markup = markup || RDoc::Markup.new
52
- @am = @markup.attribute_manager
53
- @am.add_regexp_handling(/<br>/, :HARD_BREAK)
46
+ def initialize
47
+ @markup = Markup.new
54
48
 
55
- @attributes = @am.attributes
49
+ @from_path = '.'
50
+ end
56
51
 
57
- @attr_tags = []
52
+ ##
53
+ # Adds +document+ to the output
54
+
55
+ def accept_document(document)
56
+ document.parts.each do |item|
57
+ case item
58
+ when Markup::Document # HACK
59
+ accept_document item
60
+ else
61
+ item.accept self
62
+ end
63
+ end
64
+ end
58
65
 
59
- @in_tt = 0
60
- @tt_bit = @attributes.bitmap_for :TT
66
+ ##
67
+ # Adds a regexp handling for links of the form rdoc-...:
61
68
 
62
- @hard_break = ''
63
- @from_path = '.'
64
- end
69
+ def add_regexp_handling_RDOCLINK
70
+ @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
71
+ end
65
72
 
66
- ##
67
- # Adds +document+ to the output
73
+ ##
74
+ # Allows +tag+ to be decorated with additional information.
68
75
 
69
- def accept_document(document)
70
- document.parts.each do |item|
71
- case item
72
- when RDoc::Markup::Document then # HACK
73
- accept_document item
74
- else
75
- item.accept self
76
+ def annotate(tag)
77
+ tag
76
78
  end
77
- end
78
- end
79
79
 
80
- ##
81
- # Adds a regexp handling for links of the form rdoc-...:
80
+ ##
81
+ # Marks up +content+
82
82
 
83
- def add_regexp_handling_RDOCLINK
84
- @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
85
- end
83
+ def convert(content)
84
+ @markup.convert content, self
85
+ end
86
86
 
87
- ##
88
- # Adds a regexp handling for links of the form {<text>}[<url>] and
89
- # <word>[<url>]
87
+ # Applies regexp handling to +text+ and returns an array of [text, converted?] pairs.
88
+
89
+ def apply_regexp_handling(text)
90
+ matched = []
91
+ @markup.regexp_handlings.each_with_index do |(pattern, name), priority|
92
+ text.scan(pattern) do
93
+ m = Regexp.last_match
94
+ idx = m[1] ? 1 : 0
95
+ matched << [m.begin(idx), m.end(idx), m[idx], name, priority]
96
+ end
97
+ end
98
+ # If the start positions are the same, prefer the earlier-registered one
99
+ # (lower numeric priority from each_with_index).
100
+ matched.sort_by! {|beg_pos, _, _, _, priority| [beg_pos, priority] }
101
+
102
+ pos = 0
103
+ output = []
104
+ matched.each do |beg_pos, end_pos, s, name|
105
+ next if beg_pos < pos
106
+
107
+ output << [text[pos...beg_pos], false] if beg_pos != pos
108
+ handled = public_send(:"handle_regexp_#{name}", s)
109
+ output << [handled, true]
110
+ pos = end_pos
111
+ end
112
+
113
+ output << [text[pos..], false] if pos < text.size
114
+ output
115
+ end
90
116
 
91
- def add_regexp_handling_TIDYLINK
92
- @markup.add_regexp_handling(/(?:
93
- \{[^{}]*\} | # multi-word label
94
- \b[^\s{}]+? # single-word label
95
- )
117
+ # Called when processing plain text while traversing inline nodes from handle_inline.
118
+ # +text+ may need proper escaping.
96
119
 
97
- \[\S+?\] # link target
98
- /x, :TIDYLINK)
99
- end
120
+ def handle_PLAIN_TEXT(text)
121
+ end
100
122
 
101
- ##
102
- # Add a new set of tags for an attribute. We allow separate start and end
103
- # tags for flexibility
123
+ # Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.
124
+ # +text+ may contain markup tags.
104
125
 
105
- def add_tag(name, start, stop)
106
- attr = @attributes.bitmap_for name
107
- @attr_tags << InlineTag.new(attr, start, stop)
108
- end
126
+ def handle_REGEXP_HANDLING_TEXT(text)
127
+ end
109
128
 
110
- ##
111
- # Allows +tag+ to be decorated with additional information.
129
+ # Called when processing text node while traversing inline nodes from handle_inline.
130
+ # Apply regexp handling and dispatch to the appropriate handler: handle_REGEXP_HANDLING_TEXT or handle_PLAIN_TEXT.
131
+
132
+ def handle_TEXT(text)
133
+ apply_regexp_handling(text).each do |part, converted|
134
+ if converted
135
+ handle_REGEXP_HANDLING_TEXT(part)
136
+ else
137
+ handle_PLAIN_TEXT(part)
138
+ end
139
+ end
140
+ end
112
141
 
113
- def annotate(tag)
114
- tag
115
- end
142
+ # Called when processing a hard break while traversing inline nodes from handle_inline.
116
143
 
117
- ##
118
- # Marks up +content+
144
+ def handle_HARD_BREAK
145
+ end
119
146
 
120
- def convert(content)
121
- @markup.convert content, self
122
- end
147
+ # Called when processing bold nodes while traversing inline nodes from handle_inline.
148
+ # Traverse the children nodes and dispatch to the appropriate handlers.
123
149
 
124
- ##
125
- # Converts flow items +flow+
126
-
127
- def convert_flow(flow)
128
- res = []
129
-
130
- flow.each do |item|
131
- case item
132
- when String then
133
- res << convert_string(item)
134
- when RDoc::Markup::AttrChanger then
135
- off_tags res, item
136
- on_tags res, item
137
- when RDoc::Markup::RegexpHandling then
138
- res << convert_regexp_handling(item)
139
- else
140
- raise "Unknown flow element: #{item.inspect}"
150
+ def handle_BOLD(nodes)
151
+ traverse_inline_nodes(nodes)
141
152
  end
142
- end
143
153
 
144
- res.join
145
- end
154
+ # Called when processing emphasis nodes while traversing inline nodes from handle_inline.
155
+ # Traverse the children nodes and dispatch to the appropriate handlers.
146
156
 
147
- ##
148
- # Converts added regexp handlings. See RDoc::Markup#add_regexp_handling
157
+ def handle_EM(nodes)
158
+ traverse_inline_nodes(nodes)
159
+ end
149
160
 
150
- def convert_regexp_handling(target)
151
- return target.text if in_tt?
161
+ # Called when processing bold word nodes while traversing inline nodes from handle_inline.
162
+ # +word+ may need proper escaping.
152
163
 
153
- handled = false
164
+ def handle_BOLD_WORD(word)
165
+ handle_PLAIN_TEXT(word)
166
+ end
154
167
 
155
- @attributes.each_name_of target.type do |name|
156
- method_name = "handle_regexp_#{name}"
168
+ # Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
169
+ # +word+ may need proper escaping.
157
170
 
158
- if respond_to? method_name then
159
- target.text = public_send method_name, target
160
- handled = true
171
+ def handle_EM_WORD(word)
172
+ handle_PLAIN_TEXT(word)
161
173
  end
162
- end
163
174
 
164
- unless handled then
165
- target_name = @attributes.as_string target.type
175
+ # Called when processing tt nodes while traversing inline nodes from handle_inline.
176
+ # +code+ may need proper escaping.
166
177
 
167
- raise RDoc::Error, "Unhandled regexp handling #{target_name}: #{target}"
168
- end
178
+ def handle_TT(code)
179
+ handle_PLAIN_TEXT(code)
180
+ end
169
181
 
170
- target.text
171
- end
182
+ # Called when processing strike nodes while traversing inline nodes from handle_inline.
183
+ # Traverse the children nodes and dispatch to the appropriate handlers.
172
184
 
173
- ##
174
- # Converts a string to be fancier if desired
185
+ def handle_STRIKE(nodes)
186
+ traverse_inline_nodes(nodes)
187
+ end
175
188
 
176
- def convert_string(string)
177
- string
178
- end
189
+ # Called when processing tidylink nodes while traversing inline nodes from handle_inline.
190
+ # +label_part+ is an array of strings or nodes representing the link label.
191
+ # +url+ is the link URL.
192
+ # Traverse the label_part nodes and dispatch to the appropriate handlers.
179
193
 
180
- ##
181
- # Use ignore in your subclass to ignore the content of a node.
182
- #
183
- # ##
184
- # # We don't support raw nodes in ToNoRaw
185
- #
186
- # alias accept_raw ignore
194
+ def handle_TIDYLINK(label_part, url)
195
+ traverse_inline_nodes(label_part)
196
+ end
187
197
 
188
- def ignore *node
189
- end
198
+ # Parses inline +text+, traverse the resulting nodes, and calls the appropriate handler methods.
190
199
 
191
- ##
192
- # Are we currently inside tt tags?
200
+ def handle_inline(text)
201
+ nodes = Markup::InlineParser.new(text).parse
202
+ traverse_inline_nodes(nodes)
203
+ end
193
204
 
194
- def in_tt?
195
- @in_tt > 0
196
- end
205
+ # Traverses +nodes+ and calls the appropriate handler methods
206
+ # Nodes formats are described in RDoc::Markup::InlineParser#parse
207
+
208
+ def traverse_inline_nodes(nodes)
209
+ nodes.each do |node|
210
+ next handle_TEXT(node) if String === node
211
+ case node[:type]
212
+ when :TIDYLINK
213
+ handle_TIDYLINK(node[:children], node[:url])
214
+ when :HARD_BREAK
215
+ handle_HARD_BREAK
216
+ when :BOLD
217
+ handle_BOLD(node[:children])
218
+ when :BOLD_WORD
219
+ handle_BOLD_WORD(node[:children][0] || '')
220
+ when :EM
221
+ handle_EM(node[:children])
222
+ when :EM_WORD
223
+ handle_EM_WORD(node[:children][0] || '')
224
+ when :TT
225
+ handle_TT(node[:children][0] || '')
226
+ when :STRIKE
227
+ handle_STRIKE(node[:children])
228
+ end
229
+ end
230
+ end
197
231
 
198
- def tt_tag?(attr_mask, reverse = false)
199
- each_attr_tag(attr_mask, reverse) do |tag|
200
- return true if tt? tag
201
- end
202
- false
203
- end
232
+ ##
233
+ # Converts a string to be fancier if desired
204
234
 
205
- ##
206
- # Turns on tags for +item+ on +res+
235
+ def convert_string(string)
236
+ string
237
+ end
207
238
 
208
- def on_tags(res, item)
209
- each_attr_tag(item.turn_on) do |tag|
210
- res << annotate(tag.on)
211
- @in_tt += 1 if tt? tag
212
- end
213
- end
239
+ ##
240
+ # Use ignore in your subclass to ignore the content of a node.
241
+ #
242
+ # ##
243
+ # # We don't support raw nodes in ToNoRaw
244
+ #
245
+ # alias accept_raw ignore
214
246
 
215
- ##
216
- # Turns off tags for +item+ on +res+
247
+ def ignore(*node)
248
+ end
217
249
 
218
- def off_tags(res, item)
219
- each_attr_tag(item.turn_off, true) do |tag|
220
- @in_tt -= 1 if tt? tag
221
- res << annotate(tag.off)
222
- end
223
- end
250
+ ##
251
+ # Extracts and a scheme, url and an anchor id from +url+ and returns them.
252
+
253
+ def parse_url(url)
254
+ case url
255
+ when /^rdoc-label:([^:]*)(?::(.*))?/
256
+ scheme = 'link'
257
+ path = "##{$1}"
258
+ id = " id=\"#{$2}\"" if $2
259
+ when /([A-Za-z]+):(.*)/
260
+ scheme = $1.downcase
261
+ path = $2
262
+ when /^#/
263
+ else
264
+ scheme = 'http'
265
+ path = url
266
+ url = url
267
+ end
268
+
269
+ if scheme == 'link'
270
+ url = if path[0, 1] == '#' # is this meaningful?
271
+ path
272
+ else
273
+ self.class.gen_relative_url @from_path, path
274
+ end
275
+ end
276
+
277
+ [scheme, url, id]
278
+ end
224
279
 
225
- def each_attr_tag(attr_mask, reverse = false)
226
- return if attr_mask.zero?
280
+ ##
281
+ # Is +tag+ a tt tag?
227
282
 
228
- @attr_tags.public_send(reverse ? :reverse_each : :each) do |tag|
229
- if attr_mask & tag.bit != 0 then
230
- yield tag
283
+ def tt?(tag)
284
+ tag.bit == @tt_bit
231
285
  end
232
- end
233
- end
234
286
 
235
- ##
236
- # Extracts and a scheme, url and an anchor id from +url+ and returns them.
237
-
238
- def parse_url(url)
239
- case url
240
- when /^rdoc-label:([^:]*)(?::(.*))?/ then
241
- scheme = 'link'
242
- path = "##{$1}"
243
- id = " id=\"#{$2}\"" if $2
244
- when /([A-Za-z]+):(.*)/ then
245
- scheme = $1.downcase
246
- path = $2
247
- when /^#/ then
248
- else
249
- scheme = 'http'
250
- path = url
251
- url = url
252
287
  end
253
-
254
- if scheme == 'link' then
255
- url = if path[0, 1] == '#' then # is this meaningful?
256
- path
257
- else
258
- self.class.gen_relative_url @from_path, path
259
- end
260
- end
261
-
262
- [scheme, url, id]
263
- end
264
-
265
- ##
266
- # Is +tag+ a tt tag?
267
-
268
- def tt?(tag)
269
- tag.bit == @tt_bit
270
288
  end
271
-
272
289
  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