rdoc 8.0.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 +1 -3
- data/RI.md +75 -75
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +71 -69
- data/lib/rdoc/code_object/any_method.rb +305 -303
- data/lib/rdoc/code_object/attr.rb +150 -148
- data/lib/rdoc/code_object/class_module.rb +798 -792
- data/lib/rdoc/code_object/constant.rb +175 -173
- data/lib/rdoc/code_object/context/section.rb +142 -138
- data/lib/rdoc/code_object/context.rb +926 -958
- 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 +326 -319
- 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 -219
- data/lib/rdoc/code_object.rb +305 -303
- data/lib/rdoc/comment.rb +275 -273
- data/lib/rdoc/cross_reference.rb +192 -190
- 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 +161 -153
- data/lib/rdoc/generator/darkfish.rb +645 -635
- data/lib/rdoc/generator/json_index.rb +233 -229
- data/lib/rdoc/generator/markup.rb +164 -146
- 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 +6 -4
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
- data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
- data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
- 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 +15 -11
- data/lib/rdoc/markdown.rb +40 -47
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/formatter.rb +219 -215
- 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 +283 -279
- 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 +594 -565
- data/lib/rdoc/markup/to_html_crossref.rb +234 -230
- data/lib/rdoc/markup/to_html_snippet.rb +232 -227
- data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
- 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 +84 -80
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +198 -196
- data/lib/rdoc/options.rb +1063 -1061
- data/lib/rdoc/parser/c.rb +1039 -1037
- data/lib/rdoc/parser/changelog.rb +319 -315
- data/lib/rdoc/parser/markdown.rb +17 -13
- data/lib/rdoc/parser/rbs.rb +239 -235
- data/lib/rdoc/parser/rd.rb +17 -13
- data/lib/rdoc/parser/ruby.rb +1245 -1124
- data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
- data/lib/rdoc/parser/simple.rb +31 -27
- data/lib/rdoc/parser/text.rb +12 -8
- data/lib/rdoc/parser.rb +228 -220
- data/lib/rdoc/rbs_helper.rb +1 -1
- data/lib/rdoc/rd/inline.rb +57 -53
- data/lib/rdoc/rd.rb +90 -88
- data/lib/rdoc/rdoc.rb +500 -491
- data/lib/rdoc/ri/driver.rb +1140 -1135
- data/lib/rdoc/ri/formatter.rb +7 -3
- data/lib/rdoc/ri/paths.rb +140 -136
- data/lib/rdoc/ri/servlet.rb +354 -350
- data/lib/rdoc/ri/store.rb +4 -2
- data/lib/rdoc/ri/task.rb +55 -51
- data/lib/rdoc/ri.rb +14 -12
- data/lib/rdoc/rubygems_hook.rb +183 -181
- data/lib/rdoc/server.rb +349 -347
- 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 +365 -363
- data/lib/rdoc/store.rb +888 -902
- data/lib/rdoc/task.rb +260 -256
- data/lib/rdoc/text.rb +135 -133
- data/lib/rdoc/token_stream.rb +101 -93
- data/lib/rdoc/tom_doc.rb +203 -201
- data/lib/rdoc/version.rb +1 -1
- metadata +4 -5
- data/lib/rdoc/markdown/literals.kpeg +0 -21
- data/lib/rdoc/markdown/literals.rb +0 -454
|
@@ -12,274 +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
|
+
##
|
|
20
|
+
# Converts a target url to one that is relative to a given path
|
|
19
21
|
|
|
20
|
-
|
|
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
|
+
from = from.split "/"
|
|
27
|
+
to = to.split "/"
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
from.delete '.'
|
|
30
|
+
to.delete '.'
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
from.fill ".."
|
|
36
|
-
from.concat to
|
|
37
|
-
from << to_file
|
|
38
|
-
File.join(*from)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
##
|
|
42
|
-
# Creates a new Formatter
|
|
32
|
+
while from.size > 0 and to.size > 0 and from[0] == to[0] do
|
|
33
|
+
from.shift
|
|
34
|
+
to.shift
|
|
35
|
+
end
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
from.fill ".."
|
|
38
|
+
from.concat to
|
|
39
|
+
from << to_file
|
|
40
|
+
File.join(*from)
|
|
41
|
+
end
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
##
|
|
44
|
+
# Creates a new Formatter
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
def initialize
|
|
47
|
+
@markup = Markup.new
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
document.parts.each do |item|
|
|
55
|
-
case item
|
|
56
|
-
when RDoc::Markup::Document then # HACK
|
|
57
|
-
accept_document item
|
|
58
|
-
else
|
|
59
|
-
item.accept self
|
|
49
|
+
@from_path = '.'
|
|
60
50
|
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
end
|
|
66
|
+
##
|
|
67
|
+
# Adds a regexp handling for links of the form rdoc-...:
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
def add_regexp_handling_RDOCLINK
|
|
70
|
+
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
|
|
71
|
+
end
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
end
|
|
73
|
+
##
|
|
74
|
+
# Allows +tag+ to be decorated with additional information.
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
def annotate(tag)
|
|
77
|
+
tag
|
|
78
|
+
end
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end
|
|
80
|
+
##
|
|
81
|
+
# Marks up +content+
|
|
84
82
|
|
|
85
|
-
|
|
83
|
+
def convert(content)
|
|
84
|
+
@markup.convert content, self
|
|
85
|
+
end
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
|
94
115
|
end
|
|
95
|
-
end
|
|
96
|
-
# If the start positions are the same, prefer the earlier-registered one
|
|
97
|
-
# (lower numeric priority from each_with_index).
|
|
98
|
-
matched.sort_by! {|beg_pos, _, _, _, priority| [beg_pos, priority] }
|
|
99
|
-
|
|
100
|
-
pos = 0
|
|
101
|
-
output = []
|
|
102
|
-
matched.each do |beg_pos, end_pos, s, name|
|
|
103
|
-
next if beg_pos < pos
|
|
104
|
-
|
|
105
|
-
output << [text[pos...beg_pos], false] if beg_pos != pos
|
|
106
|
-
handled = public_send(:"handle_regexp_#{name}", s)
|
|
107
|
-
output << [handled, true]
|
|
108
|
-
pos = end_pos
|
|
109
|
-
end
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
117
|
+
# Called when processing plain text while traversing inline nodes from handle_inline.
|
|
118
|
+
# +text+ may need proper escaping.
|
|
114
119
|
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
def handle_PLAIN_TEXT(text)
|
|
121
|
+
end
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
# Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.
|
|
124
|
+
# +text+ may contain markup tags.
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
127
|
+
end
|
|
123
128
|
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
126
141
|
|
|
127
|
-
|
|
128
|
-
# 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.
|
|
129
143
|
|
|
130
|
-
|
|
131
|
-
apply_regexp_handling(text).each do |part, converted|
|
|
132
|
-
if converted
|
|
133
|
-
handle_REGEXP_HANDLING_TEXT(part)
|
|
134
|
-
else
|
|
135
|
-
handle_PLAIN_TEXT(part)
|
|
144
|
+
def handle_HARD_BREAK
|
|
136
145
|
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
146
|
|
|
140
|
-
|
|
147
|
+
# Called when processing bold nodes while traversing inline nodes from handle_inline.
|
|
148
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
141
149
|
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
def handle_BOLD(nodes)
|
|
151
|
+
traverse_inline_nodes(nodes)
|
|
152
|
+
end
|
|
144
153
|
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
# Called when processing emphasis nodes while traversing inline nodes from handle_inline.
|
|
155
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
147
156
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
def handle_EM(nodes)
|
|
158
|
+
traverse_inline_nodes(nodes)
|
|
159
|
+
end
|
|
151
160
|
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
# Called when processing bold word nodes while traversing inline nodes from handle_inline.
|
|
162
|
+
# +word+ may need proper escaping.
|
|
154
163
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
def handle_BOLD_WORD(word)
|
|
165
|
+
handle_PLAIN_TEXT(word)
|
|
166
|
+
end
|
|
158
167
|
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
# Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
|
|
169
|
+
# +word+ may need proper escaping.
|
|
161
170
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
def handle_EM_WORD(word)
|
|
172
|
+
handle_PLAIN_TEXT(word)
|
|
173
|
+
end
|
|
165
174
|
|
|
166
|
-
|
|
167
|
-
|
|
175
|
+
# Called when processing tt nodes while traversing inline nodes from handle_inline.
|
|
176
|
+
# +code+ may need proper escaping.
|
|
168
177
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
178
|
+
def handle_TT(code)
|
|
179
|
+
handle_PLAIN_TEXT(code)
|
|
180
|
+
end
|
|
172
181
|
|
|
173
|
-
|
|
174
|
-
|
|
182
|
+
# Called when processing strike nodes while traversing inline nodes from handle_inline.
|
|
183
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
175
184
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
def handle_STRIKE(nodes)
|
|
186
|
+
traverse_inline_nodes(nodes)
|
|
187
|
+
end
|
|
179
188
|
|
|
180
|
-
|
|
181
|
-
|
|
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.
|
|
182
193
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
194
|
+
def handle_TIDYLINK(label_part, url)
|
|
195
|
+
traverse_inline_nodes(label_part)
|
|
196
|
+
end
|
|
186
197
|
|
|
187
|
-
|
|
188
|
-
# +label_part+ is an array of strings or nodes representing the link label.
|
|
189
|
-
# +url+ is the link URL.
|
|
190
|
-
# 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.
|
|
191
199
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
200
|
+
def handle_inline(text)
|
|
201
|
+
nodes = Markup::InlineParser.new(text).parse
|
|
202
|
+
traverse_inline_nodes(nodes)
|
|
203
|
+
end
|
|
195
204
|
|
|
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
|
-
traverse_inline_nodes(nodes)
|
|
201
|
-
end
|
|
232
|
+
##
|
|
233
|
+
# Converts a string to be fancier if desired
|
|
202
234
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
def traverse_inline_nodes(nodes)
|
|
207
|
-
nodes.each do |node|
|
|
208
|
-
next handle_TEXT(node) if String === node
|
|
209
|
-
case node[:type]
|
|
210
|
-
when :TIDYLINK
|
|
211
|
-
handle_TIDYLINK(node[:children], node[:url])
|
|
212
|
-
when :HARD_BREAK
|
|
213
|
-
handle_HARD_BREAK
|
|
214
|
-
when :BOLD
|
|
215
|
-
handle_BOLD(node[:children])
|
|
216
|
-
when :BOLD_WORD
|
|
217
|
-
handle_BOLD_WORD(node[:children][0] || '')
|
|
218
|
-
when :EM
|
|
219
|
-
handle_EM(node[:children])
|
|
220
|
-
when :EM_WORD
|
|
221
|
-
handle_EM_WORD(node[:children][0] || '')
|
|
222
|
-
when :TT
|
|
223
|
-
handle_TT(node[:children][0] || '')
|
|
224
|
-
when :STRIKE
|
|
225
|
-
handle_STRIKE(node[:children])
|
|
235
|
+
def convert_string(string)
|
|
236
|
+
string
|
|
226
237
|
end
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
238
|
|
|
230
|
-
|
|
231
|
-
|
|
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
|
|
232
246
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
end
|
|
247
|
+
def ignore(*node)
|
|
248
|
+
end
|
|
236
249
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
244
279
|
|
|
245
|
-
|
|
246
|
-
|
|
280
|
+
##
|
|
281
|
+
# Is +tag+ a tt tag?
|
|
247
282
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
def parse_url(url)
|
|
252
|
-
case url
|
|
253
|
-
when /^rdoc-label:([^:]*)(?::(.*))?/ then
|
|
254
|
-
scheme = 'link'
|
|
255
|
-
path = "##{$1}"
|
|
256
|
-
id = " id=\"#{$2}\"" if $2
|
|
257
|
-
when /([A-Za-z]+):(.*)/ then
|
|
258
|
-
scheme = $1.downcase
|
|
259
|
-
path = $2
|
|
260
|
-
when /^#/ then
|
|
261
|
-
else
|
|
262
|
-
scheme = 'http'
|
|
263
|
-
path = url
|
|
264
|
-
url = url
|
|
265
|
-
end
|
|
283
|
+
def tt?(tag)
|
|
284
|
+
tag.bit == @tt_bit
|
|
285
|
+
end
|
|
266
286
|
|
|
267
|
-
if scheme == 'link' then
|
|
268
|
-
url = if path[0, 1] == '#' then # is this meaningful?
|
|
269
|
-
path
|
|
270
|
-
else
|
|
271
|
-
self.class.gen_relative_url @from_path, path
|
|
272
|
-
end
|
|
273
287
|
end
|
|
274
|
-
|
|
275
|
-
[scheme, url, id]
|
|
276
288
|
end
|
|
277
|
-
|
|
278
|
-
##
|
|
279
|
-
# Is +tag+ a tt tag?
|
|
280
|
-
|
|
281
|
-
def tt?(tag)
|
|
282
|
-
tag.bit == @tt_bit
|
|
283
|
-
end
|
|
284
|
-
|
|
285
289
|
end
|
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
|