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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +193 -0
- data/LEGAL.rdoc +6 -0
- data/LICENSE.rdoc +4 -0
- data/README.md +132 -8
- data/RI.md +75 -75
- data/doc/markup_reference/markdown.md +659 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +70 -74
- data/lib/rdoc/code_object/any_method.rb +308 -293
- data/lib/rdoc/code_object/attr.rb +150 -142
- data/lib/rdoc/code_object/class_module.rb +802 -715
- data/lib/rdoc/code_object/constant.rb +181 -144
- data/lib/rdoc/code_object/context/section.rb +140 -130
- data/lib/rdoc/code_object/context.rb +925 -941
- data/lib/rdoc/code_object/extend.rb +7 -5
- data/lib/rdoc/code_object/include.rb +7 -5
- data/lib/rdoc/code_object/method_attr.rb +328 -315
- data/lib/rdoc/code_object/mixin.rb +97 -92
- data/lib/rdoc/code_object/normal_class.rb +77 -78
- data/lib/rdoc/code_object/normal_module.rb +61 -59
- data/lib/rdoc/code_object/require.rb +23 -39
- data/lib/rdoc/code_object/single_class.rb +21 -19
- data/lib/rdoc/code_object/top_level.rb +215 -202
- data/lib/rdoc/code_object.rb +305 -305
- data/lib/rdoc/comment.rb +274 -337
- data/lib/rdoc/cross_reference.rb +195 -206
- data/lib/rdoc/encoding.rb +105 -103
- data/lib/rdoc/erb_partial.rb +13 -11
- data/lib/rdoc/erbio.rb +29 -27
- data/lib/rdoc/generator/aliki.rb +196 -30
- data/lib/rdoc/generator/darkfish.rb +647 -629
- data/lib/rdoc/generator/json_index.rb +233 -229
- data/lib/rdoc/generator/markup.rb +165 -122
- data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
- data/lib/rdoc/generator/pot/po.rb +52 -51
- data/lib/rdoc/generator/pot/po_entry.rb +138 -132
- data/lib/rdoc/generator/pot.rb +85 -81
- data/lib/rdoc/generator/ri.rb +23 -19
- data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/aliki/_head.rhtml +15 -10
- data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +3 -3
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +3 -3
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/class.rhtml +71 -61
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +796 -323
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +119 -113
- 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 +2 -2
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/class.rhtml +29 -32
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -1
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/generator.rb +48 -46
- data/lib/rdoc/i18n/locale.rb +99 -95
- data/lib/rdoc/i18n/text.rb +109 -105
- data/lib/rdoc/i18n.rb +7 -5
- data/lib/rdoc/markdown/byte_runtime.rb +80 -0
- data/lib/rdoc/markdown.kpeg +52 -33
- data/lib/rdoc/markdown.rb +365 -177
- data/lib/rdoc/markup/blank_line.rb +25 -23
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/formatter.rb +220 -203
- data/lib/rdoc/markup/hard_break.rb +30 -27
- data/lib/rdoc/markup/heading.rb +163 -77
- data/lib/rdoc/markup/include.rb +33 -29
- data/lib/rdoc/markup/indented_paragraph.rb +37 -33
- data/lib/rdoc/markup/inline_parser.rb +316 -0
- data/lib/rdoc/markup/list.rb +80 -88
- data/lib/rdoc/markup/list_item.rb +73 -85
- data/lib/rdoc/markup/paragraph.rb +23 -19
- data/lib/rdoc/markup/parser.rb +501 -497
- data/lib/rdoc/markup/pre_process.rb +284 -305
- data/lib/rdoc/markup/raw.rb +52 -55
- data/lib/rdoc/markup/rule.rb +16 -12
- data/lib/rdoc/markup/table.rb +48 -40
- data/lib/rdoc/markup/to_ansi.rb +143 -92
- data/lib/rdoc/markup/to_bs.rb +86 -102
- data/lib/rdoc/markup/to_html.rb +608 -506
- data/lib/rdoc/markup/to_html_crossref.rb +219 -210
- data/lib/rdoc/markup/to_html_snippet.rb +210 -205
- data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
- data/lib/rdoc/markup/to_label.rb +64 -51
- data/lib/rdoc/markup/to_markdown.rb +212 -184
- data/lib/rdoc/markup/to_rdoc.rb +341 -277
- data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
- data/lib/rdoc/markup/to_test.rb +62 -50
- data/lib/rdoc/markup/to_tt_only.rb +83 -92
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +196 -215
- data/lib/rdoc/options.rb +1063 -1076
- data/lib/rdoc/parser/c.rb +1039 -1036
- data/lib/rdoc/parser/changelog.rb +320 -287
- data/lib/rdoc/parser/markdown.rb +17 -13
- data/lib/rdoc/parser/rbs.rb +279 -0
- data/lib/rdoc/parser/rd.rb +17 -13
- data/lib/rdoc/parser/ruby.rb +1231 -2222
- data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
- data/lib/rdoc/parser/simple.rb +31 -27
- data/lib/rdoc/parser/text.rb +12 -8
- data/lib/rdoc/parser.rb +230 -221
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/inline.rb +57 -53
- data/lib/rdoc/rd.rb +90 -88
- data/lib/rdoc/rdoc.rb +547 -366
- data/lib/rdoc/ri/driver.rb +1141 -1130
- data/lib/rdoc/ri/formatter.rb +7 -3
- data/lib/rdoc/ri/paths.rb +140 -136
- data/lib/rdoc/ri/servlet.rb +456 -0
- data/lib/rdoc/ri/store.rb +4 -2
- data/lib/rdoc/ri/task.rb +55 -51
- data/lib/rdoc/ri.rb +14 -11
- data/lib/rdoc/rubygems_hook.rb +194 -192
- data/lib/rdoc/server.rb +462 -0
- data/lib/rdoc/stats/normal.rb +46 -42
- data/lib/rdoc/stats/quiet.rb +39 -35
- data/lib/rdoc/stats/verbose.rb +35 -31
- data/lib/rdoc/stats.rb +363 -338
- data/lib/rdoc/store.rb +919 -725
- data/lib/rdoc/task.rb +260 -255
- data/lib/rdoc/text.rb +164 -240
- data/lib/rdoc/token_stream.rb +88 -106
- data/lib/rdoc/tom_doc.rb +203 -201
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +35 -7
- data/lib/rubygems_plugin.rb +2 -11
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +9 -7
- metadata +46 -32
- data/CONTRIBUTING.rdoc +0 -219
- data/ExampleMarkdown.md +0 -39
- data/ExampleRDoc.rdoc +0 -210
- data/lib/rdoc/code_object/anon_class.rb +0 -10
- data/lib/rdoc/code_object/ghost_method.rb +0 -6
- data/lib/rdoc/code_object/meta_method.rb +0 -6
- data/lib/rdoc/markdown/literals.kpeg +0 -21
- data/lib/rdoc/markdown/literals.rb +0 -454
- 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
- data/lib/rdoc/parser/prism_ruby.rb +0 -1100
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
- data/lib/rdoc/parser/ruby_tools.rb +0 -163
- 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
|
-
|
|
13
|
+
require 'rdoc/markup/inline_parser'
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
module RDoc
|
|
16
|
+
class Markup
|
|
17
|
+
class Formatter
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
##
|
|
20
|
+
# Converts a target url to one that is relative to a given path
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
def self.gen_relative_url(path, target)
|
|
23
|
+
from = File.dirname path
|
|
24
|
+
to, to_file = File.split target
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
to, to_file = File.split target
|
|
26
|
+
from = from.split "/"
|
|
27
|
+
to = to.split "/"
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
from.delete '.'
|
|
30
|
+
to.delete '.'
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
49
|
-
|
|
43
|
+
##
|
|
44
|
+
# Creates a new Formatter
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@am.add_regexp_handling(/<br>/, :HARD_BREAK)
|
|
46
|
+
def initialize
|
|
47
|
+
@markup = Markup.new
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
@from_path = '.'
|
|
50
|
+
end
|
|
56
51
|
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
66
|
+
##
|
|
67
|
+
# Adds a regexp handling for links of the form rdoc-...:
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
def add_regexp_handling_RDOCLINK
|
|
70
|
+
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
|
|
71
|
+
end
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
##
|
|
74
|
+
# Allows +tag+ to be decorated with additional information.
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
80
|
+
##
|
|
81
|
+
# Marks up +content+
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
def convert(content)
|
|
84
|
+
@markup.convert content, self
|
|
85
|
+
end
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
end
|
|
120
|
+
def handle_PLAIN_TEXT(text)
|
|
121
|
+
end
|
|
100
122
|
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
@attr_tags << InlineTag.new(attr, start, stop)
|
|
108
|
-
end
|
|
126
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
127
|
+
end
|
|
109
128
|
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
114
|
-
tag
|
|
115
|
-
end
|
|
142
|
+
# Called when processing a hard break while traversing inline nodes from handle_inline.
|
|
116
143
|
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
def handle_HARD_BREAK
|
|
145
|
+
end
|
|
119
146
|
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
145
|
-
|
|
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
|
-
|
|
157
|
+
def handle_EM(nodes)
|
|
158
|
+
traverse_inline_nodes(nodes)
|
|
159
|
+
end
|
|
149
160
|
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
# Called when processing bold word nodes while traversing inline nodes from handle_inline.
|
|
162
|
+
# +word+ may need proper escaping.
|
|
152
163
|
|
|
153
|
-
|
|
164
|
+
def handle_BOLD_WORD(word)
|
|
165
|
+
handle_PLAIN_TEXT(word)
|
|
166
|
+
end
|
|
154
167
|
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
# Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
|
|
169
|
+
# +word+ may need proper escaping.
|
|
157
170
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
handled = true
|
|
171
|
+
def handle_EM_WORD(word)
|
|
172
|
+
handle_PLAIN_TEXT(word)
|
|
161
173
|
end
|
|
162
|
-
end
|
|
163
174
|
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
# Called when processing tt nodes while traversing inline nodes from handle_inline.
|
|
176
|
+
# +code+ may need proper escaping.
|
|
166
177
|
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
def handle_TT(code)
|
|
179
|
+
handle_PLAIN_TEXT(code)
|
|
180
|
+
end
|
|
169
181
|
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
185
|
+
def handle_STRIKE(nodes)
|
|
186
|
+
traverse_inline_nodes(nodes)
|
|
187
|
+
end
|
|
175
188
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
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
|
-
|
|
189
|
-
end
|
|
198
|
+
# Parses inline +text+, traverse the resulting nodes, and calls the appropriate handler methods.
|
|
190
199
|
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
def handle_inline(text)
|
|
201
|
+
nodes = Markup::InlineParser.new(text).parse
|
|
202
|
+
traverse_inline_nodes(nodes)
|
|
203
|
+
end
|
|
193
204
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
199
|
-
|
|
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
|
-
|
|
235
|
+
def convert_string(string)
|
|
236
|
+
string
|
|
237
|
+
end
|
|
207
238
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
247
|
+
def ignore(*node)
|
|
248
|
+
end
|
|
217
249
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
226
|
-
|
|
280
|
+
##
|
|
281
|
+
# Is +tag+ a tt tag?
|
|
227
282
|
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|