rdoc 6.17.0 → 7.2.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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +196 -0
- data/LEGAL.rdoc +6 -0
- data/README.md +90 -7
- data/doc/markup_reference/markdown.md +558 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/lib/rdoc/code_object/any_method.rb +15 -7
- data/lib/rdoc/code_object/attr.rb +2 -1
- data/lib/rdoc/code_object/class_module.rb +62 -11
- data/lib/rdoc/code_object/constant.rb +9 -0
- data/lib/rdoc/code_object/context/section.rb +46 -9
- data/lib/rdoc/code_object/context.rb +15 -4
- data/lib/rdoc/code_object/method_attr.rb +13 -1
- data/lib/rdoc/code_object/mixin.rb +3 -0
- data/lib/rdoc/code_object/top_level.rb +15 -1
- data/lib/rdoc/comment.rb +1 -1
- data/lib/rdoc/cross_reference.rb +31 -24
- data/lib/rdoc/generator/aliki.rb +141 -0
- data/lib/rdoc/generator/darkfish.rb +3 -1
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +9 -4
- data/lib/rdoc/generator/template/aliki/_header.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +3 -3
- data/lib/rdoc/generator/template/aliki/class.rhtml +17 -17
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +278 -60
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +51 -23
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +1 -1
- data/lib/rdoc/generator/template/aliki/js/{search.js → search_controller.js} +16 -7
- data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/class.rhtml +11 -11
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -0
- data/lib/rdoc/markdown.kpeg +22 -12
- data/lib/rdoc/markdown.rb +36 -26
- data/lib/rdoc/markup/blank_line.rb +25 -23
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/formatter.rb +129 -106
- data/lib/rdoc/markup/hard_break.rb +30 -27
- data/lib/rdoc/markup/heading.rb +166 -77
- data/lib/rdoc/markup/inline_parser.rb +312 -0
- data/lib/rdoc/markup/parser.rb +1 -1
- data/lib/rdoc/markup/raw.rb +52 -55
- data/lib/rdoc/markup/table.rb +48 -40
- data/lib/rdoc/markup/to_ansi.rb +51 -4
- data/lib/rdoc/markup/to_bs.rb +22 -42
- data/lib/rdoc/markup/to_html.rb +178 -183
- data/lib/rdoc/markup/to_html_crossref.rb +58 -79
- data/lib/rdoc/markup/to_html_snippet.rb +62 -62
- data/lib/rdoc/markup/to_label.rb +29 -20
- data/lib/rdoc/markup/to_markdown.rb +61 -37
- data/lib/rdoc/markup/to_rdoc.rb +86 -26
- data/lib/rdoc/markup/to_test.rb +9 -1
- data/lib/rdoc/markup/to_tt_only.rb +10 -16
- data/lib/rdoc/markup/verbatim.rb +1 -1
- data/lib/rdoc/markup.rb +11 -32
- data/lib/rdoc/options.rb +1 -1
- data/lib/rdoc/parser/changelog.rb +29 -0
- data/lib/rdoc/parser/prism_ruby.rb +44 -32
- data/lib/rdoc/parser/ruby.rb +1 -1
- data/lib/rdoc/rubygems_hook.rb +3 -3
- data/lib/rdoc/text.rb +44 -5
- data/lib/rdoc/token_stream.rb +4 -8
- data/lib/rdoc/version.rb +1 -1
- data/rdoc.gemspec +3 -3
- metadata +13 -15
- data/CONTRIBUTING.rdoc +0 -219
- data/ExampleMarkdown.md +0 -39
- data/ExampleRDoc.rdoc +0 -210
- data/lib/rdoc/markup/attr_changer.rb +0 -22
- data/lib/rdoc/markup/attr_span.rb +0 -35
- data/lib/rdoc/markup/attribute_manager.rb +0 -405
- data/lib/rdoc/markup/attributes.rb +0 -70
- data/lib/rdoc/markup/regexp_handling.rb +0 -40
|
@@ -107,8 +107,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
|
107
107
|
def accept_verbatim(verbatim)
|
|
108
108
|
throw :done if @characters >= @character_limit
|
|
109
109
|
input = verbatim.text.rstrip
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
text = truncate(input, @character_limit - @characters)
|
|
111
|
+
@characters += input.length
|
|
112
112
|
text << ' ...' unless text == input
|
|
113
113
|
|
|
114
114
|
super RDoc::Markup::Verbatim.new text
|
|
@@ -128,16 +128,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
|
128
128
|
##
|
|
129
129
|
# Removes escaping from the cross-references in +target+
|
|
130
130
|
|
|
131
|
-
def handle_regexp_CROSSREF(
|
|
132
|
-
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
##
|
|
136
|
-
# +target+ is a <code><br></code>
|
|
137
|
-
|
|
138
|
-
def handle_regexp_HARD_BREAK(target)
|
|
139
|
-
@characters -= 4
|
|
140
|
-
'<br>'
|
|
131
|
+
def handle_regexp_CROSSREF(text)
|
|
132
|
+
text.sub(/\A\\/, '')
|
|
141
133
|
end
|
|
142
134
|
|
|
143
135
|
##
|
|
@@ -212,74 +204,82 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
|
212
204
|
end_accepting
|
|
213
205
|
end
|
|
214
206
|
|
|
215
|
-
|
|
216
|
-
|
|
207
|
+
def handle_PLAIN_TEXT(text) # :nodoc:
|
|
208
|
+
return if inline_limit_reached?
|
|
217
209
|
|
|
218
|
-
|
|
219
|
-
|
|
210
|
+
truncated = truncate(text, @inline_character_limit)
|
|
211
|
+
@inline_character_limit -= text.size
|
|
212
|
+
emit_inline(convert_string(truncated))
|
|
213
|
+
end
|
|
220
214
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
flow.each do |item|
|
|
225
|
-
case item
|
|
226
|
-
when RDoc::Markup::AttrChanger then
|
|
227
|
-
off_tags res, item
|
|
228
|
-
on_tags res, item
|
|
229
|
-
when String then
|
|
230
|
-
text = convert_string item
|
|
231
|
-
res << truncate(text)
|
|
232
|
-
when RDoc::Markup::RegexpHandling then
|
|
233
|
-
text = convert_regexp_handling item
|
|
234
|
-
res << truncate(text)
|
|
235
|
-
else
|
|
236
|
-
raise "Unknown flow element: #{item.inspect}"
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
if @characters >= @character_limit then
|
|
240
|
-
off_tags res, RDoc::Markup::AttrChanger.new(0, @mask)
|
|
241
|
-
break
|
|
242
|
-
end
|
|
243
|
-
end
|
|
215
|
+
def handle_REGEXP_HANDLING_TEXT(text) # :nodoc:
|
|
216
|
+
return if inline_limit_reached?
|
|
244
217
|
|
|
245
|
-
|
|
218
|
+
# We can't truncate text including html tags.
|
|
219
|
+
# Just emit as is, and count all characters including html tag part.
|
|
220
|
+
emit_inline(text)
|
|
221
|
+
@inline_character_limit -= text.size
|
|
222
|
+
end
|
|
246
223
|
|
|
247
|
-
|
|
224
|
+
def handle_BOLD(nodes)
|
|
225
|
+
super unless inline_limit_reached?
|
|
248
226
|
end
|
|
249
227
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
228
|
+
def handle_BOLD_WORD(word)
|
|
229
|
+
super unless inline_limit_reached?
|
|
230
|
+
end
|
|
253
231
|
|
|
254
|
-
def
|
|
255
|
-
|
|
232
|
+
def handle_EM(nodes)
|
|
233
|
+
super unless inline_limit_reached?
|
|
234
|
+
end
|
|
256
235
|
|
|
257
|
-
|
|
236
|
+
def handle_EM_WORD(word)
|
|
237
|
+
super unless inline_limit_reached?
|
|
258
238
|
end
|
|
259
239
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
240
|
+
def handle_TT(code)
|
|
241
|
+
super unless inline_limit_reached?
|
|
242
|
+
end
|
|
263
243
|
|
|
264
|
-
def
|
|
265
|
-
|
|
244
|
+
def handle_STRIKE(nodes)
|
|
245
|
+
super unless inline_limit_reached?
|
|
246
|
+
end
|
|
266
247
|
|
|
267
|
-
|
|
248
|
+
def handle_HARD_BREAK
|
|
249
|
+
super unless inline_limit_reached?
|
|
268
250
|
end
|
|
269
251
|
|
|
270
|
-
|
|
271
|
-
|
|
252
|
+
def handle_TIDYLINK(label_part, url)
|
|
253
|
+
traverse_inline_nodes(label_part) unless inline_limit_reached?
|
|
254
|
+
end
|
|
272
255
|
|
|
273
|
-
def
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
@characters += length
|
|
256
|
+
def inline_limit_reached?
|
|
257
|
+
@inline_character_limit <= 0
|
|
258
|
+
end
|
|
277
259
|
|
|
278
|
-
|
|
260
|
+
def handle_inline(text)
|
|
261
|
+
limit = @character_limit - @characters
|
|
262
|
+
return ['', 0] if limit <= 0
|
|
263
|
+
@inline_character_limit = limit
|
|
264
|
+
res = super
|
|
265
|
+
res << ' ...' if @inline_character_limit <= 0
|
|
266
|
+
@characters += limit - @inline_character_limit
|
|
267
|
+
res
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def to_html(item)
|
|
271
|
+
throw :done if @characters >= @character_limit
|
|
272
|
+
to_html_characters(handle_inline(item))
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
##
|
|
276
|
+
# Truncates +text+ at the end of the first word after the limit.
|
|
279
277
|
|
|
280
|
-
|
|
278
|
+
def truncate(text, limit)
|
|
279
|
+
return text if limit >= text.size
|
|
280
|
+
return '' if limit <= 0
|
|
281
281
|
|
|
282
|
-
text =~ /\A(.{#{
|
|
282
|
+
text =~ /\A(.{#{limit},}?)(\s|$)/m # TODO word-break instead of \s?
|
|
283
283
|
|
|
284
284
|
$1
|
|
285
285
|
end
|
data/lib/rdoc/markup/to_label.rb
CHANGED
|
@@ -18,43 +18,53 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
|
|
|
18
18
|
super nil, markup
|
|
19
19
|
|
|
20
20
|
@markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
|
|
21
|
-
@markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
add_tag :EM, '', ''
|
|
22
|
+
@res = []
|
|
23
|
+
end
|
|
26
24
|
|
|
25
|
+
def handle_PLAIN_TEXT(text)
|
|
26
|
+
@res << text
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
30
|
+
@res << text
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def handle_TT(text)
|
|
34
|
+
@res << text
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def extract_plaintext(text)
|
|
27
38
|
@res = []
|
|
39
|
+
handle_inline(text)
|
|
40
|
+
@res.join
|
|
28
41
|
end
|
|
29
42
|
|
|
30
43
|
##
|
|
31
|
-
# Converts +text+ to an HTML-safe label
|
|
44
|
+
# Converts +text+ to an HTML-safe label using GitHub-style anchor formatting.
|
|
32
45
|
|
|
33
46
|
def convert(text)
|
|
34
|
-
label =
|
|
47
|
+
label = extract_plaintext(text)
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
RDoc::Text.to_anchor(label)
|
|
37
50
|
end
|
|
38
51
|
|
|
39
52
|
##
|
|
40
|
-
# Converts
|
|
41
|
-
#
|
|
53
|
+
# Converts +text+ to an HTML-safe label using legacy RDoc formatting.
|
|
54
|
+
# Used for generating backward-compatible anchor aliases.
|
|
42
55
|
|
|
43
|
-
def
|
|
44
|
-
|
|
56
|
+
def convert_legacy(text)
|
|
57
|
+
label = extract_plaintext(text)
|
|
45
58
|
|
|
46
|
-
|
|
59
|
+
CGI.escape(label).gsub('%', '-').sub(/^-/, '')
|
|
47
60
|
end
|
|
48
61
|
|
|
49
62
|
##
|
|
50
|
-
# Converts the
|
|
51
|
-
|
|
52
|
-
def handle_regexp_TIDYLINK(target)
|
|
53
|
-
text = target.text
|
|
54
|
-
|
|
55
|
-
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
|
|
63
|
+
# Converts the CROSSREF +target+ to plain text, removing the suppression
|
|
64
|
+
# marker, if any
|
|
56
65
|
|
|
57
|
-
|
|
66
|
+
def handle_regexp_CROSSREF(text)
|
|
67
|
+
text.sub(/^\\/, '')
|
|
58
68
|
end
|
|
59
69
|
|
|
60
70
|
alias accept_blank_line ignore
|
|
@@ -69,7 +79,6 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
|
|
|
69
79
|
alias accept_rule ignore
|
|
70
80
|
alias accept_verbatim ignore
|
|
71
81
|
alias end_accepting ignore
|
|
72
|
-
alias handle_regexp_HARD_BREAK ignore
|
|
73
82
|
alias start_accepting ignore
|
|
74
83
|
|
|
75
84
|
end
|
|
@@ -20,27 +20,10 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
|
20
20
|
@headings[6] = ['###### ', '']
|
|
21
21
|
|
|
22
22
|
add_regexp_handling_RDOCLINK
|
|
23
|
-
add_regexp_handling_TIDYLINK
|
|
24
23
|
|
|
25
24
|
@hard_break = " \n"
|
|
26
25
|
end
|
|
27
26
|
|
|
28
|
-
##
|
|
29
|
-
# Maps attributes to HTML sequences
|
|
30
|
-
|
|
31
|
-
def init_tags
|
|
32
|
-
add_tag :BOLD, '**', '**'
|
|
33
|
-
add_tag :EM, '*', '*'
|
|
34
|
-
add_tag :TT, '`', '`'
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
##
|
|
38
|
-
# Adds a newline to the output
|
|
39
|
-
|
|
40
|
-
def handle_regexp_HARD_BREAK(target)
|
|
41
|
-
" \n"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
27
|
##
|
|
45
28
|
# Finishes consumption of `list`
|
|
46
29
|
|
|
@@ -94,6 +77,65 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
|
94
77
|
end
|
|
95
78
|
end
|
|
96
79
|
|
|
80
|
+
def add_tag(tag, simple_tag, content)
|
|
81
|
+
if content.match?(/\A[\w\s]+\z/)
|
|
82
|
+
emit_inline("#{simple_tag}#{content}#{simple_tag}")
|
|
83
|
+
else
|
|
84
|
+
emit_inline("<#{tag}>#{content}</#{tag}>")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def handle_tag(nodes, simple_tag, tag)
|
|
89
|
+
if nodes.size == 1 && String === nodes[0]
|
|
90
|
+
content = apply_regexp_handling(nodes[0]).map do |text, converted|
|
|
91
|
+
converted ? text : convert_string(text)
|
|
92
|
+
end.join
|
|
93
|
+
add_tag(tag, simple_tag, content)
|
|
94
|
+
else
|
|
95
|
+
emit_inline("<#{tag}>")
|
|
96
|
+
traverse_inline_nodes(nodes)
|
|
97
|
+
emit_inline("</#{tag}>")
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def handle_TIDYLINK(label_part, url)
|
|
102
|
+
if url =~ /^rdoc-label:foot/ then
|
|
103
|
+
emit_inline(handle_rdoc_link(url))
|
|
104
|
+
else
|
|
105
|
+
emit_inline('[')
|
|
106
|
+
traverse_inline_nodes(label_part)
|
|
107
|
+
emit_inline("](#{url})")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def handle_BOLD(nodes)
|
|
112
|
+
handle_tag(nodes, '**', 'strong')
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def handle_EM(nodes)
|
|
116
|
+
handle_tag(nodes, '*', 'em')
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def handle_BOLD_WORD(word)
|
|
120
|
+
add_tag('strong', '**', convert_string(word))
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def handle_EM_WORD(word)
|
|
124
|
+
add_tag('em', '*', convert_string(word))
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def handle_TT(text)
|
|
128
|
+
add_tag('code', '`', convert_string(text))
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def handle_STRIKE(nodes)
|
|
132
|
+
handle_tag(nodes, '~~', 's')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def handle_HARD_BREAK
|
|
136
|
+
emit_inline(" \n")
|
|
137
|
+
end
|
|
138
|
+
|
|
97
139
|
##
|
|
98
140
|
# Prepares the visitor for consuming `list`
|
|
99
141
|
|
|
@@ -163,29 +205,11 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
|
163
205
|
end
|
|
164
206
|
end
|
|
165
207
|
|
|
166
|
-
##
|
|
167
|
-
# Converts the RDoc markup tidylink into a Markdown.style link.
|
|
168
|
-
|
|
169
|
-
def handle_regexp_TIDYLINK(target)
|
|
170
|
-
text = target.text
|
|
171
|
-
|
|
172
|
-
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
|
|
173
|
-
|
|
174
|
-
label = $1
|
|
175
|
-
url = $2
|
|
176
|
-
|
|
177
|
-
if url =~ /^rdoc-label:foot/ then
|
|
178
|
-
handle_rdoc_link url
|
|
179
|
-
else
|
|
180
|
-
gen_url url, label
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
208
|
##
|
|
185
209
|
# Converts the rdoc-...: links into a Markdown.style links.
|
|
186
210
|
|
|
187
|
-
def handle_regexp_RDOCLINK(
|
|
188
|
-
handle_rdoc_link
|
|
211
|
+
def handle_regexp_RDOCLINK(text)
|
|
212
|
+
handle_rdoc_link text
|
|
189
213
|
end
|
|
190
214
|
|
|
191
215
|
end
|
data/lib/rdoc/markup/to_rdoc.rb
CHANGED
|
@@ -57,21 +57,11 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
|
57
57
|
|
|
58
58
|
@markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
|
|
59
59
|
@width = 78
|
|
60
|
-
init_tags
|
|
61
60
|
|
|
62
61
|
@headings = DEFAULT_HEADINGS.dup
|
|
63
62
|
@hard_break = "\n"
|
|
64
63
|
end
|
|
65
64
|
|
|
66
|
-
##
|
|
67
|
-
# Maps attributes to HTML sequences
|
|
68
|
-
|
|
69
|
-
def init_tags
|
|
70
|
-
add_tag :BOLD, "<b>", "</b>"
|
|
71
|
-
add_tag :TT, "<tt>", "</tt>"
|
|
72
|
-
add_tag :EM, "<em>", "</em>"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
65
|
##
|
|
76
66
|
# Adds +blank_line+ to the output
|
|
77
67
|
|
|
@@ -253,7 +243,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
|
253
243
|
header = header.map { |h| attributes h }
|
|
254
244
|
body = body.map { |row| row.map { |t| attributes t } }
|
|
255
245
|
widths = header.zip(*body).map do |cols|
|
|
256
|
-
cols.map { |col| calculate_text_width(col) }.max
|
|
246
|
+
cols.compact.map { |col| calculate_text_width(col) }.max
|
|
257
247
|
end
|
|
258
248
|
aligns = aligns.map do |a|
|
|
259
249
|
case a
|
|
@@ -271,7 +261,8 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
|
271
261
|
end.join("|").rstrip << "\n"
|
|
272
262
|
@res << widths.map {|w| "-" * w }.join("|") << "\n"
|
|
273
263
|
body.each do |row|
|
|
274
|
-
@res <<
|
|
264
|
+
@res << widths.zip(aligns).each_with_index.map do |(w, a), i|
|
|
265
|
+
t = row[i] || ""
|
|
275
266
|
extra_width = t.size - calculate_text_width(t)
|
|
276
267
|
t.__send__(a, w + extra_width)
|
|
277
268
|
end.join("|").rstrip << "\n"
|
|
@@ -282,12 +273,90 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
|
282
273
|
text.size
|
|
283
274
|
end
|
|
284
275
|
|
|
276
|
+
def handle_PLAIN_TEXT(text)
|
|
277
|
+
add_text(text)
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
281
|
+
add_text(text)
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def handle_BOLD(target)
|
|
285
|
+
on(:BOLD)
|
|
286
|
+
super
|
|
287
|
+
off(:BOLD)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def handle_EM(target)
|
|
291
|
+
on(:EM)
|
|
292
|
+
super
|
|
293
|
+
off(:EM)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def handle_BOLD_WORD(word)
|
|
297
|
+
on(:BOLD)
|
|
298
|
+
super
|
|
299
|
+
off(:BOLD)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def handle_EM_WORD(word)
|
|
303
|
+
on(:EM)
|
|
304
|
+
super
|
|
305
|
+
off(:EM)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def handle_TT(code)
|
|
309
|
+
on(:TT)
|
|
310
|
+
super
|
|
311
|
+
off(:TT)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def handle_STRIKE(target)
|
|
315
|
+
on(:STRIKE)
|
|
316
|
+
super
|
|
317
|
+
off(:STRIKE)
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def handle_HARD_BREAK
|
|
321
|
+
add_text("\n")
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def handle_TIDYLINK(label_part, url)
|
|
325
|
+
super
|
|
326
|
+
add_text("( #{url} )")
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def handle_inline(text, initial_attributes = [])
|
|
330
|
+
@attributes = Hash.new(0)
|
|
331
|
+
initial_attributes.each { |attr| on(attr) }
|
|
332
|
+
out = @inline_output = +''
|
|
333
|
+
super(text)
|
|
334
|
+
@inline_output = nil
|
|
335
|
+
out
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def on(attr)
|
|
339
|
+
@attributes[attr] += 1
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def off(attr)
|
|
343
|
+
@attributes[attr] -= 1
|
|
344
|
+
@attributes.delete(attr) if @attributes[attr] == 0
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def add_text(text)
|
|
348
|
+
emit_inline(text)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def emit_inline(text)
|
|
352
|
+
@inline_output << text
|
|
353
|
+
end
|
|
354
|
+
|
|
285
355
|
##
|
|
286
|
-
# Applies attribute-specific markup to +text+ using RDoc::
|
|
356
|
+
# Applies attribute-specific markup to +text+ using RDoc::Markup::InlineParser
|
|
287
357
|
|
|
288
358
|
def attributes(text)
|
|
289
|
-
|
|
290
|
-
convert_flow flow
|
|
359
|
+
handle_inline(text)
|
|
291
360
|
end
|
|
292
361
|
|
|
293
362
|
##
|
|
@@ -300,17 +369,8 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
|
300
369
|
##
|
|
301
370
|
# Removes preceding \\ from the suppressed crossref +target+
|
|
302
371
|
|
|
303
|
-
def handle_regexp_SUPPRESSED_CROSSREF(
|
|
304
|
-
text
|
|
305
|
-
text = text.sub('\\', '') unless in_tt?
|
|
306
|
-
text
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
##
|
|
310
|
-
# Adds a newline to the output
|
|
311
|
-
|
|
312
|
-
def handle_regexp_HARD_BREAK(target)
|
|
313
|
-
"\n"
|
|
372
|
+
def handle_regexp_SUPPRESSED_CROSSREF(text)
|
|
373
|
+
text.sub('\\', '')
|
|
314
374
|
end
|
|
315
375
|
|
|
316
376
|
##
|
data/lib/rdoc/markup/to_test.rb
CHANGED
|
@@ -18,8 +18,16 @@ class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
|
|
18
18
|
@res
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def handle_PLAIN_TEXT(text)
|
|
22
|
+
@res << text
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
26
|
+
@res << text
|
|
27
|
+
end
|
|
28
|
+
|
|
21
29
|
def accept_paragraph(paragraph)
|
|
22
|
-
|
|
30
|
+
handle_inline(paragraph.text)
|
|
23
31
|
end
|
|
24
32
|
|
|
25
33
|
def accept_raw(raw)
|
|
@@ -20,8 +20,6 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
|
|
|
20
20
|
|
|
21
21
|
def initialize(markup = nil)
|
|
22
22
|
super nil, markup
|
|
23
|
-
|
|
24
|
-
add_tag :TT, nil, nil
|
|
25
23
|
end
|
|
26
24
|
|
|
27
25
|
##
|
|
@@ -82,22 +80,18 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
|
|
|
82
80
|
# Extracts tt sections from +text+
|
|
83
81
|
|
|
84
82
|
def tt_sections(text)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
off_tags res, item
|
|
93
|
-
on_tags res, item
|
|
94
|
-
when RDoc::Markup::RegexpHandling then
|
|
95
|
-
@res << convert_regexp_handling(item) if in_tt? # TODO can this happen?
|
|
83
|
+
parsed = RDoc::Markup::InlineParser.new(text).parse
|
|
84
|
+
traverse = -> node {
|
|
85
|
+
next if String === node
|
|
86
|
+
if node[:type] == :TT
|
|
87
|
+
res << nil
|
|
88
|
+
res << node[:children][0] || ''
|
|
89
|
+
res << nil
|
|
96
90
|
else
|
|
97
|
-
|
|
91
|
+
node[:children].each(&traverse)
|
|
98
92
|
end
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
}
|
|
94
|
+
parsed.each(&traverse)
|
|
101
95
|
res
|
|
102
96
|
end
|
|
103
97
|
|
data/lib/rdoc/markup/verbatim.rb
CHANGED
data/lib/rdoc/markup.rb
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
#
|
|
17
17
|
# - +rdoc+:
|
|
18
18
|
# the +RDoc+ markup format;
|
|
19
|
-
# see RDoc
|
|
19
|
+
# see {RDoc Markup Reference}[rdoc-ref:doc/markup_reference/rdoc.rdoc]
|
|
20
20
|
# - +markdown+:
|
|
21
21
|
# The +markdown+ markup format as described in
|
|
22
22
|
# the {Markdown Guide}[https://www.markdownguide.org];
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
#
|
|
80
80
|
# class WikiHtml < RDoc::Markup::ToHtml
|
|
81
81
|
# def handle_regexp_WIKIWORD(target)
|
|
82
|
-
# "<font color=red>" + target
|
|
82
|
+
# "<font color=red>" + target + "</font>"
|
|
83
83
|
# end
|
|
84
84
|
# end
|
|
85
85
|
#
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
#
|
|
103
103
|
# = \RDoc Markup Reference
|
|
104
104
|
#
|
|
105
|
-
# See RDoc
|
|
105
|
+
# See {RDoc Markup Reference}[rdoc-ref:doc/markup_reference/rdoc.rdoc]
|
|
106
106
|
#
|
|
107
107
|
#--
|
|
108
108
|
# Original Author:: Dave Thomas, dave@pragmaticprogrammer.com
|
|
@@ -110,10 +110,10 @@
|
|
|
110
110
|
|
|
111
111
|
class RDoc::Markup
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
#
|
|
113
|
+
# Array of regexp handling pattern and its name. A regexp handling
|
|
114
|
+
# sequence is something like a WikiWord
|
|
115
115
|
|
|
116
|
-
attr_reader :
|
|
116
|
+
attr_reader :regexp_handlings
|
|
117
117
|
|
|
118
118
|
##
|
|
119
119
|
# Parses +str+ into an RDoc::Markup::Document.
|
|
@@ -148,27 +148,11 @@ https://github.com/ruby/rdoc/issues
|
|
|
148
148
|
# structure (paragraphs, lists, and so on). Invoke an event handler as we
|
|
149
149
|
# identify significant chunks.
|
|
150
150
|
|
|
151
|
-
def initialize
|
|
152
|
-
@
|
|
151
|
+
def initialize
|
|
152
|
+
@regexp_handlings = []
|
|
153
153
|
@output = nil
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
-
##
|
|
157
|
-
# Add to the sequences used to add formatting to an individual word (such
|
|
158
|
-
# as *bold*). Matching entries will generate attributes that the output
|
|
159
|
-
# formatters can recognize by their +name+.
|
|
160
|
-
|
|
161
|
-
def add_word_pair(start, stop, name)
|
|
162
|
-
@attribute_manager.add_word_pair(start, stop, name)
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
##
|
|
166
|
-
# Add to the sequences recognized as general markup.
|
|
167
|
-
|
|
168
|
-
def add_html(tag, name)
|
|
169
|
-
@attribute_manager.add_html(tag, name)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
156
|
##
|
|
173
157
|
# Add to other inline sequences. For example, we could add WikiWords using
|
|
174
158
|
# something like:
|
|
@@ -178,7 +162,7 @@ https://github.com/ruby/rdoc/issues
|
|
|
178
162
|
# Each wiki word will be presented to the output formatter.
|
|
179
163
|
|
|
180
164
|
def add_regexp_handling(pattern, name)
|
|
181
|
-
@
|
|
165
|
+
@regexp_handlings << [pattern, name]
|
|
182
166
|
end
|
|
183
167
|
|
|
184
168
|
##
|
|
@@ -197,19 +181,14 @@ https://github.com/ruby/rdoc/issues
|
|
|
197
181
|
end
|
|
198
182
|
|
|
199
183
|
autoload :Parser, "#{__dir__}/markup/parser"
|
|
184
|
+
autoload :InlineParser, "#{__dir__}/markup/inline_parser"
|
|
200
185
|
autoload :PreProcess, "#{__dir__}/markup/pre_process"
|
|
201
186
|
|
|
202
|
-
# Inline markup classes
|
|
203
|
-
autoload :AttrChanger, "#{__dir__}/markup/attr_changer"
|
|
204
|
-
autoload :AttrSpan, "#{__dir__}/markup/attr_span"
|
|
205
|
-
autoload :Attributes, "#{__dir__}/markup/attributes"
|
|
206
|
-
autoload :AttributeManager, "#{__dir__}/markup/attribute_manager"
|
|
207
|
-
autoload :RegexpHandling, "#{__dir__}/markup/regexp_handling"
|
|
208
|
-
|
|
209
187
|
# RDoc::Markup AST
|
|
210
188
|
autoload :BlankLine, "#{__dir__}/markup/blank_line"
|
|
211
189
|
autoload :BlockQuote, "#{__dir__}/markup/block_quote"
|
|
212
190
|
autoload :Document, "#{__dir__}/markup/document"
|
|
191
|
+
autoload :Element, "#{__dir__}/markup/element"
|
|
213
192
|
autoload :HardBreak, "#{__dir__}/markup/hard_break"
|
|
214
193
|
autoload :Heading, "#{__dir__}/markup/heading"
|
|
215
194
|
autoload :Include, "#{__dir__}/markup/include"
|