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
data/test/hidden.zip.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
PK
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'minitest/
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'rdoc'
|
4
|
+
require 'rdoc/markup'
|
3
5
|
require 'rdoc/markup/attribute_manager'
|
4
6
|
|
5
7
|
class TestAttributeManager < MiniTest::Unit::TestCase
|
@@ -9,29 +11,21 @@ class TestAttributeManager < MiniTest::Unit::TestCase
|
|
9
11
|
@klass = RDoc::Markup::AttributeManager
|
10
12
|
end
|
11
13
|
|
12
|
-
def teardown
|
13
|
-
silently do
|
14
|
-
@klass.const_set(:MATCHING_WORD_PAIRS, {})
|
15
|
-
@klass.const_set(:WORD_PAIR_MAP, {})
|
16
|
-
@klass.const_set(:HTML_TAGS, {})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
14
|
def test_initial_word_pairs
|
21
|
-
word_pairs = @
|
15
|
+
word_pairs = @am.matching_word_pairs
|
22
16
|
assert word_pairs.is_a?(Hash)
|
23
17
|
assert_equal(3, word_pairs.size)
|
24
18
|
end
|
25
19
|
|
26
20
|
def test_initial_html
|
27
|
-
html_tags = @
|
21
|
+
html_tags = @am.html_tags
|
28
22
|
assert html_tags.is_a?(Hash)
|
29
23
|
assert_equal(5, html_tags.size)
|
30
24
|
end
|
31
25
|
|
32
26
|
def test_add_matching_word_pair
|
33
27
|
@am.add_word_pair("x","x", :TEST)
|
34
|
-
word_pairs = @
|
28
|
+
word_pairs = @am.matching_word_pairs
|
35
29
|
assert_equal(4,word_pairs.size)
|
36
30
|
assert(word_pairs.has_key?("x"))
|
37
31
|
end
|
@@ -44,21 +38,21 @@ class TestAttributeManager < MiniTest::Unit::TestCase
|
|
44
38
|
|
45
39
|
def test_add_word_pair_map
|
46
40
|
@am.add_word_pair("x", "y", :TEST)
|
47
|
-
word_pair_map = @
|
41
|
+
word_pair_map = @am.word_pair_map
|
48
42
|
assert_equal(1,word_pair_map.size)
|
49
43
|
assert_equal(word_pair_map. keys.first.source, "(x)(\\S+)(y)")
|
50
44
|
end
|
51
45
|
|
52
46
|
def test_add_html_tag
|
53
47
|
@am.add_html("Test", :TEST)
|
54
|
-
tags = @
|
48
|
+
tags = @am.html_tags
|
55
49
|
assert_equal(6, tags.size)
|
56
50
|
assert(tags.has_key?("test"))
|
57
51
|
end
|
58
52
|
|
59
53
|
def test_add_special
|
60
54
|
@am.add_special("WikiWord", :WIKIWORD)
|
61
|
-
specials = @
|
55
|
+
specials = @am.special
|
62
56
|
assert_equal(1,specials.size)
|
63
57
|
assert(specials.has_key?("WikiWord"))
|
64
58
|
end
|
@@ -73,4 +67,3 @@ class TestAttributeManager < MiniTest::Unit::TestCase
|
|
73
67
|
|
74
68
|
end
|
75
69
|
|
76
|
-
MiniTest::Unit.autorun
|
@@ -6,5 +6,28 @@ class RDocAnyMethodTest < XrefTestCase
|
|
6
6
|
assert_equal 'C1::m', @c1.method_list.first.full_name
|
7
7
|
end
|
8
8
|
|
9
|
+
def test_parent_name
|
10
|
+
assert_equal 'C1', @c1.method_list.first.parent_name
|
11
|
+
assert_equal 'C1', @c1.method_list.last.parent_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_marshal_load
|
15
|
+
instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
|
16
|
+
|
17
|
+
assert_equal 'C1#m', instance_method.full_name
|
18
|
+
assert_equal 'C1', instance_method.parent_name
|
19
|
+
|
20
|
+
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
|
21
|
+
|
22
|
+
assert_equal 'C1::m', class_method.full_name
|
23
|
+
assert_equal 'C1', class_method.parent_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_name
|
27
|
+
m = RDoc::AnyMethod.new nil, nil
|
28
|
+
|
29
|
+
assert_nil m.name
|
30
|
+
end
|
31
|
+
|
9
32
|
end
|
10
33
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'rdoc/rdoc'
|
4
|
+
|
5
|
+
class TestRDocAttr < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@a = RDoc::Attr.new nil, 'attr', 'RW', ''
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_block_params
|
12
|
+
assert_nil @a.block_params
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_call_seq
|
16
|
+
assert_nil @a.call_seq
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_full_name
|
20
|
+
assert_equal '(unknown)#attr', @a.full_name
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_singleton
|
24
|
+
refute @a.singleton
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_type
|
28
|
+
assert_equal 'attr_accessor', @a.type
|
29
|
+
|
30
|
+
@a.rw = 'R'
|
31
|
+
|
32
|
+
assert_equal 'attr_reader', @a.type
|
33
|
+
|
34
|
+
@a.rw = 'W'
|
35
|
+
|
36
|
+
assert_equal 'attr_writer', @a.type
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test/xref_test_case'
|
2
|
+
|
3
|
+
class TestRDocClassModule < XrefTestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@RM = RDoc::Markup
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_comment_equals
|
12
|
+
cm = RDoc::ClassModule.new 'Klass'
|
13
|
+
cm.comment = '# comment 1'
|
14
|
+
|
15
|
+
assert_equal 'comment 1', cm.comment
|
16
|
+
|
17
|
+
cm.comment = '# comment 2'
|
18
|
+
|
19
|
+
assert_equal "comment 1\n---\ncomment 2", cm.comment
|
20
|
+
|
21
|
+
cm.comment = "# * comment 3"
|
22
|
+
|
23
|
+
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
|
24
|
+
end
|
25
|
+
|
26
|
+
# handle making a short module alias of yourself
|
27
|
+
|
28
|
+
def test_find_class_named
|
29
|
+
@c2.classes_hash['C2'] = @c2
|
30
|
+
|
31
|
+
assert_nil @c2.find_class_named('C1')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_merge
|
35
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
36
|
+
cm1.comment = 'klass 1'
|
37
|
+
cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
|
38
|
+
cm1.add_attribute RDoc::Attr.new(nil, 'a3', 'R', '')
|
39
|
+
cm1.add_constant RDoc::Constant.new('C1', nil, '')
|
40
|
+
cm1.add_include RDoc::Include.new('I1', '')
|
41
|
+
cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
|
42
|
+
|
43
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
44
|
+
cm2.instance_variable_set(:@comment,
|
45
|
+
@RM::Document.new(
|
46
|
+
@RM::Paragraph.new('klass 2')))
|
47
|
+
cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
|
48
|
+
cm2.add_attribute RDoc::Attr.new(nil, 'a3', 'W', '')
|
49
|
+
cm2.add_constant RDoc::Constant.new('C2', nil, '')
|
50
|
+
cm2.add_include RDoc::Include.new('I2', '')
|
51
|
+
cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
|
52
|
+
|
53
|
+
cm1.merge cm2
|
54
|
+
|
55
|
+
document = @RM::Document.new(
|
56
|
+
@RM::Paragraph.new('klass 2'),
|
57
|
+
@RM::Paragraph.new('klass 1'))
|
58
|
+
|
59
|
+
assert_equal document, cm1.comment
|
60
|
+
|
61
|
+
expected = [
|
62
|
+
RDoc::Attr.new(nil, 'a1', 'RW', ''),
|
63
|
+
RDoc::Attr.new(nil, 'a2', 'RW', ''),
|
64
|
+
RDoc::Attr.new(nil, 'a3', 'RW', ''),
|
65
|
+
]
|
66
|
+
|
67
|
+
expected.each do |a| a.parent = cm1 end
|
68
|
+
assert_equal expected, cm1.attributes.sort
|
69
|
+
|
70
|
+
expected = [
|
71
|
+
RDoc::Constant.new('C1', nil, ''),
|
72
|
+
RDoc::Constant.new('C2', nil, ''),
|
73
|
+
]
|
74
|
+
|
75
|
+
expected.each do |c| c.parent = cm1 end
|
76
|
+
assert_equal expected, cm1.constants.sort
|
77
|
+
|
78
|
+
expected = [
|
79
|
+
RDoc::Include.new('I1', ''),
|
80
|
+
RDoc::Include.new('I2', ''),
|
81
|
+
]
|
82
|
+
|
83
|
+
expected.each do |i| i.parent = cm1 end
|
84
|
+
assert_equal expected, cm1.includes.sort
|
85
|
+
|
86
|
+
expected = [
|
87
|
+
RDoc::AnyMethod.new(nil, 'm1'),
|
88
|
+
RDoc::AnyMethod.new(nil, 'm2'),
|
89
|
+
]
|
90
|
+
|
91
|
+
expected.each do |m| m.parent = cm1 end
|
92
|
+
assert_equal expected, cm1.method_list.sort
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_superclass
|
96
|
+
assert_equal @c3_h1, @c3_h2.superclass
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
@@ -16,13 +16,13 @@ class TestRDocCodeObject < XrefTestCase
|
|
16
16
|
assert @co.document_children, 'document_children'
|
17
17
|
refute @co.force_documentation, 'force_documentation'
|
18
18
|
refute @co.done_documenting, 'done_documenting'
|
19
|
-
assert_equal
|
19
|
+
assert_equal '', @co.comment, 'comment is empty'
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_comment_equals
|
23
23
|
@co.comment = ''
|
24
24
|
|
25
|
-
assert_equal
|
25
|
+
assert_equal '', @co.comment
|
26
26
|
|
27
27
|
@co.comment = 'I am a comment'
|
28
28
|
|
@@ -45,6 +45,22 @@ class TestRDocCodeObject < XrefTestCase
|
|
45
45
|
assert_empty @c1.method_list
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_documented_eh
|
49
|
+
refute @co.documented?
|
50
|
+
|
51
|
+
@co.comment = 'hi'
|
52
|
+
|
53
|
+
assert @co.documented?
|
54
|
+
|
55
|
+
@co.comment.replace ''
|
56
|
+
|
57
|
+
refute @co.documented?
|
58
|
+
|
59
|
+
@co.document_self = false
|
60
|
+
|
61
|
+
assert @co.documented?
|
62
|
+
end
|
63
|
+
|
48
64
|
def test_parent_file_name
|
49
65
|
assert_equal '(unknown)', @co.parent_file_name
|
50
66
|
assert_equal 'xref_data.rb', @c1.parent_file_name
|
data/test/test_rdoc_context.rb
CHANGED
@@ -51,6 +51,28 @@ class TestRDocContext < XrefTestCase
|
|
51
51
|
assert_equal %w[old_name new_name], @context.method_list.map { |m| m.name }
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_add_alias_impl
|
55
|
+
meth = RDoc::AnyMethod.new nil, 'old_name'
|
56
|
+
meth.comment = 'old comment'
|
57
|
+
meth.singleton = false
|
58
|
+
meth.visibility = :private
|
59
|
+
|
60
|
+
alas = RDoc::Alias.new nil, 'old_name', 'new_name', 'new comment'
|
61
|
+
|
62
|
+
@context.add_alias_impl alas, meth
|
63
|
+
|
64
|
+
assert_equal 1, @context.method_list.length
|
65
|
+
|
66
|
+
alas_meth = @context.method_list.first
|
67
|
+
assert_equal 'new_name', alas_meth.name
|
68
|
+
assert_equal 'new comment', alas_meth.comment
|
69
|
+
assert_equal false, alas_meth.singleton
|
70
|
+
assert_equal meth, alas_meth.is_alias_for
|
71
|
+
assert_equal :private, alas_meth.visibility
|
72
|
+
|
73
|
+
assert_equal [alas_meth], meth.aliases
|
74
|
+
end
|
75
|
+
|
54
76
|
def test_add_class
|
55
77
|
@c1.add_class RDoc::NormalClass, 'Klass', 'Object'
|
56
78
|
|
@@ -58,6 +80,15 @@ class TestRDocContext < XrefTestCase
|
|
58
80
|
assert_includes RDoc::TopLevel.classes.map { |k| k.full_name }, 'C1::Klass'
|
59
81
|
end
|
60
82
|
|
83
|
+
def test_add_class_superclass
|
84
|
+
@c1.add_class RDoc::NormalClass, 'Klass', 'Object'
|
85
|
+
@c1.add_class RDoc::NormalClass, 'Klass', 'Other'
|
86
|
+
@c1.add_class RDoc::NormalClass, 'Klass', 'Object'
|
87
|
+
|
88
|
+
klass = @c1.find_module_named 'Klass'
|
89
|
+
assert_equal 'Other', klass.superclass
|
90
|
+
end
|
91
|
+
|
61
92
|
def test_add_class_upgrade
|
62
93
|
@c1.add_module RDoc::NormalModule, 'Klass'
|
63
94
|
@c1.add_class RDoc::NormalClass, 'Klass', nil
|
@@ -117,6 +148,12 @@ class TestRDocContext < XrefTestCase
|
|
117
148
|
assert_includes @c1.modules.map { |m| m.full_name }, 'C1::Mod'
|
118
149
|
end
|
119
150
|
|
151
|
+
def test_add_module_alias
|
152
|
+
c3_c4 = @c2.add_module_alias @c2_c3, 'C4'
|
153
|
+
|
154
|
+
assert_equal @c2.find_module_named('C4'), c3_c4
|
155
|
+
end
|
156
|
+
|
120
157
|
def test_add_module_class
|
121
158
|
k = @c1.add_class RDoc::NormalClass, 'Klass', nil
|
122
159
|
m = @c1.add_module RDoc::NormalModule, 'Klass'
|
@@ -161,6 +198,10 @@ class TestRDocContext < XrefTestCase
|
|
161
198
|
refute_includes arr, incl
|
162
199
|
end
|
163
200
|
|
201
|
+
def test_child_name
|
202
|
+
assert_equal 'C1::C1', @c1.child_name('C1')
|
203
|
+
end
|
204
|
+
|
164
205
|
def test_classes
|
165
206
|
assert_equal %w[C2::C3], @c2.classes.map { |k| k.full_name }
|
166
207
|
assert_equal %w[C3::H1 C3::H2], @c3.classes.map { |k| k.full_name }
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'rdoc/rdoc'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
class TestRDocGeneratorRI < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@pwd = Dir.pwd
|
11
|
+
RDoc::TopLevel.reset
|
12
|
+
|
13
|
+
@tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
|
14
|
+
FileUtils.mkdir_p @tmpdir
|
15
|
+
Dir.chdir @tmpdir
|
16
|
+
options = RDoc::Options.new
|
17
|
+
|
18
|
+
@g = RDoc::Generator::RI.new options
|
19
|
+
|
20
|
+
@top_level = RDoc::TopLevel.new 'file.rb'
|
21
|
+
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
|
22
|
+
@meth = RDoc::AnyMethod.new nil, 'method'
|
23
|
+
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
|
24
|
+
@attr = RDoc::Attr.new nil, 'attr', 'RW', ''
|
25
|
+
|
26
|
+
@klass.add_method @meth
|
27
|
+
@klass.add_method @meth_bang
|
28
|
+
@klass.add_attribute @attr
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
Dir.chdir @pwd
|
33
|
+
FileUtils.rm_rf @tmpdir
|
34
|
+
end
|
35
|
+
|
36
|
+
def assert_file path
|
37
|
+
assert File.file?(path), "#{path} is not a file"
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_generate
|
41
|
+
top_level = RDoc::TopLevel.new 'file.rb'
|
42
|
+
top_level.add_class @klass.class, @klass.name
|
43
|
+
|
44
|
+
@g.generate nil
|
45
|
+
|
46
|
+
assert_file File.join(@tmpdir, 'cache.ri')
|
47
|
+
|
48
|
+
assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
|
49
|
+
|
50
|
+
assert_file File.join(@tmpdir, 'Object', 'attr-i.ri')
|
51
|
+
assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
|
52
|
+
assert_file File.join(@tmpdir, 'Object', 'method%21-i.ri')
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
data/test/test_rdoc_markup.rb
CHANGED
@@ -1,626 +1,37 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'minitest/
|
2
|
+
require 'minitest/autorun'
|
3
3
|
require 'rdoc/markup'
|
4
4
|
require 'rdoc/markup/to_test'
|
5
5
|
|
6
6
|
class TestRDocMarkup < MiniTest::Unit::TestCase
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
sm.content
|
13
|
-
end
|
14
|
-
|
15
|
-
def line_groups(str, expected)
|
16
|
-
m = RDoc::Markup.new
|
17
|
-
mock = RDoc::Markup::ToTest.new
|
18
|
-
|
19
|
-
block = m.convert(str, mock)
|
8
|
+
def test_convert
|
9
|
+
str = <<-STR
|
10
|
+
now is
|
11
|
+
the time
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
[expected[i]||"nil", block[i]||"nil"]
|
24
|
-
}
|
25
|
-
printf "\n\n%35s %35s\n", "Expected", "Got"
|
26
|
-
rows.each { |e,g| printf "%35s %35s\n", e.dump, g.dump }
|
27
|
-
end
|
13
|
+
hello
|
14
|
+
dave
|
28
15
|
|
29
|
-
|
30
|
-
|
16
|
+
1. l1
|
17
|
+
2. l2
|
18
|
+
STR
|
31
19
|
|
32
|
-
def line_types(str, expected)
|
33
20
|
m = RDoc::Markup.new
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
line_groups(str, ["L0: Paragraph\nnow is the time for all good men"] )
|
45
|
-
|
46
|
-
str = %{\
|
47
|
-
now is the time
|
48
|
-
code _line_ here
|
49
|
-
for all good men}
|
50
|
-
|
51
|
-
line_groups(str,
|
52
|
-
[ "L0: Paragraph\nnow is the time",
|
53
|
-
"L0: Verbatim\n code _line_ here\n",
|
54
|
-
"L0: Paragraph\nfor all good men"
|
55
|
-
] )
|
56
|
-
|
57
|
-
str = "now is the time\n code\n more code\nfor all good men"
|
58
|
-
line_groups(str,
|
59
|
-
[ "L0: Paragraph\nnow is the time",
|
60
|
-
"L0: Verbatim\n code\n more code\n",
|
61
|
-
"L0: Paragraph\nfor all good men"
|
62
|
-
] )
|
63
|
-
|
64
|
-
str = %{\
|
65
|
-
now is
|
66
|
-
* l1
|
67
|
-
* l2
|
68
|
-
the time}
|
69
|
-
line_groups(str,
|
70
|
-
[ "L0: Paragraph\nnow is",
|
71
|
-
"L1: ListStart\n",
|
72
|
-
"L1: BULLET ListItem\nl1",
|
73
|
-
"L1: BULLET ListItem\nl2",
|
74
|
-
"L1: ListEnd\n",
|
75
|
-
"L0: Paragraph\nthe time"
|
76
|
-
])
|
77
|
-
|
78
|
-
str = %{\
|
79
|
-
now is
|
80
|
-
* l1
|
81
|
-
l1+
|
82
|
-
* l2
|
83
|
-
the time}
|
84
|
-
line_groups(str,
|
85
|
-
[ "L0: Paragraph\nnow is",
|
86
|
-
"L1: ListStart\n",
|
87
|
-
"L1: BULLET ListItem\nl1 l1+",
|
88
|
-
"L1: BULLET ListItem\nl2",
|
89
|
-
"L1: ListEnd\n",
|
90
|
-
"L0: Paragraph\nthe time"
|
91
|
-
])
|
92
|
-
|
93
|
-
str = %{\
|
94
|
-
now is
|
95
|
-
* l1
|
96
|
-
* l1.1
|
97
|
-
* l2
|
98
|
-
the time}
|
99
|
-
line_groups(str,
|
100
|
-
[ "L0: Paragraph\nnow is",
|
101
|
-
"L1: ListStart\n",
|
102
|
-
"L1: BULLET ListItem\nl1",
|
103
|
-
"L2: ListStart\n",
|
104
|
-
"L2: BULLET ListItem\nl1.1",
|
105
|
-
"L2: ListEnd\n",
|
106
|
-
"L1: BULLET ListItem\nl2",
|
107
|
-
"L1: ListEnd\n",
|
108
|
-
"L0: Paragraph\nthe time"
|
109
|
-
])
|
110
|
-
|
111
|
-
|
112
|
-
str = %{\
|
113
|
-
now is
|
114
|
-
* l1
|
115
|
-
* l1.1
|
116
|
-
text
|
117
|
-
code
|
118
|
-
code
|
119
|
-
|
120
|
-
text
|
121
|
-
* l2
|
122
|
-
the time}
|
123
|
-
line_groups(str,
|
124
|
-
[ "L0: Paragraph\nnow is",
|
125
|
-
"L1: ListStart\n",
|
126
|
-
"L1: BULLET ListItem\nl1",
|
127
|
-
"L2: ListStart\n",
|
128
|
-
"L2: BULLET ListItem\nl1.1 text",
|
129
|
-
"L2: Verbatim\n code\n code\n",
|
130
|
-
"L2: Paragraph\ntext",
|
131
|
-
"L2: ListEnd\n",
|
132
|
-
"L1: BULLET ListItem\nl2",
|
133
|
-
"L1: ListEnd\n",
|
134
|
-
"L0: Paragraph\nthe time"
|
135
|
-
])
|
136
|
-
|
137
|
-
|
138
|
-
str = %{\
|
139
|
-
now is
|
140
|
-
1. l1
|
141
|
-
* l1.1
|
142
|
-
2. l2
|
143
|
-
the time}
|
144
|
-
line_groups(str,
|
145
|
-
[ "L0: Paragraph\nnow is",
|
146
|
-
"L1: ListStart\n",
|
147
|
-
"L1: NUMBER ListItem\nl1",
|
148
|
-
"L2: ListStart\n",
|
149
|
-
"L2: BULLET ListItem\nl1.1",
|
150
|
-
"L2: ListEnd\n",
|
151
|
-
"L1: NUMBER ListItem\nl2",
|
152
|
-
"L1: ListEnd\n",
|
153
|
-
"L0: Paragraph\nthe time"
|
154
|
-
])
|
155
|
-
|
156
|
-
str = %{\
|
157
|
-
now is
|
158
|
-
[cat] l1
|
159
|
-
* l1.1
|
160
|
-
[dog] l2
|
161
|
-
the time}
|
162
|
-
line_groups(str,
|
163
|
-
[ "L0: Paragraph\nnow is",
|
164
|
-
"L1: ListStart\n",
|
165
|
-
"L1: LABELED ListItem\ncat: l1",
|
166
|
-
"L2: ListStart\n",
|
167
|
-
"L2: BULLET ListItem\nl1.1",
|
168
|
-
"L2: ListEnd\n",
|
169
|
-
"L1: LABELED ListItem\ndog: l2",
|
170
|
-
"L1: ListEnd\n",
|
171
|
-
"L0: Paragraph\nthe time"
|
172
|
-
])
|
173
|
-
|
174
|
-
str = %{\
|
175
|
-
now is
|
176
|
-
[cat] l1
|
177
|
-
continuation
|
178
|
-
[dog] l2
|
179
|
-
the time}
|
180
|
-
line_groups(str,
|
181
|
-
[ "L0: Paragraph\nnow is",
|
182
|
-
"L1: ListStart\n",
|
183
|
-
"L1: LABELED ListItem\ncat: l1 continuation",
|
184
|
-
"L1: LABELED ListItem\ndog: l2",
|
185
|
-
"L1: ListEnd\n",
|
186
|
-
"L0: Paragraph\nthe time"
|
187
|
-
])
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_headings
|
191
|
-
str = "= heading one"
|
192
|
-
line_groups(str,
|
193
|
-
[ "L0: Heading\nheading one"
|
194
|
-
])
|
195
|
-
|
196
|
-
str = "=== heading three"
|
197
|
-
line_groups(str,
|
198
|
-
[ "L0: Heading\nheading three"
|
199
|
-
])
|
200
|
-
|
201
|
-
str = "text\n === heading three"
|
202
|
-
line_groups(str,
|
203
|
-
[ "L0: Paragraph\ntext",
|
204
|
-
"L0: Verbatim\n === heading three\n"
|
205
|
-
])
|
206
|
-
|
207
|
-
str = "text\n code\n === heading three"
|
208
|
-
line_groups(str,
|
209
|
-
[ "L0: Paragraph\ntext",
|
210
|
-
"L0: Verbatim\n code\n === heading three\n"
|
211
|
-
])
|
212
|
-
|
213
|
-
str = "text\n code\n=== heading three"
|
214
|
-
line_groups(str,
|
215
|
-
[ "L0: Paragraph\ntext",
|
216
|
-
"L0: Verbatim\n code\n",
|
217
|
-
"L0: Heading\nheading three"
|
218
|
-
])
|
219
|
-
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_list_alpha
|
223
|
-
str = "a. alpha\nb. baker\nB. ALPHA\nA. BAKER"
|
224
|
-
|
225
|
-
line_groups(str,
|
226
|
-
[ "L1: ListStart\n",
|
227
|
-
"L1: LOWERALPHA ListItem\nalpha",
|
228
|
-
"L1: LOWERALPHA ListItem\nbaker",
|
229
|
-
"L1: ListEnd\n",
|
230
|
-
"L1: ListStart\n",
|
231
|
-
"L1: UPPERALPHA ListItem\nALPHA",
|
232
|
-
"L1: UPPERALPHA ListItem\nBAKER",
|
233
|
-
"L1: ListEnd\n" ])
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_list_bullet_dash
|
237
|
-
str = "- one\n- two\n"
|
238
|
-
|
239
|
-
line_groups(str,
|
240
|
-
[ "L1: ListStart\n",
|
241
|
-
"L1: BULLET ListItem\none",
|
242
|
-
"L1: BULLET ListItem\ntwo",
|
243
|
-
"L1: ListEnd\n" ])
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_list_bullet_star
|
247
|
-
str = "* one\n* two\n"
|
248
|
-
|
249
|
-
line_groups(str,
|
250
|
-
[ "L1: ListStart\n",
|
251
|
-
"L1: BULLET ListItem\none",
|
252
|
-
"L1: BULLET ListItem\ntwo",
|
253
|
-
"L1: ListEnd\n" ])
|
254
|
-
end
|
255
|
-
|
256
|
-
def test_list_labeled_bracket
|
257
|
-
str = "[one] item one\n[two] item two"
|
258
|
-
|
259
|
-
line_groups(str,
|
260
|
-
[ "L1: ListStart\n",
|
261
|
-
"L1: LABELED ListItem\none: item one",
|
262
|
-
"L1: LABELED ListItem\ntwo: item two",
|
263
|
-
"L1: ListEnd\n" ])
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_list_labeled_bracket_continued
|
267
|
-
str = "[one]\n item one\n[two]\n item two"
|
268
|
-
|
269
|
-
line_groups(str,
|
270
|
-
[ "L1: ListStart\n",
|
271
|
-
"L1: LABELED ListItem\none: item one",
|
272
|
-
"L1: LABELED ListItem\ntwo: item two",
|
273
|
-
"L1: ListEnd\n" ])
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_list_labeled_colon
|
277
|
-
str = "one:: item one\ntwo:: item two"
|
278
|
-
|
279
|
-
line_groups(str,
|
280
|
-
[ "L1: ListStart\n",
|
281
|
-
"L1: NOTE ListItem\none:: item one",
|
282
|
-
"L1: NOTE ListItem\ntwo:: item two",
|
283
|
-
"L1: ListEnd\n" ])
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_list_labeled_colon_continued
|
287
|
-
str = "one::\n item one\ntwo::\n item two"
|
288
|
-
|
289
|
-
line_groups(str,
|
290
|
-
[ "L1: ListStart\n",
|
291
|
-
"L1: NOTE ListItem\none:: item one",
|
292
|
-
"L1: NOTE ListItem\ntwo:: item two",
|
293
|
-
"L1: ListEnd\n" ])
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_list_nested_bullet_bullet
|
297
|
-
str = "* one\n* two\n * cat\n * dog"
|
298
|
-
|
299
|
-
line_groups(str,
|
300
|
-
[ "L1: ListStart\n",
|
301
|
-
"L1: BULLET ListItem\none",
|
302
|
-
"L1: BULLET ListItem\ntwo",
|
303
|
-
"L2: ListStart\n",
|
304
|
-
"L2: BULLET ListItem\ncat",
|
305
|
-
"L2: BULLET ListItem\ndog",
|
306
|
-
"L2: ListEnd\n",
|
307
|
-
"L1: ListEnd\n" ])
|
308
|
-
end
|
309
|
-
|
310
|
-
def test_list_nested_labeled_bullet
|
311
|
-
str = "[one]\n * cat\n * dog"
|
312
|
-
|
313
|
-
line_groups(str,
|
314
|
-
[ "L1: ListStart\n",
|
315
|
-
"L1: LABELED ListItem\none: ",
|
316
|
-
"L2: ListStart\n",
|
317
|
-
"L2: BULLET ListItem\ncat",
|
318
|
-
"L2: BULLET ListItem\ndog",
|
319
|
-
"L2: ListEnd\n",
|
320
|
-
"L1: ListEnd\n" ])
|
321
|
-
end
|
322
|
-
|
323
|
-
def test_list_nested_labeled_bullet_bullet
|
324
|
-
str = "[one]\n * cat\n * dog"
|
325
|
-
|
326
|
-
line_groups(str,
|
327
|
-
[ "L1: ListStart\n",
|
328
|
-
"L1: LABELED ListItem\none: ",
|
329
|
-
"L2: ListStart\n",
|
330
|
-
"L2: BULLET ListItem\ncat",
|
331
|
-
"L3: ListStart\n",
|
332
|
-
"L3: BULLET ListItem\ndog",
|
333
|
-
"L3: ListEnd\n",
|
334
|
-
"L2: ListEnd\n",
|
335
|
-
"L1: ListEnd\n" ])
|
336
|
-
end
|
337
|
-
|
338
|
-
def test_list_nested_number_number
|
339
|
-
str = "1. one\n1. two\n 1. cat\n 1. dog"
|
340
|
-
|
341
|
-
line_groups(str,
|
342
|
-
[ "L1: ListStart\n",
|
343
|
-
"L1: NUMBER ListItem\none",
|
344
|
-
"L1: NUMBER ListItem\ntwo",
|
345
|
-
"L2: ListStart\n",
|
346
|
-
"L2: NUMBER ListItem\ncat",
|
347
|
-
"L2: NUMBER ListItem\ndog",
|
348
|
-
"L2: ListEnd\n",
|
349
|
-
"L1: ListEnd\n" ])
|
350
|
-
end
|
351
|
-
|
352
|
-
def test_list_number
|
353
|
-
str = "1. one\n2. two\n1. three"
|
354
|
-
|
355
|
-
line_groups(str,
|
356
|
-
[ "L1: ListStart\n",
|
357
|
-
"L1: NUMBER ListItem\none",
|
358
|
-
"L1: NUMBER ListItem\ntwo",
|
359
|
-
"L1: NUMBER ListItem\nthree",
|
360
|
-
"L1: ListEnd\n" ])
|
361
|
-
end
|
362
|
-
|
363
|
-
def test_list_split
|
364
|
-
str = %{\
|
365
|
-
now is
|
366
|
-
* l1
|
367
|
-
1. n1
|
368
|
-
2. n2
|
369
|
-
* l2
|
370
|
-
the time}
|
371
|
-
line_groups(str,
|
372
|
-
[ "L0: Paragraph\nnow is",
|
373
|
-
"L1: ListStart\n",
|
374
|
-
"L1: BULLET ListItem\nl1",
|
375
|
-
"L1: ListEnd\n",
|
376
|
-
"L1: ListStart\n",
|
377
|
-
"L1: NUMBER ListItem\nn1",
|
378
|
-
"L1: NUMBER ListItem\nn2",
|
379
|
-
"L1: ListEnd\n",
|
380
|
-
"L1: ListStart\n",
|
381
|
-
"L1: BULLET ListItem\nl2",
|
382
|
-
"L1: ListEnd\n",
|
383
|
-
"L0: Paragraph\nthe time"
|
384
|
-
])
|
385
|
-
|
386
|
-
end
|
387
|
-
|
388
|
-
def test_list_verbatim
|
389
|
-
str = "* one\n verb1\n verb2\n* two\n"
|
390
|
-
|
391
|
-
line_groups(str,
|
392
|
-
[ "L1: ListStart\n",
|
393
|
-
"L1: BULLET ListItem\none",
|
394
|
-
"L1: Verbatim\n verb1\n verb2\n",
|
395
|
-
"L1: BULLET ListItem\ntwo",
|
396
|
-
"L1: ListEnd\n" ])
|
397
|
-
end
|
398
|
-
|
399
|
-
def test_paragraph
|
400
|
-
str = "paragraph\n\n*bold* paragraph\n"
|
401
|
-
|
402
|
-
line_groups str, [
|
403
|
-
"L0: Paragraph\nparagraph",
|
404
|
-
"L0: BlankLine\n",
|
405
|
-
"L0: Paragraph\n*bold* paragraph"
|
21
|
+
out = m.convert str, RDoc::Markup::ToTest.new
|
22
|
+
|
23
|
+
expected = [
|
24
|
+
"now is the time",
|
25
|
+
"\n",
|
26
|
+
" hello\n dave\n",
|
27
|
+
"1: ",
|
28
|
+
"l1",
|
29
|
+
"1: ",
|
30
|
+
"l2",
|
406
31
|
]
|
407
|
-
end
|
408
|
-
|
409
|
-
def test_tabs
|
410
|
-
str = "hello\n dave"
|
411
|
-
assert_equal(str, basic_conv(str))
|
412
|
-
str = "hello\n\tdave"
|
413
|
-
assert_equal("hello\n dave", basic_conv(str))
|
414
|
-
str = "hello\n \tdave"
|
415
|
-
assert_equal("hello\n dave", basic_conv(str))
|
416
|
-
str = "hello\n \tdave"
|
417
|
-
assert_equal("hello\n dave", basic_conv(str))
|
418
|
-
str = "hello\n \tdave"
|
419
|
-
assert_equal("hello\n dave", basic_conv(str))
|
420
|
-
str = "hello\n \tdave"
|
421
|
-
assert_equal("hello\n dave", basic_conv(str))
|
422
|
-
str = "hello\n \tdave"
|
423
|
-
assert_equal("hello\n dave", basic_conv(str))
|
424
|
-
str = "hello\n \tdave"
|
425
|
-
assert_equal("hello\n dave", basic_conv(str))
|
426
|
-
str = "hello\n \tdave"
|
427
|
-
assert_equal("hello\n dave", basic_conv(str))
|
428
|
-
str = "hello\n \tdave"
|
429
|
-
assert_equal("hello\n dave", basic_conv(str))
|
430
|
-
str = ".\t\t."
|
431
|
-
assert_equal(". .", basic_conv(str))
|
432
|
-
end
|
433
|
-
|
434
|
-
def test_types
|
435
|
-
str = "now is the time"
|
436
|
-
line_types(str, 'P')
|
437
|
-
|
438
|
-
str = "now is the time\nfor all good men"
|
439
|
-
line_types(str, 'PP')
|
440
|
-
|
441
|
-
str = "now is the time\n code\nfor all good men"
|
442
|
-
line_types(str, 'PVP')
|
443
|
-
|
444
|
-
str = "now is the time\n code\n more code\nfor all good men"
|
445
|
-
line_types(str, 'PVVP')
|
446
|
-
|
447
|
-
str = "now is\n---\nthe time"
|
448
|
-
line_types(str, 'PRP')
|
449
|
-
|
450
|
-
str = %{\
|
451
|
-
now is
|
452
|
-
* l1
|
453
|
-
* l2
|
454
|
-
the time}
|
455
|
-
line_types(str, 'PLLP')
|
456
|
-
|
457
|
-
str = %{\
|
458
|
-
now is
|
459
|
-
* l1
|
460
|
-
l1+
|
461
|
-
* l2
|
462
|
-
the time}
|
463
|
-
line_types(str, 'PLPLP')
|
464
|
-
|
465
|
-
str = %{\
|
466
|
-
now is
|
467
|
-
* l1
|
468
|
-
* l1.1
|
469
|
-
* l2
|
470
|
-
the time}
|
471
|
-
line_types(str, 'PLLLP')
|
472
|
-
|
473
|
-
str = %{\
|
474
|
-
now is
|
475
|
-
* l1
|
476
|
-
* l1.1
|
477
|
-
text
|
478
|
-
code
|
479
|
-
code
|
480
|
-
|
481
|
-
text
|
482
|
-
* l2
|
483
|
-
the time}
|
484
|
-
line_types(str, 'PLLPVVBPLP')
|
485
|
-
|
486
|
-
str = %{\
|
487
|
-
now is
|
488
|
-
1. l1
|
489
|
-
* l1.1
|
490
|
-
2. l2
|
491
|
-
the time}
|
492
|
-
line_types(str, 'PLLLP')
|
493
|
-
|
494
|
-
str = %{\
|
495
|
-
now is
|
496
|
-
[cat] l1
|
497
|
-
* l1.1
|
498
|
-
[dog] l2
|
499
|
-
the time}
|
500
|
-
line_types(str, 'PLLLP')
|
501
|
-
|
502
|
-
str = %{\
|
503
|
-
now is
|
504
|
-
[cat] l1
|
505
|
-
continuation
|
506
|
-
[dog] l2
|
507
|
-
the time}
|
508
|
-
line_types(str, 'PLPLP')
|
509
|
-
end
|
510
|
-
|
511
|
-
def test_verbatim
|
512
|
-
str = "paragraph\n *bold* verbatim\n"
|
513
|
-
|
514
|
-
line_groups str, [
|
515
|
-
"L0: Paragraph\nparagraph",
|
516
|
-
"L0: Verbatim\n *bold* verbatim\n"
|
517
|
-
]
|
518
|
-
end
|
519
|
-
|
520
|
-
def test_verbatim_merge
|
521
|
-
str = %{\
|
522
|
-
now is
|
523
|
-
code
|
524
|
-
the time}
|
525
|
-
|
526
|
-
line_groups(str,
|
527
|
-
[ "L0: Paragraph\nnow is",
|
528
|
-
"L0: Verbatim\n code\n",
|
529
|
-
"L0: Paragraph\nthe time"
|
530
|
-
])
|
531
|
-
|
532
|
-
|
533
|
-
str = %{\
|
534
|
-
now is
|
535
|
-
code
|
536
|
-
code1
|
537
|
-
the time}
|
538
|
-
|
539
|
-
line_groups(str,
|
540
|
-
[ "L0: Paragraph\nnow is",
|
541
|
-
"L0: Verbatim\n code\n code1\n",
|
542
|
-
"L0: Paragraph\nthe time"
|
543
|
-
])
|
544
|
-
|
545
|
-
|
546
|
-
str = %{\
|
547
|
-
now is
|
548
|
-
code
|
549
|
-
|
550
|
-
code1
|
551
|
-
the time}
|
552
|
-
|
553
|
-
line_groups(str,
|
554
|
-
[ "L0: Paragraph\nnow is",
|
555
|
-
"L0: Verbatim\n code\n\n code1\n",
|
556
|
-
"L0: Paragraph\nthe time"
|
557
|
-
])
|
558
|
-
|
559
|
-
|
560
|
-
str = %{\
|
561
|
-
now is
|
562
|
-
code
|
563
|
-
|
564
|
-
code1
|
565
|
-
|
566
|
-
the time}
|
567
|
-
|
568
|
-
line_groups(str,
|
569
|
-
[ "L0: Paragraph\nnow is",
|
570
|
-
"L0: Verbatim\n code\n\n code1\n",
|
571
|
-
"L0: Paragraph\nthe time"
|
572
|
-
])
|
573
|
-
|
574
|
-
|
575
|
-
str = %{\
|
576
|
-
now is
|
577
|
-
code
|
578
|
-
|
579
|
-
code1
|
580
|
-
|
581
|
-
code2
|
582
|
-
the time}
|
583
|
-
|
584
|
-
line_groups(str,
|
585
|
-
[ "L0: Paragraph\nnow is",
|
586
|
-
"L0: Verbatim\n code\n\n code1\n\n code2\n",
|
587
|
-
"L0: Paragraph\nthe time"
|
588
|
-
])
|
589
|
-
|
590
|
-
|
591
|
-
# Folds multiple blank lines
|
592
|
-
str = %{\
|
593
|
-
now is
|
594
|
-
code
|
595
|
-
|
596
|
-
|
597
|
-
code1
|
598
|
-
|
599
|
-
the time}
|
600
|
-
|
601
|
-
line_groups(str,
|
602
|
-
[ "L0: Paragraph\nnow is",
|
603
|
-
"L0: Verbatim\n code\n\n code1\n",
|
604
|
-
"L0: Paragraph\nthe time"
|
605
|
-
])
|
606
|
-
|
607
|
-
|
608
|
-
end
|
609
|
-
|
610
|
-
def test_whitespace
|
611
|
-
assert_equal("hello", basic_conv("hello"))
|
612
|
-
assert_equal("hello", basic_conv(" hello "))
|
613
|
-
assert_equal("hello", basic_conv(" \t \t hello\t\t"))
|
614
|
-
|
615
|
-
assert_equal("1\n 2\n 3", basic_conv("1\n 2\n 3"))
|
616
|
-
assert_equal("1\n 2\n 3", basic_conv(" 1\n 2\n 3"))
|
617
|
-
|
618
|
-
assert_equal("1\n 2\n 3\n1\n 2", basic_conv("1\n 2\n 3\n1\n 2"))
|
619
|
-
assert_equal("1\n 2\n 3\n1\n 2", basic_conv(" 1\n 2\n 3\n 1\n 2"))
|
620
32
|
|
621
|
-
assert_equal
|
33
|
+
assert_equal expected, out
|
622
34
|
end
|
623
35
|
|
624
36
|
end
|
625
37
|
|
626
|
-
MiniTest::Unit.autorun
|