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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +4 -7
- data/LICENSE.rdoc +4 -0
- data/README.md +43 -2
- data/RI.md +75 -75
- data/doc/markup_reference/markdown.md +104 -3
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +70 -74
- data/lib/rdoc/code_object/any_method.rb +305 -298
- data/lib/rdoc/code_object/attr.rb +150 -143
- data/lib/rdoc/code_object/class_module.rb +801 -765
- data/lib/rdoc/code_object/constant.rb +178 -150
- data/lib/rdoc/code_object/context/section.rb +133 -160
- data/lib/rdoc/code_object/context.rb +925 -952
- 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 +325 -324
- data/lib/rdoc/code_object/mixin.rb +97 -95
- 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 +212 -213
- data/lib/rdoc/code_object.rb +305 -305
- data/lib/rdoc/comment.rb +274 -337
- data/lib/rdoc/cross_reference.rb +194 -212
- 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 +165 -140
- data/lib/rdoc/generator/darkfish.rb +647 -631
- 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 +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +11 -11
- 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 +2 -2
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
- 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 +56 -46
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +538 -283
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +80 -102
- 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 +1 -1
- 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 +18 -21
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +0 -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 +30 -21
- data/lib/rdoc/markdown.rb +329 -151
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/formatter.rb +215 -221
- data/lib/rdoc/markup/heading.rb +1 -4
- data/lib/rdoc/markup/include.rb +33 -29
- data/lib/rdoc/markup/indented_paragraph.rb +37 -33
- data/lib/rdoc/markup/inline_parser.rb +281 -277
- 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 +2 -2
- data/lib/rdoc/markup/rule.rb +16 -12
- data/lib/rdoc/markup/to_ansi.rb +143 -139
- data/lib/rdoc/markup/to_bs.rb +72 -68
- data/lib/rdoc/markup/to_html.rb +600 -493
- data/lib/rdoc/markup/to_html_crossref.rb +221 -191
- data/lib/rdoc/markup/to_html_snippet.rb +232 -227
- data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
- data/lib/rdoc/markup/to_label.rb +63 -59
- data/lib/rdoc/markup/to_markdown.rb +212 -208
- data/lib/rdoc/markup/to_rdoc.rb +336 -332
- data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
- data/lib/rdoc/markup/to_test.rb +60 -56
- data/lib/rdoc/markup/to_tt_only.rb +83 -86
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +198 -196
- data/lib/rdoc/options.rb +1063 -1076
- data/lib/rdoc/parser/c.rb +1039 -1036
- data/lib/rdoc/parser/changelog.rb +319 -315
- 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 +130 -245
- data/lib/rdoc/token_stream.rb +101 -115
- 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 +6 -4
- metadata +36 -20
- 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/parser/prism_ruby.rb +0 -1112
- 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
|
@@ -12,284 +12,278 @@
|
|
|
12
12
|
|
|
13
13
|
require 'rdoc/markup/inline_parser'
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
module RDoc
|
|
16
|
+
class Markup
|
|
17
|
+
class Formatter
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# +off+ triggers.
|
|
19
|
+
##
|
|
20
|
+
# Converts a target url to one that is relative to a given path
|
|
20
21
|
|
|
21
|
-
|
|
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
|
-
|
|
29
|
+
from.delete '.'
|
|
30
|
+
to.delete '.'
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
35
|
-
|
|
37
|
+
from.fill ".."
|
|
38
|
+
from.concat to
|
|
39
|
+
from << to_file
|
|
40
|
+
File.join(*from)
|
|
41
|
+
end
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
to.shift
|
|
40
|
-
end
|
|
43
|
+
##
|
|
44
|
+
# Creates a new Formatter
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
from << to_file
|
|
45
|
-
File.join(*from)
|
|
46
|
-
end
|
|
46
|
+
def initialize
|
|
47
|
+
@markup = Markup.new
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
@from_path = '.'
|
|
50
|
+
end
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
66
|
+
##
|
|
67
|
+
# Adds a regexp handling for links of the form rdoc-...:
|
|
55
68
|
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
def add_regexp_handling_RDOCLINK
|
|
70
|
+
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
|
|
71
|
+
end
|
|
58
72
|
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
##
|
|
74
|
+
# Allows +tag+ to be decorated with additional information.
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
80
|
+
##
|
|
81
|
+
# Marks up +content+
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
113
|
+
output << [text[pos..], false] if pos < text.size
|
|
114
|
+
output
|
|
115
|
+
end
|
|
89
116
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
end
|
|
117
|
+
# Called when processing plain text while traversing inline nodes from handle_inline.
|
|
118
|
+
# +text+ may need proper escaping.
|
|
93
119
|
|
|
94
|
-
|
|
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
|
-
|
|
126
|
-
|
|
123
|
+
# Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.
|
|
124
|
+
# +text+ may contain markup tags.
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
127
|
+
end
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
135
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
153
|
-
|
|
150
|
+
def handle_BOLD(nodes)
|
|
151
|
+
traverse_inline_nodes(nodes)
|
|
152
|
+
end
|
|
154
153
|
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
def handle_EM(nodes)
|
|
158
|
+
traverse_inline_nodes(nodes)
|
|
159
|
+
end
|
|
161
160
|
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
# Called when processing bold word nodes while traversing inline nodes from handle_inline.
|
|
162
|
+
# +word+ may need proper escaping.
|
|
164
163
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
def handle_BOLD_WORD(word)
|
|
165
|
+
handle_PLAIN_TEXT(word)
|
|
166
|
+
end
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
# Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
|
|
169
|
+
# +word+ may need proper escaping.
|
|
171
170
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
def handle_EM_WORD(word)
|
|
172
|
+
handle_PLAIN_TEXT(word)
|
|
173
|
+
end
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
# Called when processing tt nodes while traversing inline nodes from handle_inline.
|
|
176
|
+
# +code+ may need proper escaping.
|
|
178
177
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
def handle_TT(code)
|
|
179
|
+
handle_PLAIN_TEXT(code)
|
|
180
|
+
end
|
|
182
181
|
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
def handle_STRIKE(nodes)
|
|
186
|
+
traverse_inline_nodes(nodes)
|
|
187
|
+
end
|
|
189
188
|
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
def handle_TIDYLINK(label_part, url)
|
|
195
|
+
traverse_inline_nodes(label_part)
|
|
196
|
+
end
|
|
196
197
|
|
|
197
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
def handle_inline(text)
|
|
201
|
+
nodes = Markup::InlineParser.new(text).parse
|
|
202
|
+
traverse_inline_nodes(nodes)
|
|
203
|
+
end
|
|
205
204
|
|
|
206
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
traverse_inline_nodes(nodes)
|
|
211
|
-
end
|
|
232
|
+
##
|
|
233
|
+
# Converts a string to be fancier if desired
|
|
212
234
|
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
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
|
-
|
|
256
|
-
|
|
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
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
278
|
-
|
|
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
|
-
|
|
286
|
-
|
|
280
|
+
##
|
|
281
|
+
# Is +tag+ a tt tag?
|
|
287
282
|
|
|
288
|
-
|
|
289
|
-
|
|
283
|
+
def tt?(tag)
|
|
284
|
+
tag.bit == @tt_bit
|
|
285
|
+
end
|
|
290
286
|
|
|
291
|
-
|
|
292
|
-
tag.bit == @tt_bit
|
|
287
|
+
end
|
|
293
288
|
end
|
|
294
|
-
|
|
295
289
|
end
|
data/lib/rdoc/markup/heading.rb
CHANGED
|
@@ -52,10 +52,7 @@ module RDoc
|
|
|
52
52
|
#: () -> RDoc::Markup::ToHtml
|
|
53
53
|
def self.to_html
|
|
54
54
|
@to_html ||= begin
|
|
55
|
-
|
|
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(/^\\/, '')
|
data/lib/rdoc/markup/include.rb
CHANGED
|
@@ -1,42 +1,46 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
#
|
|
6
|
-
#
|
|
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
|
|
10
|
+
class Include
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
##
|
|
13
|
+
# The filename to be included, without extension
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
attr_reader :file
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
##
|
|
18
|
+
# Directories to search for #file
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
attr_reader :include_path
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
##
|
|
23
|
+
# Creates a new include that will import +file+ from +include_path+
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
def initialize(file, include_path)
|
|
26
|
+
@file = file
|
|
27
|
+
@include_path = include_path
|
|
28
|
+
end
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
2
|
+
module RDoc
|
|
3
|
+
class Markup
|
|
4
|
+
##
|
|
5
|
+
# An Indented Paragraph of text
|
|
4
6
|
|
|
5
|
-
class
|
|
7
|
+
class IndentedParagraph < Markup::Raw
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
##
|
|
10
|
+
# The indent in number of spaces
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
attr_reader :indent
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
##
|
|
15
|
+
# Creates a new IndentedParagraph containing +parts+ indented with +indent+
|
|
16
|
+
# spaces
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
def initialize(indent, *parts)
|
|
19
|
+
@indent = indent
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
super(*parts)
|
|
22
|
+
end
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
def ==(other) # :nodoc:
|
|
25
|
+
super and indent == other.indent
|
|
26
|
+
end
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
##
|
|
29
|
+
# Calls #accept_indented_paragraph on +visitor+
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|