rdoc 4.0.0.preview2 → 4.0.0.preview2.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +4 -1
- data/History.rdoc +26 -1
- data/Manifest.txt +2 -0
- data/Rakefile +1 -1
- data/lib/rdoc.rb +1 -1
- data/lib/rdoc/class_module.rb +13 -2
- data/lib/rdoc/context.rb +7 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +7 -1
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +1 -1
- data/lib/rdoc/markdown/entities.rb +3 -0
- data/lib/rdoc/markup/document.rb +8 -8
- data/lib/rdoc/markup/formatter.rb +6 -1
- data/lib/rdoc/markup/heading.rb +2 -1
- data/lib/rdoc/markup/to_joined_paragraph.rb +5 -2
- data/lib/rdoc/markup/to_table_of_contents.rb +27 -1
- data/lib/rdoc/options.rb +36 -1
- data/lib/rdoc/parser.rb +30 -1
- data/lib/rdoc/parser/c.rb +56 -14
- data/lib/rdoc/parser/changelog.rb +186 -0
- data/lib/rdoc/parser/ruby.rb +53 -11
- data/lib/rdoc/rdoc.rb +9 -0
- data/lib/rdoc/ri/driver.rb +5 -1
- data/lib/rdoc/ruby_lex.rb +1 -1
- data/lib/rdoc/rubygems_hook.rb +16 -10
- data/lib/rdoc/servlet.rb +111 -6
- data/lib/rdoc/store.rb +110 -19
- data/test/test_rdoc_class_module.rb +32 -0
- data/test/test_rdoc_context.rb +25 -0
- data/test/test_rdoc_markup_document.rb +19 -0
- data/test/test_rdoc_markup_to_table_of_contents.rb +31 -0
- data/test/test_rdoc_options.rb +38 -0
- data/test/test_rdoc_parser.rb +56 -0
- data/test/test_rdoc_parser_c.rb +129 -6
- data/test/test_rdoc_parser_changelog.rb +294 -0
- data/test/test_rdoc_parser_ruby.rb +145 -8
- data/test/test_rdoc_rdoc.rb +25 -5
- data/test/test_rdoc_ri_driver.rb +27 -0
- data/test/test_rdoc_ruby_lex.rb +10 -0
- data/test/test_rdoc_rubygems_hook.rb +49 -18
- data/test/test_rdoc_store.rb +148 -37
- metadata +26 -23
- metadata.gz.sig +0 -0
@@ -80,23 +80,53 @@ class C; end
|
|
80
80
|
assert_equal 'A', name_t.text
|
81
81
|
assert_equal 'A', given_name
|
82
82
|
|
83
|
-
cont, name_t, given_name = util_parser('
|
83
|
+
cont, name_t, given_name = util_parser('B::C') .get_class_or_module ctxt
|
84
84
|
|
85
|
-
|
86
|
-
assert_equal
|
87
|
-
assert_equal
|
85
|
+
b = @store.find_module_named('B')
|
86
|
+
assert_equal b, cont
|
87
|
+
assert_equal [@top_level], b.in_files
|
88
|
+
assert_equal 'C', name_t.text
|
89
|
+
assert_equal 'B::C', given_name
|
88
90
|
|
89
|
-
cont, name_t, given_name = util_parser('
|
91
|
+
cont, name_t, given_name = util_parser('D:: E').get_class_or_module ctxt
|
90
92
|
|
91
|
-
assert_equal @store.find_module_named('
|
92
|
-
assert_equal '
|
93
|
-
assert_equal '
|
93
|
+
assert_equal @store.find_module_named('D'), cont
|
94
|
+
assert_equal 'E', name_t.text
|
95
|
+
assert_equal 'D::E', given_name
|
94
96
|
|
95
97
|
assert_raises NoMethodError do
|
96
98
|
util_parser("A::\nB").get_class_or_module ctxt
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
def test_get_class_or_module_document_children
|
103
|
+
ctxt = @top_level.add_class RDoc::NormalClass, 'A'
|
104
|
+
ctxt.stop_doc
|
105
|
+
|
106
|
+
util_parser('B::C').get_class_or_module ctxt
|
107
|
+
|
108
|
+
b = @store.find_module_named('A::B')
|
109
|
+
assert b.ignored?
|
110
|
+
|
111
|
+
d = @top_level.add_class RDoc::NormalClass, 'A::D'
|
112
|
+
|
113
|
+
util_parser('D::E').get_class_or_module ctxt
|
114
|
+
|
115
|
+
refute d.ignored?
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_get_class_or_module_ignore_constants
|
119
|
+
ctxt = RDoc::Context.new
|
120
|
+
ctxt.store = @store
|
121
|
+
|
122
|
+
util_parser('A') .get_class_or_module ctxt, true
|
123
|
+
util_parser('A::B').get_class_or_module ctxt, true
|
124
|
+
|
125
|
+
assert_empty ctxt.constants
|
126
|
+
assert_empty @store.modules_hash.keys
|
127
|
+
assert_empty @store.classes_hash.keys
|
128
|
+
end
|
129
|
+
|
100
130
|
def test_get_class_specification
|
101
131
|
assert_equal 'A', util_parser('A') .get_class_specification
|
102
132
|
assert_equal 'A::B', util_parser('A::B').get_class_specification
|
@@ -1108,6 +1138,37 @@ EOF
|
|
1108
1138
|
assert_equal 'A', bar.find_module_named('A').full_name
|
1109
1139
|
end
|
1110
1140
|
|
1141
|
+
def test_parse_constant_in_method
|
1142
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
1143
|
+
|
1144
|
+
util_parser 'A::B = v'
|
1145
|
+
|
1146
|
+
tk = @parser.get_tk
|
1147
|
+
|
1148
|
+
@parser.parse_constant klass, tk, @comment, true
|
1149
|
+
|
1150
|
+
assert_empty klass.constants
|
1151
|
+
|
1152
|
+
assert_empty @store.modules_hash.keys
|
1153
|
+
assert_equal %w[Foo], @store.classes_hash.keys
|
1154
|
+
end
|
1155
|
+
|
1156
|
+
def test_parse_constant_rescue
|
1157
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
1158
|
+
|
1159
|
+
util_parser "A => e"
|
1160
|
+
|
1161
|
+
tk = @parser.get_tk
|
1162
|
+
|
1163
|
+
@parser.parse_constant klass, tk, @comment
|
1164
|
+
|
1165
|
+
assert_empty klass.constants
|
1166
|
+
assert_empty klass.modules
|
1167
|
+
|
1168
|
+
assert_empty @store.modules_hash.keys
|
1169
|
+
assert_equal %w[Foo], @store.classes_hash.keys
|
1170
|
+
end
|
1171
|
+
|
1111
1172
|
def test_parse_constant_stopdoc
|
1112
1173
|
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
1113
1174
|
klass.stop_doc
|
@@ -1121,6 +1182,27 @@ EOF
|
|
1121
1182
|
assert_empty klass.constants
|
1122
1183
|
end
|
1123
1184
|
|
1185
|
+
def test_parse_comment_nested
|
1186
|
+
content = <<-CONTENT
|
1187
|
+
A::B::C = 1
|
1188
|
+
CONTENT
|
1189
|
+
|
1190
|
+
util_parser content
|
1191
|
+
|
1192
|
+
tk = @parser.get_tk
|
1193
|
+
|
1194
|
+
parsed = @parser.parse_constant @top_level, tk, 'comment'
|
1195
|
+
|
1196
|
+
assert parsed
|
1197
|
+
|
1198
|
+
a = @top_level.find_module_named 'A'
|
1199
|
+
b = a.find_module_named 'B'
|
1200
|
+
c = b.constants.first
|
1201
|
+
|
1202
|
+
assert_equal 'A::B::C', c.full_name
|
1203
|
+
assert_equal 'comment', c.comment
|
1204
|
+
end
|
1205
|
+
|
1124
1206
|
def test_parse_include
|
1125
1207
|
klass = RDoc::NormalClass.new 'C'
|
1126
1208
|
klass.parent = @top_level
|
@@ -2585,6 +2667,61 @@ end
|
|
2585
2667
|
assert_equal 'A nice girl', m.comment.text
|
2586
2668
|
end
|
2587
2669
|
|
2670
|
+
def test_scan_constant_in_method
|
2671
|
+
content = <<-CONTENT # newline is after M is important
|
2672
|
+
module M
|
2673
|
+
def m
|
2674
|
+
A
|
2675
|
+
B::C
|
2676
|
+
end
|
2677
|
+
end
|
2678
|
+
CONTENT
|
2679
|
+
|
2680
|
+
util_parser content
|
2681
|
+
|
2682
|
+
@parser.scan
|
2683
|
+
|
2684
|
+
m = @top_level.modules.first
|
2685
|
+
|
2686
|
+
assert_empty m.constants
|
2687
|
+
|
2688
|
+
assert_empty @store.classes_hash.keys
|
2689
|
+
assert_equal %w[M], @store.modules_hash.keys
|
2690
|
+
end
|
2691
|
+
|
2692
|
+
def test_scan_constant_in_rescue
|
2693
|
+
content = <<-CONTENT # newline is after M is important
|
2694
|
+
module M
|
2695
|
+
def m
|
2696
|
+
rescue A::B
|
2697
|
+
rescue A::C => e
|
2698
|
+
rescue A::D, A::E
|
2699
|
+
rescue A::F,
|
2700
|
+
A::G
|
2701
|
+
rescue H
|
2702
|
+
rescue I => e
|
2703
|
+
rescue J, K
|
2704
|
+
rescue L =>
|
2705
|
+
e
|
2706
|
+
rescue M;
|
2707
|
+
rescue N,
|
2708
|
+
O => e
|
2709
|
+
end
|
2710
|
+
end
|
2711
|
+
CONTENT
|
2712
|
+
|
2713
|
+
util_parser content
|
2714
|
+
|
2715
|
+
@parser.scan
|
2716
|
+
|
2717
|
+
m = @top_level.modules.first
|
2718
|
+
|
2719
|
+
assert_empty m.constants
|
2720
|
+
|
2721
|
+
assert_empty @store.classes_hash.keys
|
2722
|
+
assert_equal %w[M], @store.modules_hash.keys
|
2723
|
+
end
|
2724
|
+
|
2588
2725
|
def test_scan_constant_nodoc
|
2589
2726
|
content = <<-CONTENT # newline is after M is important
|
2590
2727
|
module M
|
data/test/test_rdoc_rdoc.rb
CHANGED
@@ -123,13 +123,14 @@ class TestRDocRDoc < RDoc::TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_normalized_file_list_non_file_directory
|
126
|
-
|
127
|
-
|
126
|
+
dev = defined?(File::NULL) ? File::NULL : '/dev/stdin'
|
127
|
+
skip "#{dev} is not a character special" unless
|
128
|
+
File.chardev? dev
|
128
129
|
|
129
130
|
files = nil
|
130
131
|
|
131
132
|
out, err = verbose_capture_io do
|
132
|
-
files = @rdoc.normalized_file_list
|
133
|
+
files = @rdoc.normalized_file_list [dev]
|
133
134
|
end
|
134
135
|
|
135
136
|
files = files.map { |file| File.expand_path file }
|
@@ -137,8 +138,8 @@ class TestRDocRDoc < RDoc::TestCase
|
|
137
138
|
assert_empty files
|
138
139
|
|
139
140
|
assert_empty out
|
140
|
-
assert_match %r
|
141
|
-
assert_match %r
|
141
|
+
assert_match %r"^rdoc can't parse", err
|
142
|
+
assert_match %r"#{dev}$", err
|
142
143
|
end
|
143
144
|
|
144
145
|
def test_parse_file
|
@@ -158,6 +159,25 @@ class TestRDocRDoc < RDoc::TestCase
|
|
158
159
|
end
|
159
160
|
end
|
160
161
|
|
162
|
+
def test_parse_file_page_dir
|
163
|
+
@rdoc.store = RDoc::Store.new
|
164
|
+
|
165
|
+
temp_dir do |dir|
|
166
|
+
FileUtils.mkdir 'pages'
|
167
|
+
@rdoc.options.page_dir = Pathname('pages')
|
168
|
+
@rdoc.options.root = Pathname(Dir.pwd)
|
169
|
+
|
170
|
+
open 'pages/test.txt', 'w' do |io|
|
171
|
+
io.puts 'hi'
|
172
|
+
end
|
173
|
+
|
174
|
+
top_level = @rdoc.parse_file 'pages/test.txt'
|
175
|
+
|
176
|
+
assert_equal 'pages/test.txt', top_level.absolute_name
|
177
|
+
assert_equal 'test.txt', top_level.relative_name
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
161
181
|
def test_parse_file_relative
|
162
182
|
pwd = Dir.pwd
|
163
183
|
|
data/test/test_rdoc_ri_driver.rb
CHANGED
@@ -747,6 +747,25 @@ Foo::Bar#bother
|
|
747
747
|
assert_match %r%README\.md%, out
|
748
748
|
end
|
749
749
|
|
750
|
+
def test_display_page_extension
|
751
|
+
util_store
|
752
|
+
|
753
|
+
other = @store1.add_file 'README.EXT'
|
754
|
+
other.parser = RDoc::Parser::Simple
|
755
|
+
other.comment =
|
756
|
+
doc(
|
757
|
+
head(1, 'README.EXT'),
|
758
|
+
para('This is the other README'))
|
759
|
+
|
760
|
+
@store1.save_page other
|
761
|
+
|
762
|
+
out, = capture_io do
|
763
|
+
@driver.display_page 'home:README.EXT'
|
764
|
+
end
|
765
|
+
|
766
|
+
assert_match 'other README', out
|
767
|
+
end
|
768
|
+
|
750
769
|
def test_display_page_ignore_directory
|
751
770
|
util_store
|
752
771
|
|
@@ -1147,6 +1166,14 @@ Foo::Bar#bother
|
|
1147
1166
|
assert_equal nil, meth, 'ruby page'
|
1148
1167
|
end
|
1149
1168
|
|
1169
|
+
def test_parse_name_page_extenson
|
1170
|
+
klass, type, meth = @driver.parse_name 'ruby:README.EXT'
|
1171
|
+
|
1172
|
+
assert_equal 'ruby', klass, 'ruby project'
|
1173
|
+
assert_equal ':', type, 'ruby type'
|
1174
|
+
assert_equal 'README.EXT', meth, 'ruby page'
|
1175
|
+
end
|
1176
|
+
|
1150
1177
|
def test_parse_name_single_class
|
1151
1178
|
klass, type, meth = @driver.parse_name 'Foo'
|
1152
1179
|
|
data/test/test_rdoc_ruby_lex.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
1
3
|
require 'rdoc/test_case'
|
2
4
|
|
3
5
|
class TestRDocRubyLex < RDoc::TestCase
|
@@ -133,6 +135,14 @@ U
|
|
133
135
|
assert_equal expected, tokens
|
134
136
|
end
|
135
137
|
|
138
|
+
def test_class_tokenize_identifier_high_unicode
|
139
|
+
tokens = RDoc::RubyLex.tokenize '𝖒', nil
|
140
|
+
|
141
|
+
expected = @TK::TkIDENTIFIER.new(0, 1, 0, '𝖒')
|
142
|
+
|
143
|
+
assert_equal expected, tokens.first
|
144
|
+
end
|
145
|
+
|
136
146
|
def test_class_tokenize_percent_1
|
137
147
|
tokens = RDoc::RubyLex.tokenize 'v%10==10', nil
|
138
148
|
|
@@ -10,7 +10,15 @@ class TestRDocRubygemsHook < Gem::TestCase
|
|
10
10
|
skip 'requires RubyGems 1.9+' unless
|
11
11
|
Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9')
|
12
12
|
|
13
|
-
@a = quick_spec 'a'
|
13
|
+
@a = quick_spec 'a' do |s|
|
14
|
+
s.rdoc_options = %w[--main MyTitle]
|
15
|
+
s.extra_rdoc_files = %w[README]
|
16
|
+
end
|
17
|
+
|
18
|
+
write_file File.join(@tempdir, 'lib', 'a.rb')
|
19
|
+
write_file File.join(@tempdir, 'README')
|
20
|
+
|
21
|
+
install_gem @a
|
14
22
|
|
15
23
|
@hook = RDoc::RubygemsHook.new @a
|
16
24
|
|
@@ -24,7 +32,7 @@ class TestRDocRubygemsHook < Gem::TestCase
|
|
24
32
|
end
|
25
33
|
|
26
34
|
def test_initialize
|
27
|
-
|
35
|
+
refute @hook.generate_rdoc
|
28
36
|
assert @hook.generate_ri
|
29
37
|
|
30
38
|
rdoc = RDoc::RubygemsHook.new @a, false, false
|
@@ -66,12 +74,37 @@ class TestRDocRubygemsHook < Gem::TestCase
|
|
66
74
|
|
67
75
|
@hook.generate
|
68
76
|
|
77
|
+
refute @hook.rdoc_installed?
|
78
|
+
assert @hook.ri_installed?
|
79
|
+
|
80
|
+
rdoc = @hook.instance_variable_get :@rdoc
|
81
|
+
|
82
|
+
refute rdoc.options.hyperlink_all
|
83
|
+
assert_equal Pathname(@a.full_gem_path), rdoc.options.root
|
84
|
+
assert_equal %w[README lib], rdoc.options.files.sort
|
85
|
+
|
86
|
+
assert_equal 'MyTitle', rdoc.store.main
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_generate_all
|
90
|
+
@hook.generate_rdoc = true
|
91
|
+
@hook.generate_ri = true
|
92
|
+
|
93
|
+
FileUtils.mkdir_p @a.doc_dir
|
94
|
+
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
|
95
|
+
|
96
|
+
@hook.generate
|
97
|
+
|
69
98
|
assert @hook.rdoc_installed?
|
70
99
|
assert @hook.ri_installed?
|
71
100
|
|
72
101
|
rdoc = @hook.instance_variable_get :@rdoc
|
73
102
|
|
74
103
|
refute rdoc.options.hyperlink_all
|
104
|
+
assert_equal Pathname(@a.full_gem_path), rdoc.options.root
|
105
|
+
assert_equal %w[README lib], rdoc.options.files.sort
|
106
|
+
|
107
|
+
assert_equal 'MyTitle', rdoc.store.main
|
75
108
|
end
|
76
109
|
|
77
110
|
def test_generate_configuration_rdoc_array
|
@@ -133,7 +166,7 @@ class TestRDocRubygemsHook < Gem::TestCase
|
|
133
166
|
|
134
167
|
@hook.generate
|
135
168
|
|
136
|
-
|
169
|
+
refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
|
137
170
|
assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
|
138
171
|
end
|
139
172
|
|
@@ -183,7 +216,7 @@ class TestRDocRubygemsHook < Gem::TestCase
|
|
183
216
|
|
184
217
|
assert_equal @a.base_dir, e.directory
|
185
218
|
ensure
|
186
|
-
FileUtils.chmod
|
219
|
+
FileUtils.chmod(0755, @a.base_dir) if File.directory?(@a.base_dir)
|
187
220
|
end
|
188
221
|
|
189
222
|
def test_ri_installed?
|
@@ -202,20 +235,18 @@ class TestRDocRubygemsHook < Gem::TestCase
|
|
202
235
|
|
203
236
|
def test_setup_unwritable
|
204
237
|
skip 'chmod not supported' if Gem.win_platform?
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
FileUtils.rm_r @a.doc_dir
|
218
|
-
end
|
238
|
+
FileUtils.mkdir_p @a.doc_dir
|
239
|
+
FileUtils.chmod 0, @a.doc_dir
|
240
|
+
|
241
|
+
e = assert_raises Gem::FilePermissionError do
|
242
|
+
@hook.setup
|
243
|
+
end
|
244
|
+
|
245
|
+
assert_equal @a.doc_dir, e.directory
|
246
|
+
ensure
|
247
|
+
if File.exist? @a.doc_dir
|
248
|
+
FileUtils.chmod 0755, @a.doc_dir
|
249
|
+
FileUtils.rm_r @a.doc_dir
|
219
250
|
end
|
220
251
|
end
|
221
252
|
|
data/test/test_rdoc_store.rb
CHANGED
@@ -18,6 +18,7 @@ class TestRDocStore < XrefTestCase
|
|
18
18
|
|
19
19
|
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
|
20
20
|
@klass.add_comment 'original', @top_level
|
21
|
+
@klass.record_location @top_level
|
21
22
|
|
22
23
|
@cmeth = RDoc::AnyMethod.new nil, 'cmethod'
|
23
24
|
@cmeth.singleton = true
|
@@ -87,15 +88,17 @@ class TestRDocStore < XrefTestCase
|
|
87
88
|
@s.clean_cache_collection ancestors
|
88
89
|
|
89
90
|
expected = {
|
90
|
-
:ancestors
|
91
|
-
:attributes
|
92
|
-
:class_methods
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
91
|
+
:ancestors => ancestors,
|
92
|
+
:attributes => attrs,
|
93
|
+
:class_methods => cmethods,
|
94
|
+
:c_class_variables => {},
|
95
|
+
:c_singleton_class_variables => {},
|
96
|
+
:encoding => nil,
|
97
|
+
:instance_methods => imethods,
|
98
|
+
:modules => modules,
|
99
|
+
:pages => pages,
|
100
|
+
:main => main,
|
101
|
+
:title => title,
|
99
102
|
}
|
100
103
|
|
101
104
|
@s.save_cache
|
@@ -115,6 +118,38 @@ class TestRDocStore < XrefTestCase
|
|
115
118
|
refute File.exist?(path), "#{path} exists"
|
116
119
|
end
|
117
120
|
|
121
|
+
def test_add_c_enclosure
|
122
|
+
@s.add_c_enclosure 'cC1', @c1
|
123
|
+
|
124
|
+
expected = { 'cC1' => @c1 }
|
125
|
+
|
126
|
+
assert_equal expected, @s.c_enclosure_classes
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_add_c_variables
|
130
|
+
options = RDoc::Options.new
|
131
|
+
|
132
|
+
c_file = @s.add_file 'ext.c'
|
133
|
+
|
134
|
+
some_ext = c_file.add_class RDoc::NormalClass, 'SomeExt'
|
135
|
+
c_file.add_class RDoc::SingleClass, 'SomeExtSingle'
|
136
|
+
|
137
|
+
c_parser = RDoc::Parser::C.new c_file, 'ext.c', '', options, nil
|
138
|
+
|
139
|
+
c_parser.classes['cSomeExt'] = some_ext
|
140
|
+
c_parser.singleton_classes['s_cSomeExt'] = 'SomeExtSingle'
|
141
|
+
|
142
|
+
@s.add_c_variables c_parser
|
143
|
+
|
144
|
+
expected = { 'ext.c' => { 'cSomeExt' => 'SomeExt' } }
|
145
|
+
|
146
|
+
assert_equal expected, @s.c_class_variables
|
147
|
+
|
148
|
+
expected = { 'ext.c' => { 's_cSomeExt' => 'SomeExtSingle' } }
|
149
|
+
|
150
|
+
assert_equal expected, @s.c_singleton_class_variables
|
151
|
+
end
|
152
|
+
|
118
153
|
def test_add_file
|
119
154
|
top_level = @store.add_file 'file.rb'
|
120
155
|
|
@@ -214,6 +249,31 @@ class TestRDocStore < XrefTestCase
|
|
214
249
|
refute_empty a1.aliases
|
215
250
|
end
|
216
251
|
|
252
|
+
def test_find_c_enclosure
|
253
|
+
assert_nil @s.find_c_enclosure 'cC1'
|
254
|
+
|
255
|
+
@s.add_c_enclosure 'cC1', @c1
|
256
|
+
|
257
|
+
assert_equal @c1, @s.find_c_enclosure('cC1')
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_find_c_enclosure_from_cache
|
261
|
+
@s.save_class @klass
|
262
|
+
@s.classes_hash.clear
|
263
|
+
|
264
|
+
assert_nil @s.find_c_enclosure 'cObject'
|
265
|
+
|
266
|
+
@s.c_enclosure_names['cObject'] = 'Object'
|
267
|
+
|
268
|
+
klass = @s.find_c_enclosure('cObject')
|
269
|
+
assert_equal @klass, klass
|
270
|
+
|
271
|
+
assert_empty klass.comment_location
|
272
|
+
assert_equal @top_level, klass.parent
|
273
|
+
|
274
|
+
assert_includes @s.c_enclosure_classes, 'cObject'
|
275
|
+
end
|
276
|
+
|
217
277
|
def test_find_class_named
|
218
278
|
assert_equal @c1, @store.find_class_named('C1')
|
219
279
|
|
@@ -329,11 +389,15 @@ class TestRDocStore < XrefTestCase
|
|
329
389
|
|
330
390
|
def test_load_cache
|
331
391
|
cache = {
|
332
|
-
:
|
333
|
-
|
334
|
-
:
|
335
|
-
|
336
|
-
:
|
392
|
+
:c_class_variables =>
|
393
|
+
{ 'file.c' => { 'cKlass' => 'Klass' } },
|
394
|
+
:c_singleton_class_variables =>
|
395
|
+
{ 'file.c' => { 'sKlass' => 'KlassSingle' } },
|
396
|
+
:encoding => :encoding_value,
|
397
|
+
:methods => { "Object" => %w[Object#method] },
|
398
|
+
:main => @page.full_name,
|
399
|
+
:modules => %w[Object],
|
400
|
+
:pages => [],
|
337
401
|
}
|
338
402
|
|
339
403
|
Dir.mkdir @tmpdir
|
@@ -348,17 +412,28 @@ class TestRDocStore < XrefTestCase
|
|
348
412
|
|
349
413
|
assert_equal :encoding_value, @s.encoding
|
350
414
|
assert_equal 'README.txt', @s.main
|
415
|
+
|
416
|
+
expected = { 'file.c' => { 'cKlass' => 'Klass' } }
|
417
|
+
assert_equal expected, @s.cache[:c_class_variables]
|
418
|
+
|
419
|
+
expected = { 'file.c' => { 'sKlass' => 'KlassSingle' } }
|
420
|
+
assert_equal expected, @s.cache[:c_singleton_class_variables]
|
421
|
+
|
422
|
+
expected = { 'cKlass' => 'Klass' }
|
423
|
+
assert_equal expected, @s.c_enclosure_names
|
351
424
|
end
|
352
425
|
|
353
426
|
def test_load_cache_encoding_differs
|
354
427
|
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
355
428
|
|
356
429
|
cache = {
|
357
|
-
:
|
358
|
-
:
|
359
|
-
:
|
360
|
-
:
|
361
|
-
:
|
430
|
+
:c_class_variables => {},
|
431
|
+
:c_singleton_class_variables => {},
|
432
|
+
:encoding => Encoding::ISO_8859_1,
|
433
|
+
:main => nil,
|
434
|
+
:methods => { "Object" => %w[Object#method] },
|
435
|
+
:modules => %w[Object],
|
436
|
+
:pages => [],
|
362
437
|
}
|
363
438
|
|
364
439
|
Dir.mkdir @tmpdir
|
@@ -378,15 +453,17 @@ class TestRDocStore < XrefTestCase
|
|
378
453
|
|
379
454
|
def test_load_cache_no_cache
|
380
455
|
cache = {
|
381
|
-
:ancestors
|
382
|
-
:attributes
|
383
|
-
:class_methods
|
384
|
-
:
|
385
|
-
:
|
386
|
-
:
|
387
|
-
:
|
388
|
-
:
|
389
|
-
:
|
456
|
+
:ancestors => {},
|
457
|
+
:attributes => {},
|
458
|
+
:class_methods => {},
|
459
|
+
:c_class_variables => {},
|
460
|
+
:c_singleton_class_variables => {},
|
461
|
+
:encoding => nil,
|
462
|
+
:instance_methods => {},
|
463
|
+
:main => nil,
|
464
|
+
:modules => [],
|
465
|
+
:pages => [],
|
466
|
+
:title => nil,
|
390
467
|
}
|
391
468
|
|
392
469
|
@s.load_cache
|
@@ -404,6 +481,8 @@ class TestRDocStore < XrefTestCase
|
|
404
481
|
:modules => %w[Object],
|
405
482
|
# no :pages
|
406
483
|
# no :main
|
484
|
+
# no :c_class_variables
|
485
|
+
# no :c_singleton_class_variables
|
407
486
|
}
|
408
487
|
|
409
488
|
Dir.mkdir @tmpdir
|
@@ -415,14 +494,16 @@ class TestRDocStore < XrefTestCase
|
|
415
494
|
@s.load_cache
|
416
495
|
|
417
496
|
expected = {
|
418
|
-
:ancestors
|
419
|
-
:attributes
|
420
|
-
:class_methods
|
421
|
-
:
|
422
|
-
:
|
423
|
-
:
|
424
|
-
:
|
425
|
-
:
|
497
|
+
:ancestors => {},
|
498
|
+
:attributes => {},
|
499
|
+
:class_methods => {},
|
500
|
+
:c_class_variables => {},
|
501
|
+
:c_singleton_class_variables => {},
|
502
|
+
:encoding => :encoding_value,
|
503
|
+
:instance_methods => { "Object" => %w[Object#method] },
|
504
|
+
:main => nil,
|
505
|
+
:modules => %w[Object],
|
506
|
+
:pages => [],
|
426
507
|
}
|
427
508
|
|
428
509
|
assert_equal expected, @s.cache
|
@@ -534,6 +615,8 @@ class TestRDocStore < XrefTestCase
|
|
534
615
|
},
|
535
616
|
:attributes => { 'Object' => ['attr_accessor attr'] },
|
536
617
|
:class_methods => { 'Object' => %w[cmethod] },
|
618
|
+
:c_class_variables => {},
|
619
|
+
:c_singleton_class_variables => {},
|
537
620
|
:instance_methods => {
|
538
621
|
'Object' => %w[attr method method! method_bang],
|
539
622
|
'Object::SubClass' => %w[method],
|
@@ -564,16 +647,44 @@ class TestRDocStore < XrefTestCase
|
|
564
647
|
@s.main = @page.full_name
|
565
648
|
@s.title = 'title'
|
566
649
|
|
650
|
+
options = RDoc::Options.new
|
651
|
+
|
652
|
+
c_file = @s.add_file 'ext.c'
|
653
|
+
|
654
|
+
some_ext = c_file.add_class RDoc::NormalClass, 'SomeExt'
|
655
|
+
c_file.add_class RDoc::SingleClass, 'SomeExtSingle'
|
656
|
+
|
657
|
+
c_parser = RDoc::Parser::C.new c_file, 'ext.c', '', options, nil
|
658
|
+
|
659
|
+
c_parser.classes['cSomeExt'] = some_ext
|
660
|
+
c_parser.singleton_classes['s_cSomeExt'] = 'SomeExtSingle'
|
661
|
+
|
662
|
+
@s.add_c_variables c_parser
|
663
|
+
|
567
664
|
@s.save_cache
|
568
665
|
|
569
666
|
assert_file File.join(@tmpdir, 'cache.ri')
|
570
667
|
|
668
|
+
c_class_variables = {
|
669
|
+
'ext.c' => {
|
670
|
+
'cSomeExt' => 'SomeExt'
|
671
|
+
}
|
672
|
+
}
|
673
|
+
|
674
|
+
c_singleton_class_variables = {
|
675
|
+
'ext.c' => {
|
676
|
+
's_cSomeExt' => 'SomeExtSingle'
|
677
|
+
}
|
678
|
+
}
|
679
|
+
|
571
680
|
expected = {
|
572
681
|
:ancestors => {
|
573
682
|
'Object::SubClass' => %w[Incl Object],
|
574
683
|
},
|
575
684
|
:attributes => { 'Object' => ['attr_accessor attr'] },
|
576
685
|
:class_methods => { 'Object' => %w[cmethod] },
|
686
|
+
:c_class_variables => c_class_variables,
|
687
|
+
:c_singleton_class_variables => c_singleton_class_variables,
|
577
688
|
:instance_methods => {
|
578
689
|
'Object' => %w[method method! method_bang],
|
579
690
|
'Object::SubClass' => %w[method],
|
@@ -708,7 +819,7 @@ class TestRDocStore < XrefTestCase
|
|
708
819
|
|
709
820
|
document = @RM::Document.new inner
|
710
821
|
|
711
|
-
assert_equal document, s.load_class('Object').
|
822
|
+
assert_equal document, s.load_class('Object').comment_location
|
712
823
|
end
|
713
824
|
|
714
825
|
# This is a functional test
|