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
@@ -12,284 +12,278 @@
12
12
 
13
13
  require 'rdoc/markup/inline_parser'
14
14
 
15
- class RDoc::Markup::Formatter
15
+ module RDoc
16
+ class Markup
17
+ class Formatter
16
18
 
17
- ##
18
- # Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
19
- # +off+ triggers.
19
+ ##
20
+ # Converts a target url to one that is relative to a given path
20
21
 
21
- InlineTag = Struct.new(:bit, :on, :off)
22
+ def self.gen_relative_url(path, target)
23
+ from = File.dirname path
24
+ to, to_file = File.split target
22
25
 
26
+ from = from.split "/"
27
+ to = to.split "/"
23
28
 
24
- ##
25
- # Converts a target url to one that is relative to a given path
29
+ from.delete '.'
30
+ to.delete '.'
26
31
 
27
- def self.gen_relative_url(path, target)
28
- from = File.dirname path
29
- to, to_file = File.split target
30
-
31
- from = from.split "/"
32
- to = to.split "/"
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
- from.delete '.'
35
- to.delete '.'
37
+ from.fill ".."
38
+ from.concat to
39
+ from << to_file
40
+ File.join(*from)
41
+ end
36
42
 
37
- while from.size > 0 and to.size > 0 and from[0] == to[0] do
38
- from.shift
39
- to.shift
40
- end
43
+ ##
44
+ # Creates a new Formatter
41
45
 
42
- from.fill ".."
43
- from.concat to
44
- from << to_file
45
- File.join(*from)
46
- end
46
+ def initialize
47
+ @markup = Markup.new
47
48
 
48
- ##
49
- # Creates a new Formatter
49
+ @from_path = '.'
50
+ end
50
51
 
51
- def initialize(options, markup = nil)
52
- @options = options
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
53
65
 
54
- @markup = markup || RDoc::Markup.new
66
+ ##
67
+ # Adds a regexp handling for links of the form rdoc-...:
55
68
 
56
- @from_path = '.'
57
- end
69
+ def add_regexp_handling_RDOCLINK
70
+ @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
71
+ end
58
72
 
59
- ##
60
- # Adds +document+ to the output
73
+ ##
74
+ # Allows +tag+ to be decorated with additional information.
61
75
 
62
- def accept_document(document)
63
- document.parts.each do |item|
64
- case item
65
- when RDoc::Markup::Document then # HACK
66
- accept_document item
67
- else
68
- item.accept self
76
+ def annotate(tag)
77
+ tag
69
78
  end
70
- end
71
- end
72
79
 
73
- ##
74
- # Adds a regexp handling for links of the form rdoc-...:
80
+ ##
81
+ # Marks up +content+
75
82
 
76
- def add_regexp_handling_RDOCLINK
77
- @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
78
- end
83
+ def convert(content)
84
+ @markup.convert content, self
85
+ end
79
86
 
80
- ##
81
- # Allows +tag+ to be decorated with additional information.
87
+ # Applies regexp handling to +text+ and returns an array of [text, converted?] pairs.
82
88
 
83
- def annotate(tag)
84
- tag
85
- end
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
86
112
 
87
- ##
88
- # Marks up +content+
113
+ output << [text[pos..], false] if pos < text.size
114
+ output
115
+ end
89
116
 
90
- def convert(content)
91
- @markup.convert content, self
92
- end
117
+ # Called when processing plain text while traversing inline nodes from handle_inline.
118
+ # +text+ may need proper escaping.
93
119
 
94
- # Applies regexp handling to +text+ and returns an array of [text, converted?] pairs.
95
-
96
- 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
105
- 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
120
+ def handle_PLAIN_TEXT(text)
111
121
  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
- end
122
- output
123
- end
124
122
 
125
- # Called when processing plain text while traversing inline nodes from handle_inline.
126
- # +text+ may need proper escaping.
123
+ # Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.
124
+ # +text+ may contain markup tags.
127
125
 
128
- def handle_PLAIN_TEXT(text)
129
- end
126
+ def handle_REGEXP_HANDLING_TEXT(text)
127
+ end
130
128
 
131
- # Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.
132
- # +text+ may contain markup tags.
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.
133
131
 
134
- def handle_REGEXP_HANDLING_TEXT(text)
135
- end
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
136
141
 
137
- # Called when processing text node while traversing inline nodes from handle_inline.
138
- # Apply regexp handling and dispatch to the appropriate handler: handle_REGEXP_HANDLING_TEXT or handle_PLAIN_TEXT.
142
+ # Called when processing a hard break while traversing inline nodes from handle_inline.
139
143
 
140
- def handle_TEXT(text)
141
- apply_regexp_handling(text).each do |part, converted|
142
- if converted
143
- handle_REGEXP_HANDLING_TEXT(part)
144
- else
145
- handle_PLAIN_TEXT(part)
144
+ def handle_HARD_BREAK
146
145
  end
147
- end
148
- end
149
146
 
150
- # Called when processing a hard break while traversing inline nodes from handle_inline.
147
+ # Called when processing bold nodes while traversing inline nodes from handle_inline.
148
+ # Traverse the children nodes and dispatch to the appropriate handlers.
151
149
 
152
- def handle_HARD_BREAK
153
- end
150
+ def handle_BOLD(nodes)
151
+ traverse_inline_nodes(nodes)
152
+ end
154
153
 
155
- # Called when processing bold nodes while traversing inline nodes from handle_inline.
156
- # Traverse the children nodes and dispatch to the appropriate handlers.
154
+ # Called when processing emphasis nodes while traversing inline nodes from handle_inline.
155
+ # Traverse the children nodes and dispatch to the appropriate handlers.
157
156
 
158
- def handle_BOLD(nodes)
159
- traverse_inline_nodes(nodes)
160
- end
157
+ def handle_EM(nodes)
158
+ traverse_inline_nodes(nodes)
159
+ end
161
160
 
162
- # Called when processing emphasis nodes while traversing inline nodes from handle_inline.
163
- # Traverse the children nodes and dispatch to the appropriate handlers.
161
+ # Called when processing bold word nodes while traversing inline nodes from handle_inline.
162
+ # +word+ may need proper escaping.
164
163
 
165
- def handle_EM(nodes)
166
- traverse_inline_nodes(nodes)
167
- end
164
+ def handle_BOLD_WORD(word)
165
+ handle_PLAIN_TEXT(word)
166
+ end
168
167
 
169
- # Called when processing bold word nodes while traversing inline nodes from handle_inline.
170
- # +word+ may need proper escaping.
168
+ # Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
169
+ # +word+ may need proper escaping.
171
170
 
172
- def handle_BOLD_WORD(word)
173
- handle_PLAIN_TEXT(word)
174
- end
171
+ def handle_EM_WORD(word)
172
+ handle_PLAIN_TEXT(word)
173
+ end
175
174
 
176
- # Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
177
- # +word+ may need proper escaping.
175
+ # Called when processing tt nodes while traversing inline nodes from handle_inline.
176
+ # +code+ may need proper escaping.
178
177
 
179
- def handle_EM_WORD(word)
180
- handle_PLAIN_TEXT(word)
181
- end
178
+ def handle_TT(code)
179
+ handle_PLAIN_TEXT(code)
180
+ end
182
181
 
183
- # Called when processing tt nodes while traversing inline nodes from handle_inline.
184
- # +code+ may need proper escaping.
182
+ # Called when processing strike nodes while traversing inline nodes from handle_inline.
183
+ # Traverse the children nodes and dispatch to the appropriate handlers.
185
184
 
186
- def handle_TT(code)
187
- handle_PLAIN_TEXT(code)
188
- end
185
+ def handle_STRIKE(nodes)
186
+ traverse_inline_nodes(nodes)
187
+ end
189
188
 
190
- # Called when processing strike nodes while traversing inline nodes from handle_inline.
191
- # Traverse the children nodes and dispatch to the appropriate handlers.
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.
192
193
 
193
- def handle_STRIKE(nodes)
194
- traverse_inline_nodes(nodes)
195
- end
194
+ def handle_TIDYLINK(label_part, url)
195
+ traverse_inline_nodes(label_part)
196
+ end
196
197
 
197
- # Called when processing tidylink nodes while traversing inline nodes from handle_inline.
198
- # +label_part+ is an array of strings or nodes representing the link label.
199
- # +url+ is the link URL.
200
- # Traverse the label_part nodes and dispatch to the appropriate handlers.
198
+ # Parses inline +text+, traverse the resulting nodes, and calls the appropriate handler methods.
201
199
 
202
- def handle_TIDYLINK(label_part, url)
203
- traverse_inline_nodes(label_part)
204
- end
200
+ def handle_inline(text)
201
+ nodes = Markup::InlineParser.new(text).parse
202
+ traverse_inline_nodes(nodes)
203
+ end
205
204
 
206
- # Parses inline +text+, traverse the resulting nodes, and calls the appropriate handler methods.
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
207
231
 
208
- def handle_inline(text)
209
- nodes = RDoc::Markup::InlineParser.new(text).parse
210
- traverse_inline_nodes(nodes)
211
- end
232
+ ##
233
+ # Converts a string to be fancier if desired
212
234
 
213
- # Traverses +nodes+ and calls the appropriate handler methods
214
- # Nodes formats are described in RDoc::Markup::InlineParser#parse
215
-
216
- def traverse_inline_nodes(nodes)
217
- nodes.each do |node|
218
- next handle_TEXT(node) if String === node
219
- case node[:type]
220
- when :TIDYLINK
221
- handle_TIDYLINK(node[:children], node[:url])
222
- when :HARD_BREAK
223
- handle_HARD_BREAK
224
- when :BOLD
225
- handle_BOLD(node[:children])
226
- when :BOLD_WORD
227
- handle_BOLD_WORD(node[:children][0] || '')
228
- when :EM
229
- handle_EM(node[:children])
230
- when :EM_WORD
231
- handle_EM_WORD(node[:children][0] || '')
232
- when :TT
233
- handle_TT(node[:children][0] || '')
234
- when :STRIKE
235
- handle_STRIKE(node[:children])
235
+ def convert_string(string)
236
+ string
236
237
  end
237
- end
238
- end
239
-
240
- ##
241
- # Converts a string to be fancier if desired
242
238
 
243
- def convert_string(string)
244
- string
245
- 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
246
246
 
247
- ##
248
- # Use ignore in your subclass to ignore the content of a node.
249
- #
250
- # ##
251
- # # We don't support raw nodes in ToNoRaw
252
- #
253
- # alias accept_raw ignore
247
+ def ignore(*node)
248
+ end
254
249
 
255
- def ignore *node
256
- 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
257
268
 
258
- ##
259
- # Extracts and a scheme, url and an anchor id from +url+ and returns them.
260
-
261
- def parse_url(url)
262
- case url
263
- when /^rdoc-label:([^:]*)(?::(.*))?/ then
264
- scheme = 'link'
265
- path = "##{$1}"
266
- id = " id=\"#{$2}\"" if $2
267
- when /([A-Za-z]+):(.*)/ then
268
- scheme = $1.downcase
269
- path = $2
270
- when /^#/ then
271
- else
272
- scheme = 'http'
273
- path = url
274
- url = url
275
- end
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
276
 
277
- if scheme == 'link' then
278
- url = if path[0, 1] == '#' then # is this meaningful?
279
- path
280
- else
281
- self.class.gen_relative_url @from_path, path
282
- end
283
- end
277
+ [scheme, url, id]
278
+ end
284
279
 
285
- [scheme, url, id]
286
- end
280
+ ##
281
+ # Is +tag+ a tt tag?
287
282
 
288
- ##
289
- # Is +tag+ a tt tag?
283
+ def tt?(tag)
284
+ tag.bit == @tt_bit
285
+ end
290
286
 
291
- def tt?(tag)
292
- tag.bit == @tt_bit
287
+ end
293
288
  end
294
-
295
289
  end
@@ -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(/^\\/, '')
@@ -1,42 +1,46 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A file included at generation time. Objects of this class are created by
4
- # RDoc::RD for an extension-less include.
5
- #
6
- # This implementation in incomplete.
2
+ module RDoc
3
+ class Markup
4
+ ##
5
+ # A file included at generation time. Objects of this class are created by
6
+ # RDoc::RD for an extension-less include.
7
+ #
8
+ # This implementation in incomplete.
7
9
 
8
- class RDoc::Markup::Include
10
+ class Include
9
11
 
10
- ##
11
- # The filename to be included, without extension
12
+ ##
13
+ # The filename to be included, without extension
12
14
 
13
- attr_reader :file
15
+ attr_reader :file
14
16
 
15
- ##
16
- # Directories to search for #file
17
+ ##
18
+ # Directories to search for #file
17
19
 
18
- attr_reader :include_path
20
+ attr_reader :include_path
19
21
 
20
- ##
21
- # Creates a new include that will import +file+ from +include_path+
22
+ ##
23
+ # Creates a new include that will import +file+ from +include_path+
22
24
 
23
- def initialize(file, include_path)
24
- @file = file
25
- @include_path = include_path
26
- end
25
+ def initialize(file, include_path)
26
+ @file = file
27
+ @include_path = include_path
28
+ end
27
29
 
28
- def ==(other) # :nodoc:
29
- self.class === other and
30
- @file == other.file and @include_path == other.include_path
31
- end
30
+ def ==(other) # :nodoc:
31
+ self.class === other and
32
+ @file == other.file and @include_path == other.include_path
33
+ end
34
+
35
+ def pretty_print(q) # :nodoc:
36
+ q.group 2, '[incl ', ']' do
37
+ q.text file
38
+ q.breakable
39
+ q.text 'from '
40
+ q.pp include_path
41
+ end
42
+ end
32
43
 
33
- def pretty_print(q) # :nodoc:
34
- q.group 2, '[incl ', ']' do
35
- q.text file
36
- q.breakable
37
- q.text 'from '
38
- q.pp include_path
39
44
  end
40
45
  end
41
-
42
46
  end
@@ -1,47 +1,51 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # An Indented Paragraph of text
2
+ module RDoc
3
+ class Markup
4
+ ##
5
+ # An Indented Paragraph of text
4
6
 
5
- class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
7
+ class IndentedParagraph < Markup::Raw
6
8
 
7
- ##
8
- # The indent in number of spaces
9
+ ##
10
+ # The indent in number of spaces
9
11
 
10
- attr_reader :indent
12
+ attr_reader :indent
11
13
 
12
- ##
13
- # Creates a new IndentedParagraph containing +parts+ indented with +indent+
14
- # spaces
14
+ ##
15
+ # Creates a new IndentedParagraph containing +parts+ indented with +indent+
16
+ # spaces
15
17
 
16
- def initialize indent, *parts
17
- @indent = indent
18
+ def initialize(indent, *parts)
19
+ @indent = indent
18
20
 
19
- super(*parts)
20
- end
21
+ super(*parts)
22
+ end
21
23
 
22
- def ==(other) # :nodoc:
23
- super and indent == other.indent
24
- end
24
+ def ==(other) # :nodoc:
25
+ super and indent == other.indent
26
+ end
25
27
 
26
- ##
27
- # Calls #accept_indented_paragraph on +visitor+
28
+ ##
29
+ # Calls #accept_indented_paragraph on +visitor+
28
30
 
29
- def accept(visitor)
30
- visitor.accept_indented_paragraph self
31
- end
32
-
33
- ##
34
- # Joins the raw paragraph text and converts inline HardBreaks to the
35
- # +hard_break+ text followed by the indent.
31
+ def accept(visitor)
32
+ visitor.accept_indented_paragraph self
33
+ end
36
34
 
37
- def text(hard_break = nil)
38
- @parts.map do |part|
39
- if RDoc::Markup::HardBreak === part then
40
- '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break
41
- else
42
- part
35
+ ##
36
+ # Joins the raw paragraph text and converts inline HardBreaks to the
37
+ # +hard_break+ text followed by the indent.
38
+
39
+ def text(hard_break = nil)
40
+ @parts.map do |part|
41
+ if Markup::HardBreak === part
42
+ '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break
43
+ else
44
+ part
45
+ end
46
+ end.join
43
47
  end
44
- end.join
45
- end
46
48
 
49
+ end
50
+ end
47
51
  end