rdoc 3.9.5 → 3.10.pre.1
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 +6 -3
- data/History.txt +63 -13
- data/LICENSE.rdoc +57 -0
- data/Manifest.txt +60 -6
- data/Rakefile +24 -12
- data/TODO.rdoc +30 -0
- data/bin/rdoc +0 -2
- data/lib/rdoc.rb +55 -2
- data/lib/rdoc/alias.rb +0 -2
- data/lib/rdoc/anon_class.rb +0 -2
- data/lib/rdoc/any_method.rb +0 -3
- data/lib/rdoc/attr.rb +0 -2
- data/lib/rdoc/class_module.rb +40 -7
- data/lib/rdoc/code_object.rb +1 -3
- data/lib/rdoc/code_objects.rb +3 -21
- data/lib/rdoc/comment.rb +225 -0
- data/lib/rdoc/constant.rb +0 -2
- data/lib/rdoc/context.rb +37 -120
- data/lib/rdoc/context/section.rb +114 -0
- data/lib/rdoc/cross_reference.rb +16 -7
- data/lib/rdoc/encoding.rb +0 -2
- data/lib/rdoc/gauntlet.rb +1 -1
- data/lib/rdoc/generator.rb +7 -2
- data/lib/rdoc/generator/darkfish.rb +126 -20
- data/lib/rdoc/generator/json_index.rb +240 -0
- data/lib/rdoc/generator/markup.rb +17 -54
- data/lib/rdoc/generator/ri.rb +0 -3
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
- data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
- data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
- data/lib/rdoc/ghost_method.rb +0 -2
- data/lib/rdoc/include.rb +0 -2
- data/lib/rdoc/markup.rb +204 -43
- data/lib/rdoc/markup/attr_changer.rb +25 -0
- data/lib/rdoc/markup/attr_span.rb +29 -0
- data/lib/rdoc/markup/attribute.rb +51 -0
- data/lib/rdoc/markup/document.rb +22 -1
- data/lib/rdoc/markup/formatter.rb +4 -11
- data/lib/rdoc/markup/formatter_test_case.rb +1 -2
- data/lib/rdoc/markup/heading.rb +44 -0
- data/lib/rdoc/markup/include.rb +42 -0
- data/lib/rdoc/markup/inline.rb +1 -144
- data/lib/rdoc/markup/list.rb +2 -1
- data/lib/rdoc/markup/parser.rb +6 -16
- data/lib/rdoc/markup/pre_process.rb +64 -10
- data/lib/rdoc/markup/raw.rb +1 -1
- data/lib/rdoc/markup/special.rb +40 -0
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
- data/lib/rdoc/markup/to_ansi.rb +0 -2
- data/lib/rdoc/markup/to_bs.rb +0 -2
- data/lib/rdoc/markup/to_html.rb +102 -34
- data/lib/rdoc/markup/to_html_crossref.rb +36 -5
- data/lib/rdoc/markup/to_html_snippet.rb +270 -0
- data/lib/rdoc/markup/to_label.rb +55 -0
- data/lib/rdoc/markup/to_rdoc.rb +0 -3
- data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
- data/lib/rdoc/markup/to_test.rb +0 -3
- data/lib/rdoc/markup/to_tt_only.rb +0 -3
- data/lib/rdoc/markup/verbatim.rb +18 -0
- data/lib/rdoc/meta_method.rb +0 -2
- data/lib/rdoc/method_attr.rb +17 -1
- data/lib/rdoc/normal_class.rb +0 -2
- data/lib/rdoc/normal_module.rb +0 -2
- data/lib/rdoc/options.rb +18 -3
- data/lib/rdoc/parser.rb +74 -42
- data/lib/rdoc/parser/c.rb +79 -118
- data/lib/rdoc/parser/rd.rb +22 -0
- data/lib/rdoc/parser/ruby.rb +86 -54
- data/lib/rdoc/parser/simple.rb +21 -9
- data/lib/rdoc/parser/text.rb +11 -0
- data/lib/rdoc/rd.rb +95 -0
- data/lib/rdoc/rd/block_parser.ry +638 -0
- data/lib/rdoc/rd/inline.rb +71 -0
- data/lib/rdoc/rd/inline_parser.ry +575 -0
- data/lib/rdoc/rdoc.rb +8 -23
- data/lib/rdoc/require.rb +0 -2
- data/lib/rdoc/ri.rb +4 -2
- data/lib/rdoc/ri/driver.rb +2 -6
- data/lib/rdoc/ri/store.rb +0 -1
- data/lib/rdoc/ruby_lex.rb +43 -20
- data/lib/rdoc/ruby_token.rb +44 -2
- data/lib/rdoc/single_class.rb +0 -2
- data/lib/rdoc/stats.rb +0 -5
- data/lib/rdoc/task.rb +2 -6
- data/lib/rdoc/test_case.rb +59 -0
- data/lib/rdoc/text.rb +42 -30
- data/lib/rdoc/token_stream.rb +45 -0
- data/lib/rdoc/tom_doc.rb +232 -0
- data/lib/rdoc/top_level.rb +36 -4
- data/test/test_attribute_manager.rb +26 -29
- data/test/test_rdoc_any_method.rb +2 -26
- data/test/test_rdoc_attr.rb +4 -4
- data/test/test_rdoc_class_module.rb +95 -12
- data/test/test_rdoc_code_object.rb +10 -3
- data/test/test_rdoc_comment.rb +504 -0
- data/test/test_rdoc_context.rb +60 -11
- data/test/test_rdoc_context_section.rb +16 -17
- data/test/test_rdoc_cross_reference.rb +17 -2
- data/test/test_rdoc_encoding.rb +4 -7
- data/test/test_rdoc_generator_darkfish.rb +12 -11
- data/test/test_rdoc_generator_json_index.rb +255 -0
- data/test/test_rdoc_generator_markup.rb +56 -0
- data/test/test_rdoc_generator_ri.rb +8 -11
- data/test/test_rdoc_markup.rb +9 -5
- data/test/test_rdoc_markup_attribute_manager.rb +5 -8
- data/test/test_rdoc_markup_document.rb +34 -6
- data/test/test_rdoc_markup_formatter.rb +11 -13
- data/test/test_rdoc_markup_heading.rb +20 -0
- data/test/test_rdoc_markup_include.rb +19 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
- data/test/test_rdoc_markup_paragraph.rb +2 -5
- data/test/test_rdoc_markup_parser.rb +87 -7
- data/test/test_rdoc_markup_pre_process.rb +60 -9
- data/test/test_rdoc_markup_raw.rb +4 -6
- data/test/test_rdoc_markup_to_ansi.rb +1 -4
- data/test/test_rdoc_markup_to_bs.rb +1 -4
- data/test/test_rdoc_markup_to_html.rb +170 -31
- data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
- data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
- data/test/test_rdoc_markup_to_label.rb +50 -0
- data/test/test_rdoc_markup_to_rdoc.rb +1 -4
- data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
- data/test/test_rdoc_markup_to_tt_only.rb +1 -4
- data/test/test_rdoc_markup_verbatim.rb +16 -0
- data/test/test_rdoc_method_attr.rb +16 -1
- data/test/test_rdoc_options.rb +17 -7
- data/test/test_rdoc_parser.rb +75 -6
- data/test/test_rdoc_parser_c.rb +56 -104
- data/test/test_rdoc_parser_rd.rb +52 -0
- data/test/test_rdoc_parser_ruby.rb +264 -323
- data/test/test_rdoc_parser_simple.rb +33 -17
- data/test/test_rdoc_rd.rb +30 -0
- data/test/test_rdoc_rd_block_parser.rb +527 -0
- data/test/test_rdoc_rd_inline.rb +63 -0
- data/test/test_rdoc_rd_inline_parser.rb +173 -0
- data/test/test_rdoc_rdoc.rb +7 -9
- data/test/test_rdoc_ri_driver.rb +10 -15
- data/test/test_rdoc_ri_paths.rb +6 -6
- data/test/test_rdoc_ri_store.rb +6 -13
- data/test/test_rdoc_ruby_lex.rb +53 -5
- data/test/test_rdoc_rubygems_hook.rb +2 -1
- data/test/test_rdoc_stats.rb +83 -103
- data/test/test_rdoc_task.rb +5 -4
- data/test/test_rdoc_text.rb +156 -11
- data/test/test_rdoc_token_stream.rb +42 -0
- data/test/test_rdoc_tom_doc.rb +458 -0
- data/test/test_rdoc_top_level.rb +49 -2
- data/test/xref_test_case.rb +4 -8
- metadata +217 -111
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/LICENSE.txt +0 -57
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
@@ -1,8 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'rdoc/rdoc'
|
4
|
-
require 'rdoc/code_objects'
|
5
|
-
require 'rdoc/markup/to_html_crossref'
|
6
1
|
require File.expand_path '../xref_test_case', __FILE__
|
7
2
|
|
8
3
|
class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
@@ -16,19 +11,86 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|
16
11
|
def test_convert_CROSSREF
|
17
12
|
result = @to.convert 'C1'
|
18
13
|
|
19
|
-
assert_equal "
|
14
|
+
assert_equal para("<a href=\"C1.html\">C1</a>"), result
|
20
15
|
end
|
21
16
|
|
22
|
-
def
|
17
|
+
def test_convert_CROSSREF_label
|
18
|
+
result = @to.convert 'C1@foo'
|
19
|
+
assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>"), result
|
20
|
+
|
21
|
+
result = @to.convert 'C1#m@foo'
|
22
|
+
assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>"),
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_convert_CROSSREF_label_period
|
27
|
+
result = @to.convert 'C1@foo.'
|
28
|
+
assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>."), result
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_convert_CROSSREF_label_space
|
32
|
+
result = @to.convert 'C1@foo+bar'
|
33
|
+
assert_equal para("<a href=\"C1.html#label-foo+bar\">foo bar at C1</a>"),
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_convert_RDOCLINK_rdoc_ref
|
23
38
|
result = @to.convert 'rdoc-ref:C1'
|
24
39
|
|
25
|
-
assert_equal "
|
40
|
+
assert_equal para("<a href=\"C1.html\">C1</a>"), result
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_convert_RDOCLINK_rdoc_ref_method
|
44
|
+
result = @to.convert 'rdoc-ref:C1#m'
|
45
|
+
|
46
|
+
assert_equal para("<a href=\"C1.html#method-i-m\">C1#m</a>"), result
|
26
47
|
end
|
27
48
|
|
28
|
-
def
|
29
|
-
result = @to.convert '
|
49
|
+
def test_convert_RDOCLINK_rdoc_ref_method_label
|
50
|
+
result = @to.convert 'rdoc-ref:C1#m@foo'
|
51
|
+
|
52
|
+
assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>"),
|
53
|
+
result, 'rdoc-ref:C1#m@foo'
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_convert_RDOCLINK_rdoc_ref_method_percent
|
57
|
+
m = @c1.add_method RDoc::AnyMethod.new nil, '%'
|
58
|
+
m.singleton = false
|
59
|
+
|
60
|
+
result = @to.convert 'rdoc-ref:C1#%'
|
61
|
+
|
62
|
+
assert_equal para("<a href=\"C1.html#method-i-25\">C1#%</a>"), result
|
63
|
+
|
64
|
+
m.singleton = true
|
65
|
+
|
66
|
+
result = @to.convert 'rdoc-ref:C1::%'
|
67
|
+
|
68
|
+
assert_equal para("<a href=\"C1.html#method-c-25\">C1::%</a>"), result
|
30
69
|
|
31
|
-
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_convert_RDOCLINK_rdoc_ref_method_percent_label
|
73
|
+
m = @c1.add_method RDoc::AnyMethod.new nil, '%'
|
74
|
+
m.singleton = false
|
75
|
+
|
76
|
+
result = @to.convert 'rdoc-ref:C1#%@f'
|
77
|
+
|
78
|
+
assert_equal para("<a href=\"C1.html#method-i-25-label-f\">f at C1#%</a>"),
|
79
|
+
result
|
80
|
+
|
81
|
+
m.singleton = true
|
82
|
+
|
83
|
+
result = @to.convert 'rdoc-ref:C1::%@f'
|
84
|
+
|
85
|
+
assert_equal para("<a href=\"C1.html#method-c-25-label-f\">f at C1::%</a>"),
|
86
|
+
result
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_convert_RDOCLINK_rdoc_ref_label
|
90
|
+
result = @to.convert 'rdoc-ref:C1@foo'
|
91
|
+
|
92
|
+
assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>"), result,
|
93
|
+
'rdoc-ref:C1@foo'
|
32
94
|
end
|
33
95
|
|
34
96
|
def test_gen_url
|
@@ -43,6 +105,11 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|
43
105
|
assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", SPECIAL('C2::C3')
|
44
106
|
end
|
45
107
|
|
108
|
+
def test_handle_special_CROSSREF_label
|
109
|
+
assert_equal "<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>",
|
110
|
+
SPECIAL('C1#m@foo')
|
111
|
+
end
|
112
|
+
|
46
113
|
def test_handle_special_CROSSREF_show_hash_false
|
47
114
|
@to.show_hash = false
|
48
115
|
|
@@ -84,12 +151,23 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|
84
151
|
assert_equal '<a href="README_txt.html">tidy</a>', link
|
85
152
|
end
|
86
153
|
|
154
|
+
def test_handle_special_TIDYLINK_label
|
155
|
+
link = @to.handle_special_TIDYLINK tidy 'C1#m@foo'
|
156
|
+
|
157
|
+
assert_equal "<a href=\"C1.html#method-i-m-label-foo\">tidy</a>",
|
158
|
+
link, 'C1#m@foo'
|
159
|
+
end
|
160
|
+
|
87
161
|
def test_link
|
88
162
|
assert_equal 'n', @to.link('n', 'n')
|
89
163
|
|
90
164
|
assert_equal '<a href="C1.html#method-c-m">m</a>', @to.link('m', 'm')
|
91
165
|
end
|
92
166
|
|
167
|
+
def para text
|
168
|
+
"\n<p>#{text}</p>\n"
|
169
|
+
end
|
170
|
+
|
93
171
|
def SPECIAL text
|
94
172
|
@to.handle_special_CROSSREF special text
|
95
173
|
end
|
@@ -0,0 +1,668 @@
|
|
1
|
+
require 'rdoc/test_case'
|
2
|
+
|
3
|
+
class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase
|
4
|
+
|
5
|
+
add_visitor_tests
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@to = RDoc::Markup::ToHtmlSnippet.new 100, 100
|
11
|
+
@ellipsis = @to.to_html '...'
|
12
|
+
end
|
13
|
+
|
14
|
+
def accept_blank_line
|
15
|
+
assert_empty @to.res.join
|
16
|
+
end
|
17
|
+
|
18
|
+
def accept_document
|
19
|
+
assert_equal "<p>hello\n", @to.res.join
|
20
|
+
assert_equal 5, @to.characters
|
21
|
+
end
|
22
|
+
|
23
|
+
def accept_heading
|
24
|
+
assert_equal "<p>Hello\n", @to.res.join
|
25
|
+
assert_equal 5, @to.characters
|
26
|
+
end
|
27
|
+
|
28
|
+
def accept_heading_1
|
29
|
+
assert_equal "<p>Hello\n", @to.res.join
|
30
|
+
assert_equal 5, @to.characters
|
31
|
+
end
|
32
|
+
|
33
|
+
def accept_heading_2
|
34
|
+
assert_equal "<p>Hello\n", @to.res.join
|
35
|
+
assert_equal 5, @to.characters
|
36
|
+
end
|
37
|
+
|
38
|
+
def accept_heading_3
|
39
|
+
assert_equal "<p>Hello\n", @to.res.join
|
40
|
+
assert_equal 5, @to.characters
|
41
|
+
end
|
42
|
+
|
43
|
+
def accept_heading_4
|
44
|
+
assert_equal "<p>Hello\n", @to.res.join
|
45
|
+
assert_equal 5, @to.characters
|
46
|
+
end
|
47
|
+
|
48
|
+
def accept_heading_b
|
49
|
+
assert_equal "<p><strong>Hello</strong>\n",
|
50
|
+
@to.res.join
|
51
|
+
assert_equal 5, @to.characters
|
52
|
+
end
|
53
|
+
|
54
|
+
def accept_heading_suppressed_crossref
|
55
|
+
assert_equal "<p>Hello\n", @to.res.join
|
56
|
+
assert_equal 5, @to.characters
|
57
|
+
end
|
58
|
+
|
59
|
+
def accept_list_end_bullet
|
60
|
+
assert_equal [], @to.list
|
61
|
+
assert_equal [], @to.in_list_entry
|
62
|
+
|
63
|
+
assert_equal "\n", @to.res.join
|
64
|
+
assert_equal 0, @to.characters
|
65
|
+
end
|
66
|
+
|
67
|
+
def accept_list_end_label
|
68
|
+
assert_equal [], @to.list
|
69
|
+
assert_equal [], @to.in_list_entry
|
70
|
+
|
71
|
+
assert_equal "\n", @to.res.join
|
72
|
+
assert_equal 0, @to.characters
|
73
|
+
end
|
74
|
+
|
75
|
+
def accept_list_end_lalpha
|
76
|
+
assert_equal [], @to.list
|
77
|
+
assert_equal [], @to.in_list_entry
|
78
|
+
|
79
|
+
assert_equal "\n", @to.res.join
|
80
|
+
assert_equal 0, @to.characters
|
81
|
+
end
|
82
|
+
|
83
|
+
def accept_list_end_number
|
84
|
+
assert_equal [], @to.list
|
85
|
+
assert_equal [], @to.in_list_entry
|
86
|
+
|
87
|
+
assert_equal "\n", @to.res.join
|
88
|
+
assert_equal 0, @to.characters
|
89
|
+
end
|
90
|
+
|
91
|
+
def accept_list_end_note
|
92
|
+
assert_equal [], @to.list
|
93
|
+
assert_equal [], @to.in_list_entry
|
94
|
+
|
95
|
+
assert_equal "\n", @to.res.join
|
96
|
+
assert_equal 0, @to.characters
|
97
|
+
end
|
98
|
+
|
99
|
+
def accept_list_end_ualpha
|
100
|
+
assert_equal [], @to.list
|
101
|
+
assert_equal [], @to.in_list_entry
|
102
|
+
|
103
|
+
assert_equal "\n", @to.res.join
|
104
|
+
assert_equal 0, @to.characters
|
105
|
+
end
|
106
|
+
|
107
|
+
def accept_list_item_end_bullet
|
108
|
+
assert_equal [''], @to.in_list_entry
|
109
|
+
assert_equal 0, @to.characters
|
110
|
+
end
|
111
|
+
|
112
|
+
def accept_list_item_end_label
|
113
|
+
assert_equal [''], @to.in_list_entry
|
114
|
+
assert_equal 4, @to.characters
|
115
|
+
end
|
116
|
+
|
117
|
+
def accept_list_item_end_lalpha
|
118
|
+
assert_equal [''], @to.in_list_entry
|
119
|
+
assert_equal 0, @to.characters
|
120
|
+
end
|
121
|
+
|
122
|
+
def accept_list_item_end_note
|
123
|
+
assert_equal [''], @to.in_list_entry
|
124
|
+
assert_equal 4, @to.characters
|
125
|
+
end
|
126
|
+
|
127
|
+
def accept_list_item_end_number
|
128
|
+
assert_equal [''], @to.in_list_entry
|
129
|
+
assert_equal 0, @to.characters
|
130
|
+
end
|
131
|
+
|
132
|
+
def accept_list_item_end_ualpha
|
133
|
+
assert_equal [''], @to.in_list_entry
|
134
|
+
assert_equal 0, @to.characters
|
135
|
+
end
|
136
|
+
|
137
|
+
def accept_list_item_start_bullet
|
138
|
+
assert_equal "<p>", @to.res.join
|
139
|
+
assert_equal 0, @to.characters
|
140
|
+
end
|
141
|
+
|
142
|
+
def accept_list_item_start_label
|
143
|
+
assert_equal "<p>cat — ", @to.res.join
|
144
|
+
assert_equal 4, @to.characters
|
145
|
+
end
|
146
|
+
|
147
|
+
def accept_list_item_start_lalpha
|
148
|
+
assert_equal "<p>", @to.res.join
|
149
|
+
assert_equal 0, @to.characters
|
150
|
+
end
|
151
|
+
|
152
|
+
def accept_list_item_start_note
|
153
|
+
assert_equal "<p>cat — ",
|
154
|
+
@to.res.join
|
155
|
+
assert_equal 4, @to.characters
|
156
|
+
end
|
157
|
+
|
158
|
+
def accept_list_item_start_note_2
|
159
|
+
expected = <<-EXPECTED
|
160
|
+
<p><code>teletype</code> — teletype description
|
161
|
+
|
162
|
+
EXPECTED
|
163
|
+
|
164
|
+
assert_equal expected, @to.res.join
|
165
|
+
assert_equal 29, @to.characters
|
166
|
+
end
|
167
|
+
|
168
|
+
def accept_list_item_start_number
|
169
|
+
assert_equal "<p>", @to.res.join
|
170
|
+
assert_equal 0, @to.characters
|
171
|
+
end
|
172
|
+
|
173
|
+
def accept_list_item_start_ualpha
|
174
|
+
assert_equal "<p>", @to.res.join
|
175
|
+
assert_equal 0, @to.characters
|
176
|
+
end
|
177
|
+
|
178
|
+
def accept_list_start_bullet
|
179
|
+
assert_equal [:BULLET], @to.list
|
180
|
+
assert_equal [''], @to.in_list_entry
|
181
|
+
|
182
|
+
assert_equal '', @to.res.join
|
183
|
+
assert_equal 0, @to.characters
|
184
|
+
end
|
185
|
+
|
186
|
+
def accept_list_start_label
|
187
|
+
assert_equal [:LABEL], @to.list
|
188
|
+
assert_equal [''], @to.in_list_entry
|
189
|
+
|
190
|
+
assert_equal '', @to.res.join
|
191
|
+
assert_equal 0, @to.characters
|
192
|
+
end
|
193
|
+
|
194
|
+
def accept_list_start_lalpha
|
195
|
+
assert_equal [:LALPHA], @to.list
|
196
|
+
assert_equal [''], @to.in_list_entry
|
197
|
+
|
198
|
+
assert_equal '', @to.res.join
|
199
|
+
assert_equal 0, @to.characters
|
200
|
+
end
|
201
|
+
|
202
|
+
def accept_list_start_note
|
203
|
+
assert_equal [:NOTE], @to.list
|
204
|
+
assert_equal [''], @to.in_list_entry
|
205
|
+
|
206
|
+
assert_equal '', @to.res.join
|
207
|
+
assert_equal 0, @to.characters
|
208
|
+
end
|
209
|
+
|
210
|
+
def accept_list_start_number
|
211
|
+
assert_equal [:NUMBER], @to.list
|
212
|
+
assert_equal [''], @to.in_list_entry
|
213
|
+
|
214
|
+
assert_equal '', @to.res.join
|
215
|
+
assert_equal 0, @to.characters
|
216
|
+
end
|
217
|
+
|
218
|
+
def accept_list_start_ualpha
|
219
|
+
assert_equal [:UALPHA], @to.list
|
220
|
+
assert_equal [''], @to.in_list_entry
|
221
|
+
|
222
|
+
assert_equal '', @to.res.join
|
223
|
+
assert_equal 0, @to.characters
|
224
|
+
end
|
225
|
+
|
226
|
+
def accept_paragraph
|
227
|
+
assert_equal "<p>hi\n", @to.res.join
|
228
|
+
|
229
|
+
assert_equal 2, @to.characters
|
230
|
+
end
|
231
|
+
|
232
|
+
def accept_paragraph_b
|
233
|
+
assert_equal "<p>reg <strong>bold words</strong> reg\n", @to.res.join
|
234
|
+
|
235
|
+
assert_equal 18, @to.characters
|
236
|
+
end
|
237
|
+
|
238
|
+
def accept_paragraph_i
|
239
|
+
assert_equal "<p>reg <em>italic words</em> reg\n", @to.res.join
|
240
|
+
|
241
|
+
assert_equal 20, @to.characters
|
242
|
+
end
|
243
|
+
|
244
|
+
def accept_paragraph_plus
|
245
|
+
assert_equal "<p>reg <code>teletype</code> reg\n", @to.res.join
|
246
|
+
|
247
|
+
assert_equal 16, @to.characters
|
248
|
+
end
|
249
|
+
|
250
|
+
def accept_paragraph_star
|
251
|
+
assert_equal "<p>reg <strong>bold</strong> reg\n", @to.res.join
|
252
|
+
|
253
|
+
assert_equal 12, @to.characters
|
254
|
+
end
|
255
|
+
|
256
|
+
def accept_paragraph_underscore
|
257
|
+
assert_equal "<p>reg <em>italic</em> reg\n", @to.res.join
|
258
|
+
|
259
|
+
assert_equal 14, @to.characters
|
260
|
+
end
|
261
|
+
|
262
|
+
def accept_raw
|
263
|
+
assert_equal '', @to.res.join
|
264
|
+
assert_equal 0, @to.characters
|
265
|
+
end
|
266
|
+
|
267
|
+
def accept_rule
|
268
|
+
assert_empty @to.res
|
269
|
+
assert_equal 0, @to.characters
|
270
|
+
end
|
271
|
+
|
272
|
+
def accept_verbatim
|
273
|
+
assert_equal "\n<pre>hi\n world</pre>\n", @to.res.join
|
274
|
+
assert_equal 10, @to.characters
|
275
|
+
end
|
276
|
+
|
277
|
+
def end_accepting
|
278
|
+
assert_equal 'hi', @to.res.join
|
279
|
+
end
|
280
|
+
|
281
|
+
def start_accepting
|
282
|
+
assert_equal [], @to.res
|
283
|
+
assert_equal [], @to.in_list_entry
|
284
|
+
assert_equal [], @to.list
|
285
|
+
assert_equal 0, @to.characters
|
286
|
+
end
|
287
|
+
|
288
|
+
def list_nested
|
289
|
+
expected = <<-EXPECTED
|
290
|
+
<p>l1
|
291
|
+
<p>l1.1
|
292
|
+
|
293
|
+
<p>l2
|
294
|
+
|
295
|
+
EXPECTED
|
296
|
+
|
297
|
+
assert_equal expected, @to.res.join
|
298
|
+
assert_equal 8, @to.characters
|
299
|
+
end
|
300
|
+
|
301
|
+
def list_verbatim
|
302
|
+
expected = <<-EXPECTED
|
303
|
+
<p>list stuff
|
304
|
+
|
305
|
+
<pre>* list
|
306
|
+
with
|
307
|
+
|
308
|
+
second
|
309
|
+
|
310
|
+
1. indented
|
311
|
+
2. numbered
|
312
|
+
|
313
|
+
third
|
314
|
+
|
315
|
+
* second</pre>
|
316
|
+
|
317
|
+
EXPECTED
|
318
|
+
|
319
|
+
assert_equal expected, @to.end_accepting
|
320
|
+
assert_equal 81, @to.characters
|
321
|
+
end
|
322
|
+
|
323
|
+
def test_accept_heading_7
|
324
|
+
@to.start_accepting
|
325
|
+
|
326
|
+
@to.accept_heading @RM::Heading.new(7, 'Hello')
|
327
|
+
|
328
|
+
assert_equal "<p>Hello\n", @to.res.join
|
329
|
+
assert_equal 5, @to.characters
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_accept_heading_aref_class
|
333
|
+
@to.code_object = RDoc::NormalClass.new 'Foo'
|
334
|
+
@to.start_accepting
|
335
|
+
|
336
|
+
@to.accept_heading @RM::Heading.new(1, 'Hello')
|
337
|
+
|
338
|
+
assert_equal "<p>Hello\n",
|
339
|
+
@to.res.join
|
340
|
+
assert_equal 5, @to.characters
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_accept_heading_aref_method
|
344
|
+
@to.code_object = RDoc::AnyMethod.new nil, 'foo'
|
345
|
+
@to.start_accepting
|
346
|
+
|
347
|
+
@to.accept_heading @RM::Heading.new(1, 'Hello')
|
348
|
+
|
349
|
+
assert_equal "<p>Hello\n",
|
350
|
+
@to.res.join
|
351
|
+
assert_equal 5, @to.characters
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_accept_verbatim_ruby
|
355
|
+
options = RDoc::Options.new
|
356
|
+
rdoc = RDoc::RDoc.new
|
357
|
+
rdoc.options = options
|
358
|
+
RDoc::RDoc.current = rdoc
|
359
|
+
|
360
|
+
verb = @RM::Verbatim.new("class C\n", "end\n")
|
361
|
+
|
362
|
+
@to.start_accepting
|
363
|
+
@to.accept_verbatim verb
|
364
|
+
|
365
|
+
expected = <<-EXPECTED
|
366
|
+
|
367
|
+
<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">C</span>
|
368
|
+
<span class="ruby-keyword">end</span>
|
369
|
+
</pre>
|
370
|
+
EXPECTED
|
371
|
+
|
372
|
+
assert_equal expected, @to.res.join
|
373
|
+
assert_equal 11, @to.characters
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_accept_verbatim_ruby_error
|
377
|
+
options = RDoc::Options.new
|
378
|
+
rdoc = RDoc::RDoc.new
|
379
|
+
rdoc.options = options
|
380
|
+
RDoc::RDoc.current = rdoc
|
381
|
+
|
382
|
+
verb = @RM::Verbatim.new("a %z'foo' # => blah\n")
|
383
|
+
|
384
|
+
@to.start_accepting
|
385
|
+
@to.accept_verbatim verb
|
386
|
+
|
387
|
+
expected = <<-EXPECTED
|
388
|
+
|
389
|
+
<pre>a %z'foo' # => blah
|
390
|
+
</pre>
|
391
|
+
EXPECTED
|
392
|
+
|
393
|
+
assert_equal expected, @to.res.join
|
394
|
+
assert_equal 19, @to.characters
|
395
|
+
end
|
396
|
+
|
397
|
+
def test_add_paragraph
|
398
|
+
@to = RDoc::Markup::ToHtmlSnippet.new 0, 3
|
399
|
+
assert_throws :done do
|
400
|
+
@to.add_paragraph
|
401
|
+
@to.add_paragraph
|
402
|
+
@to.add_paragraph
|
403
|
+
end
|
404
|
+
|
405
|
+
assert_equal 3, @to.paragraphs
|
406
|
+
end
|
407
|
+
|
408
|
+
def test_convert_limit
|
409
|
+
rdoc = <<-RDOC
|
410
|
+
= Hello
|
411
|
+
|
412
|
+
This is some text, it *will* be cut off after 100 characters and an ellipsis
|
413
|
+
must follow
|
414
|
+
|
415
|
+
So there you have it
|
416
|
+
RDOC
|
417
|
+
|
418
|
+
expected = <<-EXPECTED
|
419
|
+
<p>Hello
|
420
|
+
<p>This is some text, it <strong>will</strong> be cut off after 100 characters
|
421
|
+
and an ellipsis must follow
|
422
|
+
<p>So there you #{@ellipsis}
|
423
|
+
EXPECTED
|
424
|
+
|
425
|
+
actual = @to.convert rdoc
|
426
|
+
|
427
|
+
assert_equal 111, @to.characters
|
428
|
+
assert_equal expected, actual
|
429
|
+
end
|
430
|
+
|
431
|
+
def test_convert_limit_2
|
432
|
+
rdoc = <<-RDOC
|
433
|
+
Outputs formatted RI data for the class or method +name+.
|
434
|
+
|
435
|
+
Returns true if +name+ was found, false if it was not an alternative could
|
436
|
+
be guessed, raises an error if +name+ couldn't be guessed.
|
437
|
+
RDOC
|
438
|
+
|
439
|
+
expected = <<-EXPECTED
|
440
|
+
<p>Outputs formatted RI data for the class or method <code>name</code>.
|
441
|
+
<p>Returns true if <code>name</code> was found, false if it was #{@ellipsis}
|
442
|
+
EXPECTED
|
443
|
+
|
444
|
+
actual = @to.convert rdoc
|
445
|
+
|
446
|
+
assert_equal expected, actual
|
447
|
+
assert_equal 159, @to.characters
|
448
|
+
end
|
449
|
+
|
450
|
+
def test_convert_limit_paragraphs
|
451
|
+
@to = RDoc::Markup::ToHtmlSnippet.new 100, 3
|
452
|
+
|
453
|
+
rdoc = <<-RDOC
|
454
|
+
= \RDoc - Ruby Documentation System
|
455
|
+
|
456
|
+
* {RDoc Project Page}[https://github.com/rdoc/rdoc/]
|
457
|
+
* {RDoc Documentation}[http://docs.seattlerb.org/rdoc]
|
458
|
+
* {RDoc Bug Tracker}[https://github.com/rdoc/rdoc/issues]
|
459
|
+
|
460
|
+
== DESCRIPTION:
|
461
|
+
|
462
|
+
RDoc produces HTML and command-line documentation for Ruby projects. RDoc
|
463
|
+
includes the +rdoc+ and +ri+ tools for generating and displaying online
|
464
|
+
documentation.
|
465
|
+
|
466
|
+
See RDoc for a description of RDoc's markup and basic use.
|
467
|
+
RDOC
|
468
|
+
|
469
|
+
expected = <<-EXPECTED
|
470
|
+
<p>RDoc - Ruby Documentation System
|
471
|
+
<p>RDoc Project Page
|
472
|
+
<p>RDoc Documentation
|
473
|
+
EXPECTED
|
474
|
+
|
475
|
+
actual = @to.convert rdoc
|
476
|
+
|
477
|
+
assert_equal expected, actual
|
478
|
+
assert_equal 67, @to.characters
|
479
|
+
end
|
480
|
+
|
481
|
+
def test_convert_limit_in_tag
|
482
|
+
@to = RDoc::Markup::ToHtmlSnippet.new 4
|
483
|
+
rdoc = "* ab *c* d\n"
|
484
|
+
|
485
|
+
expected = "<p>ab <strong>c</strong> #{@ellipsis}\n\n"
|
486
|
+
|
487
|
+
actual = @to.convert rdoc
|
488
|
+
|
489
|
+
assert_equal 4, @to.characters
|
490
|
+
assert_equal expected, actual
|
491
|
+
end
|
492
|
+
|
493
|
+
def test_convert_limit_verbatim
|
494
|
+
rdoc = <<-RDOC
|
495
|
+
= Hello There
|
496
|
+
|
497
|
+
This is some text, it *will* be cut off after 100 characters
|
498
|
+
|
499
|
+
This one is cut off in this verbatim section
|
500
|
+
RDOC
|
501
|
+
|
502
|
+
expected = <<-EXPECTED
|
503
|
+
<p>Hello There
|
504
|
+
<p>This is some text, it <strong>will</strong> be cut off after 100 characters
|
505
|
+
|
506
|
+
<pre>This one is cut off in this verbatim ...</pre>
|
507
|
+
EXPECTED
|
508
|
+
|
509
|
+
actual = @to.convert rdoc
|
510
|
+
|
511
|
+
assert_equal expected, actual
|
512
|
+
assert_equal 113, @to.characters
|
513
|
+
end
|
514
|
+
|
515
|
+
def test_convert_limit_verbatim_2
|
516
|
+
rdoc = <<-RDOC
|
517
|
+
Extracts the class, selector and method name parts from +name+ like
|
518
|
+
Foo::Bar#baz.
|
519
|
+
|
520
|
+
NOTE: Given Foo::Bar, Bar is considered a class even though it may be a
|
521
|
+
method
|
522
|
+
RDOC
|
523
|
+
|
524
|
+
expected = <<-EXPECTED
|
525
|
+
<p>Extracts the class, selector and method name parts from <code>name</code>
|
526
|
+
like Foo::Bar#baz.
|
527
|
+
<p>NOTE: Given Foo::Bar, #{@ellipsis}
|
528
|
+
EXPECTED
|
529
|
+
|
530
|
+
actual = @to.convert rdoc
|
531
|
+
|
532
|
+
assert_equal expected, actual
|
533
|
+
assert_equal 101, @to.characters
|
534
|
+
end
|
535
|
+
|
536
|
+
def test_convert_limit_verbatim_multiline
|
537
|
+
rdoc = <<-RDOC
|
538
|
+
Look for directives in a normal comment block:
|
539
|
+
|
540
|
+
# :stopdoc:
|
541
|
+
# Don't display comment from this point forward
|
542
|
+
|
543
|
+
This routine modifies its +comment+ parameter.
|
544
|
+
RDOC
|
545
|
+
|
546
|
+
expected = <<-EXPECTED
|
547
|
+
<p>Look for directives in a normal comment block:
|
548
|
+
|
549
|
+
<pre># :stopdoc:
|
550
|
+
# Don't display comment from this point forward</pre>
|
551
|
+
EXPECTED
|
552
|
+
|
553
|
+
actual = @to.convert rdoc
|
554
|
+
|
555
|
+
assert_equal expected, actual
|
556
|
+
assert_equal 105, @to.characters
|
557
|
+
end
|
558
|
+
|
559
|
+
def test_convert_limit_over
|
560
|
+
@to = RDoc::Markup::ToHtmlSnippet.new 4
|
561
|
+
rdoc = "* text\n" * 2
|
562
|
+
|
563
|
+
expected = "<p>text\n"
|
564
|
+
expected.chomp!
|
565
|
+
expected << " #{@ellipsis}\n"
|
566
|
+
|
567
|
+
actual = @to.convert rdoc
|
568
|
+
|
569
|
+
assert_equal 4, @to.characters
|
570
|
+
assert_equal expected, actual
|
571
|
+
end
|
572
|
+
|
573
|
+
def test_convert_string
|
574
|
+
assert_equal '<>', @to.convert_string('<>')
|
575
|
+
end
|
576
|
+
|
577
|
+
def test_convert_RDOCLINK_label_label
|
578
|
+
result = @to.convert 'rdoc-label:label-One'
|
579
|
+
|
580
|
+
assert_equal "<p>One\n", result
|
581
|
+
assert_equal 3, @to.characters
|
582
|
+
end
|
583
|
+
|
584
|
+
def test_convert_RDOCLINK_label_foottext
|
585
|
+
result = @to.convert 'rdoc-label:foottext-1'
|
586
|
+
|
587
|
+
assert_equal "<p>*1\n", result
|
588
|
+
assert_equal 2, @to.characters
|
589
|
+
end
|
590
|
+
|
591
|
+
def test_convert_RDOCLINK_label_footmark
|
592
|
+
result = @to.convert 'rdoc-label:footmark-1'
|
593
|
+
|
594
|
+
assert_equal "<p>^1\n", result
|
595
|
+
assert_equal 2, @to.characters
|
596
|
+
end
|
597
|
+
|
598
|
+
def test_convert_RDOCLINK_ref
|
599
|
+
result = @to.convert 'rdoc-ref:C'
|
600
|
+
|
601
|
+
assert_equal "<p>C\n", result
|
602
|
+
assert_equal 1, @to.characters
|
603
|
+
end
|
604
|
+
|
605
|
+
def test_convert_TIDYLINK_rdoc_label
|
606
|
+
result = @to.convert '{foo}[rdoc-label:foottext-1]'
|
607
|
+
|
608
|
+
assert_equal "<p>foo\n", result
|
609
|
+
assert_equal 3, @to.characters
|
610
|
+
end
|
611
|
+
|
612
|
+
def test_handle_special_HYPERLINK_link
|
613
|
+
special = RDoc::Markup::Special.new 0, 'link:README.txt'
|
614
|
+
|
615
|
+
link = @to.handle_special_HYPERLINK special
|
616
|
+
|
617
|
+
assert_equal 'README.txt', link
|
618
|
+
end
|
619
|
+
|
620
|
+
def test_list_verbatim_2
|
621
|
+
str = "* one\n verb1\n verb2\n* two\n"
|
622
|
+
|
623
|
+
expected = <<-EXPECTED
|
624
|
+
<p>one
|
625
|
+
|
626
|
+
<pre>verb1
|
627
|
+
verb2</pre>
|
628
|
+
<p>two
|
629
|
+
|
630
|
+
EXPECTED
|
631
|
+
|
632
|
+
assert_equal expected, @m.convert(str, @to)
|
633
|
+
assert_equal 17, @to.characters
|
634
|
+
end
|
635
|
+
|
636
|
+
def test_on_tags
|
637
|
+
on = RDoc::Markup::AttrChanger.new 2, 0
|
638
|
+
|
639
|
+
@to.on_tags [], on
|
640
|
+
|
641
|
+
assert_equal 2, @to.mask
|
642
|
+
end
|
643
|
+
|
644
|
+
def test_off_tags
|
645
|
+
on = RDoc::Markup::AttrChanger.new 2, 0
|
646
|
+
off = RDoc::Markup::AttrChanger.new 0, 2
|
647
|
+
|
648
|
+
@to.on_tags [], on
|
649
|
+
@to.off_tags [], off
|
650
|
+
|
651
|
+
assert_equal 0, @to.mask
|
652
|
+
end
|
653
|
+
|
654
|
+
def test_to_html
|
655
|
+
assert_equal "<p><code>--</code>\n", util_format("<tt>--</tt>")
|
656
|
+
assert_equal 2, @to.characters
|
657
|
+
end
|
658
|
+
|
659
|
+
def util_format text
|
660
|
+
paragraph = RDoc::Markup::Paragraph.new text
|
661
|
+
|
662
|
+
@to.start_accepting
|
663
|
+
@to.accept_paragraph paragraph
|
664
|
+
@to.end_accepting
|
665
|
+
end
|
666
|
+
|
667
|
+
end
|
668
|
+
|