rdoc 2.4.3 → 2.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +3 -1
- data/History.txt +68 -0
- data/LICENSE.txt +57 -0
- data/Manifest.txt +37 -19
- data/README.txt +2 -12
- data/Rakefile +12 -12
- data/bin/rdoc +4 -4
- data/lib/rdoc.rb +32 -9
- data/lib/rdoc/alias.rb +2 -2
- data/lib/rdoc/any_method.rb +108 -16
- data/lib/rdoc/attr.rb +87 -1
- data/lib/rdoc/class_module.rb +131 -5
- data/lib/rdoc/code_object.rb +28 -5
- data/lib/rdoc/constant.rb +22 -0
- data/lib/rdoc/context.rb +80 -37
- data/lib/rdoc/gauntlet.rb +48 -0
- data/lib/rdoc/generator/darkfish.rb +25 -23
- data/lib/rdoc/generator/markup.rb +6 -29
- data/lib/rdoc/generator/ri.rb +39 -189
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +17 -1
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/rdoc.css +38 -33
- data/lib/rdoc/include.rb +22 -0
- data/lib/rdoc/markup.rb +10 -262
- data/lib/rdoc/markup/attribute_manager.rb +57 -50
- data/lib/rdoc/markup/blank_line.rb +19 -0
- data/lib/rdoc/markup/document.rb +72 -0
- data/lib/rdoc/markup/formatter.rb +118 -0
- data/lib/rdoc/markup/formatter_test_case.rb +341 -0
- data/lib/rdoc/markup/heading.rb +17 -0
- data/lib/rdoc/markup/inline.rb +6 -5
- data/lib/rdoc/markup/list.rb +78 -0
- data/lib/rdoc/markup/list_item.rb +83 -0
- data/lib/rdoc/markup/paragraph.rb +66 -0
- data/lib/rdoc/markup/parser.rb +528 -0
- data/lib/rdoc/markup/rule.rb +17 -0
- data/lib/rdoc/markup/to_ansi.rb +72 -0
- data/lib/rdoc/markup/to_bs.rb +74 -0
- data/lib/rdoc/markup/to_html.rb +106 -172
- data/lib/rdoc/markup/to_html_crossref.rb +10 -4
- data/lib/rdoc/markup/to_rdoc.rb +243 -0
- data/lib/rdoc/markup/to_test.rb +27 -16
- data/lib/rdoc/markup/verbatim.rb +42 -0
- data/lib/rdoc/normal_class.rb +38 -1
- data/lib/rdoc/normal_module.rb +38 -8
- data/lib/rdoc/options.rb +39 -151
- data/lib/rdoc/parser.rb +36 -18
- data/lib/rdoc/parser/c.rb +102 -109
- data/lib/rdoc/parser/ruby.rb +359 -1662
- data/lib/rdoc/parser/ruby_tools.rb +157 -0
- data/lib/rdoc/parser/simple.rb +0 -2
- data/lib/rdoc/rdoc.rb +142 -82
- data/lib/rdoc/ri.rb +10 -0
- data/lib/rdoc/ri/driver.rb +674 -444
- data/lib/rdoc/ri/formatter.rb +2 -651
- data/lib/rdoc/ri/paths.rb +70 -45
- data/lib/rdoc/ri/store.rb +248 -0
- data/lib/rdoc/ruby_lex.rb +1284 -0
- data/lib/rdoc/ruby_token.rb +416 -0
- data/lib/rdoc/single_class.rb +5 -0
- data/lib/rdoc/stats.rb +152 -83
- data/lib/rdoc/task.rb +27 -49
- data/lib/rdoc/text.rb +130 -0
- data/lib/rdoc/tokenstream.rb +28 -9
- data/lib/rdoc/top_level.rb +49 -43
- data/test/hidden.zip.txt +1 -0
- data/test/test_attribute_manager.rb +9 -16
- data/test/test_rdoc_any_method.rb +23 -0
- data/test/test_rdoc_attr.rb +40 -0
- data/test/test_rdoc_class_module.rb +100 -0
- data/test/test_rdoc_code_object.rb +18 -2
- data/test/test_rdoc_context.rb +41 -0
- data/test/test_rdoc_generator_ri.rb +56 -0
- data/test/test_rdoc_markup.rb +21 -610
- data/test/test_rdoc_markup_attribute_manager.rb +14 -17
- data/test/test_rdoc_markup_document.rb +51 -0
- data/test/test_rdoc_markup_paragraph.rb +27 -0
- data/test/test_rdoc_markup_parser.rb +1327 -0
- data/test/test_rdoc_markup_to_ansi.rb +426 -0
- data/test/test_rdoc_markup_to_bs.rb +443 -0
- data/test/test_rdoc_markup_to_html.rb +183 -18
- data/test/test_rdoc_markup_to_html_crossref.rb +1 -3
- data/test/test_rdoc_markup_to_rdoc.rb +426 -0
- data/test/test_rdoc_normal_class.rb +17 -0
- data/test/test_rdoc_normal_module.rb +6 -6
- data/test/test_rdoc_options.rb +41 -0
- data/test/test_rdoc_parser.rb +66 -13
- data/test/test_rdoc_parser_c.rb +93 -38
- data/test/test_rdoc_parser_perl.rb +2 -3
- data/test/test_rdoc_parser_ruby.rb +291 -28
- data/test/test_rdoc_parser_simple.rb +48 -0
- data/test/test_rdoc_rdoc.rb +66 -0
- data/test/test_rdoc_ri_driver.rb +752 -38
- data/test/test_rdoc_ri_paths.rb +39 -0
- data/test/test_rdoc_ri_store.rb +309 -0
- data/test/test_rdoc_text.rb +157 -0
- data/test/test_rdoc_top_level.rb +35 -9
- data/test/xref_data.rb +9 -1
- data/test/xref_test_case.rb +8 -3
- metadata +110 -38
- metadata.gz.sig +0 -0
- data/lib/rdoc/cache.rb +0 -41
- data/lib/rdoc/diagram.rb +0 -340
- data/lib/rdoc/dot.rb +0 -249
- data/lib/rdoc/markup/fragments.rb +0 -377
- data/lib/rdoc/markup/lines.rb +0 -156
- data/lib/rdoc/markup/to_flow.rb +0 -211
- data/lib/rdoc/markup/to_latex.rb +0 -328
- data/lib/rdoc/markup/to_texinfo.rb +0 -73
- data/lib/rdoc/ri/cache.rb +0 -187
- data/lib/rdoc/ri/descriptions.rb +0 -156
- data/lib/rdoc/ri/display.rb +0 -340
- data/lib/rdoc/ri/reader.rb +0 -106
- data/lib/rdoc/ri/util.rb +0 -79
- data/lib/rdoc/ri/writer.rb +0 -68
- data/test/test_rdoc_ri_attribute_formatter.rb +0 -44
- data/test/test_rdoc_ri_default_display.rb +0 -302
- data/test/test_rdoc_ri_formatter.rb +0 -320
- data/test/test_rdoc_ri_html_formatter.rb +0 -141
- data/test/test_rdoc_ri_overstrike_formatter.rb +0 -71
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'rdoc/markup/inline'
|
2
|
-
|
3
1
|
##
|
4
2
|
# Manages changes of attributes in a block of text
|
5
3
|
|
@@ -10,38 +8,69 @@ class RDoc::Markup::AttributeManager
|
|
10
8
|
|
11
9
|
NULL = "\000".freeze
|
12
10
|
|
13
|
-
|
11
|
+
#--
|
14
12
|
# We work by substituting non-printing characters in to the text. For now
|
15
13
|
# I'm assuming that I can substitute a character in the range 0..8 for a 7
|
16
14
|
# bit character without damaging the encoded string, but this might be
|
17
15
|
# optimistic
|
16
|
+
#++
|
18
17
|
|
19
|
-
A_PROTECT = 004
|
20
|
-
|
18
|
+
A_PROTECT = 004 # :nodoc:
|
19
|
+
|
20
|
+
PROTECT_ATTR = A_PROTECT.chr # :nodoc:
|
21
21
|
|
22
22
|
##
|
23
23
|
# This maps delimiters that occur around words (such as *bold* or +tt+)
|
24
24
|
# where the start and end delimiters and the same. This lets us optimize
|
25
25
|
# the regexp
|
26
26
|
|
27
|
-
|
27
|
+
attr_reader :matching_word_pairs
|
28
28
|
|
29
29
|
##
|
30
30
|
# And this is used when the delimiters aren't the same. In this case the
|
31
31
|
# hash maps a pattern to the attribute character
|
32
32
|
|
33
|
-
|
33
|
+
attr_reader :word_pair_map
|
34
34
|
|
35
35
|
##
|
36
36
|
# This maps HTML tags to the corresponding attribute char
|
37
37
|
|
38
|
-
|
38
|
+
attr_reader :html_tags
|
39
|
+
|
40
|
+
##
|
41
|
+
# A \ in front of a character that would normally be processed turns off
|
42
|
+
# processing. We do this by turning \< into <#{PROTECT}
|
43
|
+
|
44
|
+
attr_reader :protectable
|
39
45
|
|
40
46
|
##
|
41
47
|
# And this maps _special_ sequences to a name. A special sequence is
|
42
48
|
# something like a WikiWord
|
43
49
|
|
44
|
-
|
50
|
+
attr_reader :special
|
51
|
+
|
52
|
+
##
|
53
|
+
# Creates a new attribute manager that understands bold, emphasized and
|
54
|
+
# teletype text.
|
55
|
+
|
56
|
+
def initialize
|
57
|
+
@html_tags = {}
|
58
|
+
@matching_word_pairs = {}
|
59
|
+
@protectable = %w[<\\]
|
60
|
+
@special = {}
|
61
|
+
@word_pair_map = {}
|
62
|
+
|
63
|
+
add_word_pair "*", "*", :BOLD
|
64
|
+
add_word_pair "_", "_", :EM
|
65
|
+
add_word_pair "+", "+", :TT
|
66
|
+
|
67
|
+
add_html "em", :EM
|
68
|
+
add_html "i", :EM
|
69
|
+
add_html "b", :BOLD
|
70
|
+
add_html "tt", :TT
|
71
|
+
add_html "code", :TT
|
72
|
+
end
|
73
|
+
|
45
74
|
|
46
75
|
##
|
47
76
|
# Return an attribute object with the given turn_on and turn_off bits set
|
@@ -81,19 +110,19 @@ class RDoc::Markup::AttributeManager
|
|
81
110
|
|
82
111
|
def convert_attrs(str, attrs)
|
83
112
|
# first do matching ones
|
84
|
-
tags =
|
113
|
+
tags = @matching_word_pairs.keys.join("")
|
85
114
|
|
86
115
|
re = /(^|\W)([#{tags}])([#:\\]?[\w.\/-]+?\S?)\2(\W|$)/
|
87
116
|
|
88
117
|
1 while str.gsub!(re) do
|
89
|
-
attr =
|
118
|
+
attr = @matching_word_pairs[$2]
|
90
119
|
attrs.set_attrs($`.length + $1.length + $2.length, $3.length, attr)
|
91
120
|
$1 + NULL * $2.length + $3 + NULL * $2.length + $4
|
92
121
|
end
|
93
122
|
|
94
123
|
# then non-matching
|
95
|
-
unless
|
96
|
-
|
124
|
+
unless @word_pair_map.empty? then
|
125
|
+
@word_pair_map.each do |regexp, attr|
|
97
126
|
str.gsub!(regexp) {
|
98
127
|
attrs.set_attrs($`.length + $1.length, $2.length, attr)
|
99
128
|
NULL * $1.length + $2 + NULL * $3.length
|
@@ -106,10 +135,10 @@ class RDoc::Markup::AttributeManager
|
|
106
135
|
# Converts HTML tags to RDoc attributes
|
107
136
|
|
108
137
|
def convert_html(str, attrs)
|
109
|
-
tags =
|
138
|
+
tags = @html_tags.keys.join '|'
|
110
139
|
|
111
140
|
1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) {
|
112
|
-
attr =
|
141
|
+
attr = @html_tags[$1.downcase]
|
113
142
|
html_length = $1.length + 2
|
114
143
|
seq = NULL * html_length
|
115
144
|
attrs.set_attrs($`.length + html_length, $2.length, attr)
|
@@ -121,8 +150,8 @@ class RDoc::Markup::AttributeManager
|
|
121
150
|
# Converts special sequences to RDoc attributes
|
122
151
|
|
123
152
|
def convert_specials(str, attrs)
|
124
|
-
unless
|
125
|
-
|
153
|
+
unless @special.empty?
|
154
|
+
@special.each do |regexp, attr|
|
126
155
|
str.scan(regexp) do
|
127
156
|
attrs.set_attrs($`.length, $&.length,
|
128
157
|
attr | RDoc::Markup::Attribute::SPECIAL)
|
@@ -131,18 +160,12 @@ class RDoc::Markup::AttributeManager
|
|
131
160
|
end
|
132
161
|
end
|
133
162
|
|
134
|
-
##
|
135
|
-
# A \ in front of a character that would normally be processed turns off
|
136
|
-
# processing. We do this by turning \< into <#{PROTECT}
|
137
|
-
|
138
|
-
PROTECTABLE = %w[<\\]
|
139
|
-
|
140
163
|
##
|
141
164
|
# Escapes special sequences of text to prevent conversion to RDoc
|
142
165
|
|
143
166
|
def mask_protected_sequences
|
144
|
-
|
145
|
-
|
167
|
+
@str.gsub!(/\\([#{Regexp.escape @protectable.join('')}])/,
|
168
|
+
"\\1#{PROTECT_ATTR}")
|
146
169
|
end
|
147
170
|
|
148
171
|
##
|
@@ -152,22 +175,6 @@ class RDoc::Markup::AttributeManager
|
|
152
175
|
@str.gsub!(/(.)#{PROTECT_ATTR}/, "\\1\000")
|
153
176
|
end
|
154
177
|
|
155
|
-
##
|
156
|
-
# Creates a new attribute manager that understands bold, emphasized and
|
157
|
-
# teletype text.
|
158
|
-
|
159
|
-
def initialize
|
160
|
-
add_word_pair("*", "*", :BOLD)
|
161
|
-
add_word_pair("_", "_", :EM)
|
162
|
-
add_word_pair("+", "+", :TT)
|
163
|
-
|
164
|
-
add_html("em", :EM)
|
165
|
-
add_html("i", :EM)
|
166
|
-
add_html("b", :BOLD)
|
167
|
-
add_html("tt", :TT)
|
168
|
-
add_html("code", :TT)
|
169
|
-
end
|
170
|
-
|
171
178
|
##
|
172
179
|
# Adds a markup class with +name+ for words wrapped in the +start+ and
|
173
180
|
# +stop+ character. To make words wrapped with "*" bold:
|
@@ -181,14 +188,14 @@ class RDoc::Markup::AttributeManager
|
|
181
188
|
bitmap = RDoc::Markup::Attribute.bitmap_for name
|
182
189
|
|
183
190
|
if start == stop then
|
184
|
-
|
191
|
+
@matching_word_pairs[start] = bitmap
|
185
192
|
else
|
186
193
|
pattern = /(#{Regexp.escape start})(\S+)(#{Regexp.escape stop})/
|
187
|
-
|
194
|
+
@word_pair_map[pattern] = bitmap
|
188
195
|
end
|
189
196
|
|
190
|
-
|
191
|
-
|
197
|
+
@protectable << start[0,1]
|
198
|
+
@protectable.uniq!
|
192
199
|
end
|
193
200
|
|
194
201
|
##
|
@@ -198,7 +205,7 @@ class RDoc::Markup::AttributeManager
|
|
198
205
|
# am.add_html 'em', :EM
|
199
206
|
|
200
207
|
def add_html(tag, name)
|
201
|
-
|
208
|
+
@html_tags[tag.downcase] = RDoc::Markup::Attribute.bitmap_for name
|
202
209
|
end
|
203
210
|
|
204
211
|
##
|
@@ -208,7 +215,7 @@ class RDoc::Markup::AttributeManager
|
|
208
215
|
# @am.add_special(/((https?:)\S+\w)/, :HYPERLINK)
|
209
216
|
|
210
217
|
def add_special(pattern, name)
|
211
|
-
|
218
|
+
@special[pattern] = RDoc::Markup::Attribute.bitmap_for name
|
212
219
|
end
|
213
220
|
|
214
221
|
##
|
@@ -221,9 +228,9 @@ class RDoc::Markup::AttributeManager
|
|
221
228
|
|
222
229
|
@attrs = RDoc::Markup::AttrSpan.new @str.length
|
223
230
|
|
224
|
-
convert_attrs
|
225
|
-
convert_html
|
226
|
-
convert_specials
|
231
|
+
convert_attrs @str, @attrs
|
232
|
+
convert_html @str, @attrs
|
233
|
+
convert_specials @str, @attrs
|
227
234
|
|
228
235
|
unmask_protected_sequences
|
229
236
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
##
|
2
|
+
# An empty line
|
3
|
+
|
4
|
+
class RDoc::Markup::BlankLine
|
5
|
+
|
6
|
+
def == other # :nodoc:
|
7
|
+
self.class == other.class
|
8
|
+
end
|
9
|
+
|
10
|
+
def accept visitor
|
11
|
+
visitor.accept_blank_line self
|
12
|
+
end
|
13
|
+
|
14
|
+
def pretty_print q # :nodoc:
|
15
|
+
q.text 'blankline'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
##
|
2
|
+
# A Document containing lists, headings, paragraphs, etc.
|
3
|
+
|
4
|
+
class RDoc::Markup::Document
|
5
|
+
|
6
|
+
##
|
7
|
+
# The parts of the Document
|
8
|
+
|
9
|
+
attr_reader :parts
|
10
|
+
|
11
|
+
##
|
12
|
+
# Creates a new Document with +parts+
|
13
|
+
|
14
|
+
def initialize *parts
|
15
|
+
@parts = []
|
16
|
+
@parts.push(*parts)
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Appends +part+ to the document
|
21
|
+
|
22
|
+
def << part
|
23
|
+
case part
|
24
|
+
when RDoc::Markup::Document then
|
25
|
+
unless part.empty? then
|
26
|
+
parts.push(*part.parts)
|
27
|
+
parts << RDoc::Markup::BlankLine.new
|
28
|
+
end
|
29
|
+
when String then
|
30
|
+
raise ArgumentError,
|
31
|
+
"expected RDoc::Markup::Document and friends, got String" unless
|
32
|
+
part.empty?
|
33
|
+
else
|
34
|
+
parts << part
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def == other # :nodoc:
|
39
|
+
self.class == other.class and @parts == other.parts
|
40
|
+
end
|
41
|
+
|
42
|
+
def accept visitor
|
43
|
+
visitor.start_accepting
|
44
|
+
|
45
|
+
@parts.each do |item|
|
46
|
+
item.accept visitor
|
47
|
+
end
|
48
|
+
|
49
|
+
visitor.end_accepting
|
50
|
+
end
|
51
|
+
|
52
|
+
def empty?
|
53
|
+
@parts.empty?
|
54
|
+
end
|
55
|
+
|
56
|
+
def pretty_print q # :nodoc:
|
57
|
+
q.group 2, '[doc: ', ']' do
|
58
|
+
q.seplist @parts do |part|
|
59
|
+
q.pp part
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Appends +parts+ to the document
|
66
|
+
|
67
|
+
def push *parts
|
68
|
+
self.parts.push(*parts)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
@@ -7,11 +7,34 @@ require 'rdoc/markup'
|
|
7
7
|
|
8
8
|
class RDoc::Markup::Formatter
|
9
9
|
|
10
|
+
InlineTag = Struct.new(:bit, :on, :off)
|
11
|
+
|
10
12
|
##
|
11
13
|
# Creates a new Formatter
|
12
14
|
|
13
15
|
def initialize
|
14
16
|
@markup = RDoc::Markup.new
|
17
|
+
@am = @markup.attribute_manager
|
18
|
+
@attr_tags = []
|
19
|
+
|
20
|
+
@in_tt = 0
|
21
|
+
@tt_bit = RDoc::Markup::Attribute.bitmap_for :TT
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Add a new set of tags for an attribute. We allow separate start and end
|
26
|
+
# tags for flexibility
|
27
|
+
|
28
|
+
def add_tag(name, start, stop)
|
29
|
+
attr = RDoc::Markup::Attribute.bitmap_for name
|
30
|
+
@attr_tags << InlineTag.new(attr, start, stop)
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Allows +tag+ to be decorated with additional information.
|
35
|
+
|
36
|
+
def annotate(tag)
|
37
|
+
tag
|
15
38
|
end
|
16
39
|
|
17
40
|
##
|
@@ -21,5 +44,100 @@ class RDoc::Markup::Formatter
|
|
21
44
|
@markup.convert content, self
|
22
45
|
end
|
23
46
|
|
47
|
+
##
|
48
|
+
# Converts flow items +flow+
|
49
|
+
|
50
|
+
def convert_flow(flow)
|
51
|
+
res = []
|
52
|
+
|
53
|
+
flow.each do |item|
|
54
|
+
case item
|
55
|
+
when String then
|
56
|
+
res << convert_string(item)
|
57
|
+
when RDoc::Markup::AttrChanger then
|
58
|
+
off_tags res, item
|
59
|
+
on_tags res, item
|
60
|
+
when RDoc::Markup::Special then
|
61
|
+
res << convert_special(item)
|
62
|
+
else
|
63
|
+
raise "Unknown flow element: #{item.inspect}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
res.join
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Converts added specials. See RDoc::Markup#add_special
|
72
|
+
|
73
|
+
def convert_special(special)
|
74
|
+
handled = false
|
75
|
+
|
76
|
+
RDoc::Markup::Attribute.each_name_of special.type do |name|
|
77
|
+
method_name = "handle_special_#{name}"
|
78
|
+
|
79
|
+
if respond_to? method_name then
|
80
|
+
special.text = send method_name, special
|
81
|
+
handled = true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
raise "Unhandled special: #{special}" unless handled
|
86
|
+
|
87
|
+
special.text
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Converts a string to be fancier if desired
|
92
|
+
|
93
|
+
def convert_string string
|
94
|
+
string
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Are we currently inside tt tags?
|
99
|
+
|
100
|
+
def in_tt?
|
101
|
+
@in_tt > 0
|
102
|
+
end
|
103
|
+
|
104
|
+
def on_tags res, item
|
105
|
+
attr_mask = item.turn_on
|
106
|
+
return if attr_mask.zero?
|
107
|
+
|
108
|
+
@attr_tags.each do |tag|
|
109
|
+
if attr_mask & tag.bit != 0 then
|
110
|
+
res << annotate(tag.on)
|
111
|
+
@in_tt += 1 if tt? tag
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def off_tags res, item
|
117
|
+
attr_mask = item.turn_off
|
118
|
+
return if attr_mask.zero?
|
119
|
+
|
120
|
+
@attr_tags.reverse_each do |tag|
|
121
|
+
if attr_mask & tag.bit != 0 then
|
122
|
+
@in_tt -= 1 if tt? tag
|
123
|
+
res << annotate(tag.off)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
##
|
129
|
+
# Is +tag+ a tt tag?
|
130
|
+
|
131
|
+
def tt? tag
|
132
|
+
tag.bit == @tt_bit
|
133
|
+
end
|
134
|
+
|
24
135
|
end
|
25
136
|
|
137
|
+
class RDoc::Markup
|
138
|
+
autoload :ToAnsi, 'rdoc/markup/to_ansi'
|
139
|
+
autoload :ToBs, 'rdoc/markup/to_bs'
|
140
|
+
autoload :ToHtml, 'rdoc/markup/to_html'
|
141
|
+
autoload :ToHtmlCrossref, 'rdoc/markup/to_html_crossref'
|
142
|
+
autoload :ToRdoc, 'rdoc/markup/to_rdoc'
|
143
|
+
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
require 'rdoc/markup/formatter'
|
3
|
+
|
4
|
+
##
|
5
|
+
# Test case for creating new RDoc::Markup formatters. See
|
6
|
+
# test/test_rdoc_markup_to_*.rb for examples.
|
7
|
+
|
8
|
+
class RDoc::Markup::FormatterTestCase < MiniTest::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
|
13
|
+
@m = RDoc::Markup.new
|
14
|
+
@am = RDoc::Markup::AttributeManager.new
|
15
|
+
@RM = RDoc::Markup
|
16
|
+
|
17
|
+
@bullet_list = @RM::List.new(:BULLET,
|
18
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
|
19
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
|
20
|
+
|
21
|
+
@label_list = @RM::List.new(:LABEL,
|
22
|
+
@RM::ListItem.new('cat', @RM::Paragraph.new('cats are cool')),
|
23
|
+
@RM::ListItem.new('dog', @RM::Paragraph.new('dogs are cool too')))
|
24
|
+
|
25
|
+
@lalpha_list = @RM::List.new(:LALPHA,
|
26
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
|
27
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
|
28
|
+
|
29
|
+
@note_list = @RM::List.new(:NOTE,
|
30
|
+
@RM::ListItem.new('cat', @RM::Paragraph.new('cats are cool')),
|
31
|
+
@RM::ListItem.new('dog', @RM::Paragraph.new('dogs are cool too')))
|
32
|
+
|
33
|
+
@number_list = @RM::List.new(:NUMBER,
|
34
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
|
35
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
|
36
|
+
|
37
|
+
@ualpha_list = @RM::List.new(:UALPHA,
|
38
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
|
39
|
+
@RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.add_visitor_tests
|
43
|
+
self.class_eval do
|
44
|
+
def test_start_accepting
|
45
|
+
@to.start_accepting
|
46
|
+
|
47
|
+
start_accepting
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_end_accepting
|
51
|
+
@to.start_accepting
|
52
|
+
@to.res << 'hi'
|
53
|
+
|
54
|
+
end_accepting
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_accept_blank_line
|
58
|
+
@to.start_accepting
|
59
|
+
|
60
|
+
@to.accept_blank_line @RM::BlankLine.new
|
61
|
+
|
62
|
+
accept_blank_line
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_accept_heading
|
66
|
+
@to.start_accepting
|
67
|
+
|
68
|
+
@to.accept_heading @RM::Heading.new(5, 'Hello')
|
69
|
+
|
70
|
+
accept_heading
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_accept_paragraph
|
74
|
+
@to.start_accepting
|
75
|
+
|
76
|
+
@to.accept_paragraph @RM::Paragraph.new('hi')
|
77
|
+
|
78
|
+
accept_paragraph
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_accept_verbatim
|
82
|
+
@to.start_accepting
|
83
|
+
|
84
|
+
@to.accept_verbatim @RM::Verbatim.new(' ', 'hi', "\n",
|
85
|
+
' ', 'world', "\n")
|
86
|
+
|
87
|
+
accept_verbatim
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_accept_rule
|
91
|
+
@to.start_accepting
|
92
|
+
|
93
|
+
@to.accept_rule @RM::Rule.new(4)
|
94
|
+
|
95
|
+
accept_rule
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_accept_list_item_start_bullet
|
99
|
+
@to.start_accepting
|
100
|
+
|
101
|
+
@to.accept_list_start @bullet_list
|
102
|
+
|
103
|
+
@to.accept_list_item_start @bullet_list.items.first
|
104
|
+
|
105
|
+
accept_list_item_start_bullet
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_accept_list_item_start_label
|
109
|
+
@to.start_accepting
|
110
|
+
|
111
|
+
@to.accept_list_start @label_list
|
112
|
+
|
113
|
+
@to.accept_list_item_start @label_list.items.first
|
114
|
+
|
115
|
+
accept_list_item_start_label
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_accept_list_item_start_lalpha
|
119
|
+
@to.start_accepting
|
120
|
+
|
121
|
+
@to.accept_list_start @lalpha_list
|
122
|
+
|
123
|
+
@to.accept_list_item_start @lalpha_list.items.first
|
124
|
+
|
125
|
+
accept_list_item_start_lalpha
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_accept_list_item_start_note
|
129
|
+
@to.start_accepting
|
130
|
+
|
131
|
+
@to.accept_list_start @note_list
|
132
|
+
|
133
|
+
@to.accept_list_item_start @note_list.items.first
|
134
|
+
|
135
|
+
accept_list_item_start_note
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_accept_list_item_start_number
|
139
|
+
@to.start_accepting
|
140
|
+
|
141
|
+
@to.accept_list_start @number_list
|
142
|
+
|
143
|
+
@to.accept_list_item_start @number_list.items.first
|
144
|
+
|
145
|
+
accept_list_item_start_number
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_accept_list_item_start_ualpha
|
149
|
+
@to.start_accepting
|
150
|
+
|
151
|
+
@to.accept_list_start @ualpha_list
|
152
|
+
|
153
|
+
@to.accept_list_item_start @ualpha_list.items.first
|
154
|
+
|
155
|
+
accept_list_item_start_ualpha
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_accept_list_item_end_bullet
|
159
|
+
@to.start_accepting
|
160
|
+
|
161
|
+
@to.accept_list_start @bullet_list
|
162
|
+
|
163
|
+
@to.accept_list_item_start @bullet_list.items.first
|
164
|
+
|
165
|
+
@to.accept_list_item_end @bullet_list.items.first
|
166
|
+
|
167
|
+
accept_list_item_end_bullet
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_accept_list_item_end_label
|
171
|
+
@to.start_accepting
|
172
|
+
|
173
|
+
@to.accept_list_start @label_list
|
174
|
+
|
175
|
+
@to.accept_list_item_start @label_list.items.first
|
176
|
+
|
177
|
+
@to.accept_list_item_end @label_list.items.first
|
178
|
+
|
179
|
+
accept_list_item_end_label
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_accept_list_item_end_lalpha
|
183
|
+
@to.start_accepting
|
184
|
+
|
185
|
+
@to.accept_list_start @lalpha_list
|
186
|
+
|
187
|
+
@to.accept_list_item_start @lalpha_list.items.first
|
188
|
+
|
189
|
+
@to.accept_list_item_end @lalpha_list.items.first
|
190
|
+
|
191
|
+
accept_list_item_end_lalpha
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_accept_list_item_end_note
|
195
|
+
@to.start_accepting
|
196
|
+
|
197
|
+
@to.accept_list_start @note_list
|
198
|
+
|
199
|
+
@to.accept_list_item_start @note_list.items.first
|
200
|
+
|
201
|
+
@to.accept_list_item_end @note_list.items.first
|
202
|
+
|
203
|
+
accept_list_item_end_note
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_accept_list_item_end_number
|
207
|
+
@to.start_accepting
|
208
|
+
|
209
|
+
@to.accept_list_start @number_list
|
210
|
+
|
211
|
+
@to.accept_list_item_start @number_list.items.first
|
212
|
+
|
213
|
+
@to.accept_list_item_end @number_list.items.first
|
214
|
+
|
215
|
+
accept_list_item_end_number
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_accept_list_item_end_ualpha
|
219
|
+
@to.start_accepting
|
220
|
+
|
221
|
+
@to.accept_list_start @ualpha_list
|
222
|
+
|
223
|
+
@to.accept_list_item_start @ualpha_list.items.first
|
224
|
+
|
225
|
+
@to.accept_list_item_end @ualpha_list.items.first
|
226
|
+
|
227
|
+
accept_list_item_end_ualpha
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_accept_list_start_bullet
|
231
|
+
@to.start_accepting
|
232
|
+
|
233
|
+
@to.accept_list_start @bullet_list
|
234
|
+
|
235
|
+
accept_list_start_bullet
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_accept_list_start_label
|
239
|
+
@to.start_accepting
|
240
|
+
|
241
|
+
@to.accept_list_start @label_list
|
242
|
+
|
243
|
+
accept_list_start_label
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_accept_list_start_lalpha
|
247
|
+
@to.start_accepting
|
248
|
+
|
249
|
+
@to.accept_list_start @lalpha_list
|
250
|
+
|
251
|
+
accept_list_start_lalpha
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_accept_list_start_note
|
255
|
+
@to.start_accepting
|
256
|
+
|
257
|
+
@to.accept_list_start @note_list
|
258
|
+
|
259
|
+
accept_list_start_note
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_accept_list_start_number
|
263
|
+
@to.start_accepting
|
264
|
+
|
265
|
+
@to.accept_list_start @number_list
|
266
|
+
|
267
|
+
accept_list_start_number
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_accept_list_start_ualpha
|
271
|
+
@to.start_accepting
|
272
|
+
|
273
|
+
@to.accept_list_start @ualpha_list
|
274
|
+
|
275
|
+
accept_list_start_ualpha
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_accept_list_end_bullet
|
279
|
+
@to.start_accepting
|
280
|
+
|
281
|
+
@to.accept_list_start @bullet_list
|
282
|
+
|
283
|
+
@to.accept_list_end @bullet_list
|
284
|
+
|
285
|
+
accept_list_end_bullet
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_accept_list_end_label
|
289
|
+
@to.start_accepting
|
290
|
+
|
291
|
+
@to.accept_list_start @label_list
|
292
|
+
|
293
|
+
@to.accept_list_end @label_list
|
294
|
+
|
295
|
+
accept_list_end_label
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_accept_list_end_lalpha
|
299
|
+
@to.start_accepting
|
300
|
+
|
301
|
+
@to.accept_list_start @lalpha_list
|
302
|
+
|
303
|
+
@to.accept_list_end @lalpha_list
|
304
|
+
|
305
|
+
accept_list_end_lalpha
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_accept_list_end_number
|
309
|
+
@to.start_accepting
|
310
|
+
|
311
|
+
@to.accept_list_start @number_list
|
312
|
+
|
313
|
+
@to.accept_list_end @number_list
|
314
|
+
|
315
|
+
accept_list_end_number
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_accept_list_end_note
|
319
|
+
@to.start_accepting
|
320
|
+
|
321
|
+
@to.accept_list_start @note_list
|
322
|
+
|
323
|
+
@to.accept_list_end @note_list
|
324
|
+
|
325
|
+
accept_list_end_note
|
326
|
+
end
|
327
|
+
|
328
|
+
def test_accept_list_end_ualpha
|
329
|
+
@to.start_accepting
|
330
|
+
|
331
|
+
@to.accept_list_start @ualpha_list
|
332
|
+
|
333
|
+
@to.accept_list_end @ualpha_list
|
334
|
+
|
335
|
+
accept_list_end_ualpha
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|
341
|
+
|