rdoc 3.6.1 → 3.7
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/History.txt +45 -0
- data/Manifest.txt +4 -0
- data/lib/rdoc.rb +3 -2
- data/lib/rdoc/any_method.rb +12 -7
- data/lib/rdoc/attr.rb +16 -1
- data/lib/rdoc/class_module.rb +156 -42
- data/lib/rdoc/code_object.rb +8 -1
- data/lib/rdoc/context.rb +75 -29
- data/lib/rdoc/generator/markup.rb +3 -1
- data/lib/rdoc/generator/ri.rb +3 -2
- data/lib/rdoc/generator/template/darkfish/rdoc.css +4 -0
- data/lib/rdoc/known_classes.rb +2 -2
- data/lib/rdoc/markup.rb +63 -18
- data/lib/rdoc/markup/document.rb +43 -4
- data/lib/rdoc/markup/formatter.rb +13 -3
- data/lib/rdoc/markup/formatter_test_case.rb +13 -3
- data/lib/rdoc/markup/indented_paragraph.rb +33 -0
- data/lib/rdoc/markup/inline.rb +8 -1
- data/lib/rdoc/markup/parser.rb +1 -0
- data/lib/rdoc/markup/pre_process.rb +7 -0
- data/lib/rdoc/markup/to_ansi.rb +4 -4
- data/lib/rdoc/markup/to_bs.rb +1 -1
- data/lib/rdoc/markup/to_html.rb +2 -2
- data/lib/rdoc/markup/to_html_crossref.rb +3 -2
- data/lib/rdoc/markup/to_rdoc.rb +10 -1
- data/lib/rdoc/markup/to_test.rb +1 -1
- data/lib/rdoc/markup/to_tt_only.rb +1 -1
- data/lib/rdoc/parser.rb +1 -1
- data/lib/rdoc/parser/c.rb +69 -26
- data/lib/rdoc/parser/ruby.rb +19 -9
- data/lib/rdoc/rdoc.rb +14 -3
- data/lib/rdoc/ri/driver.rb +137 -103
- data/lib/rdoc/ri/store.rb +111 -26
- data/lib/rdoc/ruby_lex.rb +1 -1
- data/lib/rdoc/rubygems_hook.rb +220 -0
- data/lib/rdoc/text.rb +1 -1
- data/lib/rdoc/top_level.rb +31 -0
- data/test/test_rdoc_any_method.rb +68 -0
- data/test/test_rdoc_attr.rb +62 -0
- data/test/test_rdoc_class_module.rb +459 -29
- data/test/test_rdoc_code_object.rb +17 -0
- data/test/test_rdoc_context.rb +70 -0
- data/test/test_rdoc_context_section.rb +1 -1
- data/test/test_rdoc_generator_ri.rb +14 -3
- data/test/test_rdoc_markup.rb +55 -1
- data/test/test_rdoc_markup_document.rb +83 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +40 -0
- data/test/test_rdoc_markup_paragraph.rb +12 -0
- data/test/test_rdoc_markup_pre_process.rb +13 -2
- data/test/test_rdoc_markup_to_ansi.rb +4 -0
- data/test/test_rdoc_markup_to_bs.rb +4 -0
- data/test/test_rdoc_markup_to_html.rb +7 -3
- data/test/test_rdoc_markup_to_rdoc.rb +14 -0
- data/test/test_rdoc_markup_to_tt_only.rb +4 -0
- data/test/test_rdoc_parser_c.rb +302 -2
- data/test/test_rdoc_parser_ruby.rb +48 -1
- data/test/test_rdoc_rdoc.rb +41 -10
- data/test/test_rdoc_ri_driver.rb +40 -7
- data/test/test_rdoc_ri_store.rb +111 -23
- data/test/test_rdoc_rubygems_hook.rb +201 -0
- data/test/test_rdoc_stats.rb +12 -12
- data/test/test_rdoc_text.rb +17 -0
- data/test/test_rdoc_top_level.rb +35 -0
- metadata +18 -14
- metadata.gz.sig +0 -0
data/lib/rdoc/ruby_lex.rb
CHANGED
@@ -0,0 +1,220 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/user_interaction'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'rdoc'
|
5
|
+
|
6
|
+
##
|
7
|
+
# Gem::RDoc provides methods to generate RDoc and ri data for installed gems
|
8
|
+
# upon gem installation.
|
9
|
+
#
|
10
|
+
# This file is automatically required by RubyGems 1.9 and newer.
|
11
|
+
|
12
|
+
class RDoc::RubygemsHook
|
13
|
+
|
14
|
+
include Gem::UserInteraction
|
15
|
+
|
16
|
+
@rdoc_version = nil
|
17
|
+
@specs = []
|
18
|
+
|
19
|
+
##
|
20
|
+
# Force installation of documentation?
|
21
|
+
|
22
|
+
attr_accessor :force
|
23
|
+
|
24
|
+
##
|
25
|
+
# Generate rdoc?
|
26
|
+
|
27
|
+
attr_accessor :generate_rdoc
|
28
|
+
|
29
|
+
##
|
30
|
+
# Generate ri data?
|
31
|
+
|
32
|
+
attr_accessor :generate_ri
|
33
|
+
|
34
|
+
class << self
|
35
|
+
|
36
|
+
##
|
37
|
+
# Loaded version of RDoc. Set by ::load_rdoc
|
38
|
+
|
39
|
+
attr_reader :rdoc_version
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Post installs hook that generates documentation for each specification in
|
45
|
+
# +specs+
|
46
|
+
|
47
|
+
def self.generation_hook installer, specs
|
48
|
+
types = installer.document
|
49
|
+
|
50
|
+
generate_rdoc = types.include? 'rdoc'
|
51
|
+
generate_ri = types.include? 'ri'
|
52
|
+
|
53
|
+
specs.each do |spec|
|
54
|
+
new(spec, generate_rdoc, generate_ri).generate
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Loads the RDoc generator
|
60
|
+
|
61
|
+
def self.load_rdoc
|
62
|
+
return if @rdoc_version
|
63
|
+
|
64
|
+
require 'rdoc/rdoc'
|
65
|
+
|
66
|
+
@rdoc_version = Gem::Version.new ::RDoc::VERSION
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Creates a new documentation generator for +spec+. RDoc and ri data
|
71
|
+
# generation can be disabled through +generate_rdoc+ and +generate_ri+
|
72
|
+
# respectively.
|
73
|
+
|
74
|
+
def initialize spec, generate_rdoc = true, generate_ri = true
|
75
|
+
@doc_dir = spec.doc_dir
|
76
|
+
@file_info = nil
|
77
|
+
@force = false
|
78
|
+
@rdoc = nil
|
79
|
+
@spec = spec
|
80
|
+
|
81
|
+
@generate_rdoc = generate_rdoc
|
82
|
+
@generate_ri = generate_ri
|
83
|
+
|
84
|
+
@rdoc_dir = spec.doc_dir 'rdoc'
|
85
|
+
@ri_dir = spec.doc_dir 'ri'
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Removes legacy rdoc arguments from +args+
|
90
|
+
#--
|
91
|
+
# TODO move to RDoc::Options
|
92
|
+
|
93
|
+
def delete_legacy_args args
|
94
|
+
args.delete '--inline-source'
|
95
|
+
args.delete '--promiscuous'
|
96
|
+
args.delete '-p'
|
97
|
+
args.delete '--one-file'
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Generates documentation using the named +generator+ ("darkfish" or "ri")
|
102
|
+
# and following the given +options+.
|
103
|
+
#
|
104
|
+
# Documentation will be generated into +destination+
|
105
|
+
|
106
|
+
def document generator, options, destination
|
107
|
+
options = options.dup
|
108
|
+
options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
|
109
|
+
options.setup_generator generator
|
110
|
+
options.op_dir = destination
|
111
|
+
options.finish
|
112
|
+
|
113
|
+
@rdoc.options = options
|
114
|
+
@rdoc.generator = options.generator.new options
|
115
|
+
|
116
|
+
say "Installing #{generator} documentation for #{@spec.full_name}"
|
117
|
+
|
118
|
+
FileUtils.mkdir_p options.op_dir
|
119
|
+
|
120
|
+
Dir.chdir options.op_dir do
|
121
|
+
begin
|
122
|
+
@rdoc.class.current = @rdoc
|
123
|
+
@rdoc.generator.generate @file_info
|
124
|
+
ensure
|
125
|
+
@rdoc.class.current = nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
##
|
131
|
+
# Generates RDoc and ri data
|
132
|
+
|
133
|
+
def generate
|
134
|
+
return unless @generate_ri or @generate_rdoc
|
135
|
+
|
136
|
+
setup
|
137
|
+
|
138
|
+
::RDoc::RDoc.reset
|
139
|
+
|
140
|
+
options = ::RDoc::Options.new
|
141
|
+
options.default_title = "#{@spec.full_name} Documentation"
|
142
|
+
options.files = []
|
143
|
+
options.files.push(*@spec.require_paths)
|
144
|
+
options.files.push(*@spec.extra_rdoc_files)
|
145
|
+
|
146
|
+
args = @spec.rdoc_options
|
147
|
+
|
148
|
+
case config_args = Gem.configuration[:rdoc]
|
149
|
+
when String then
|
150
|
+
args = args.concat config_args.split
|
151
|
+
when Array then
|
152
|
+
args = args.concat config_args
|
153
|
+
end
|
154
|
+
|
155
|
+
delete_legacy_args args
|
156
|
+
options.parse args
|
157
|
+
options.quiet = !Gem.configuration.really_verbose
|
158
|
+
|
159
|
+
@rdoc = new_rdoc
|
160
|
+
@rdoc.options = options
|
161
|
+
|
162
|
+
Dir.chdir @spec.full_gem_path do
|
163
|
+
@file_info = @rdoc.parse_files options.files
|
164
|
+
end
|
165
|
+
|
166
|
+
document 'ri', options, @ri_dir if
|
167
|
+
@generate_ri and (@force or not File.exist? @ri_dir)
|
168
|
+
|
169
|
+
document 'darkfish', options, @rdoc_dir if
|
170
|
+
@generate_rdoc and (@force or not File.exist? @rdoc_dir)
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# #new_rdoc creates a new RDoc instance. This method is provided only to
|
175
|
+
# make testing easier.
|
176
|
+
|
177
|
+
def new_rdoc # :nodoc:
|
178
|
+
::RDoc::RDoc.new
|
179
|
+
end
|
180
|
+
|
181
|
+
##
|
182
|
+
# Is rdoc documentation installed?
|
183
|
+
|
184
|
+
def rdoc_installed?
|
185
|
+
File.exist? @rdoc_dir
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# Removes generated RDoc and ri data
|
190
|
+
|
191
|
+
def remove
|
192
|
+
base_dir = @spec.base_dir
|
193
|
+
|
194
|
+
raise Gem::FilePermissionError, base_dir unless File.writable? base_dir
|
195
|
+
|
196
|
+
FileUtils.rm_rf @rdoc_dir
|
197
|
+
FileUtils.rm_rf @ri_dir
|
198
|
+
end
|
199
|
+
|
200
|
+
##
|
201
|
+
# Is ri data installed?
|
202
|
+
|
203
|
+
def ri_installed?
|
204
|
+
File.exist? @ri_dir
|
205
|
+
end
|
206
|
+
|
207
|
+
##
|
208
|
+
# Prepares the spec for documentation generation
|
209
|
+
|
210
|
+
def setup
|
211
|
+
self.class.load_rdoc
|
212
|
+
|
213
|
+
raise Gem::FilePermissionError, @doc_dir if
|
214
|
+
File.exist?(@doc_dir) and not File.writable?(@doc_dir)
|
215
|
+
|
216
|
+
FileUtils.mkdir_p @doc_dir unless File.exist? @doc_dir
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
|
data/lib/rdoc/text.rb
CHANGED
@@ -157,7 +157,7 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
|
|
157
157
|
def strip_stars text
|
158
158
|
encoding = text.encoding if Object.const_defined? :Encoding
|
159
159
|
|
160
|
-
text = text.gsub %r%Document-method:\s+[\w
|
160
|
+
text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, ''
|
161
161
|
|
162
162
|
space = ' '
|
163
163
|
space.force_encoding encoding if encoding
|
data/lib/rdoc/top_level.rb
CHANGED
@@ -219,6 +219,20 @@ class RDoc::TopLevel < RDoc::Context
|
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
|
+
##
|
223
|
+
# Creates a new RDoc::TopLevel with +file_name+ only if one with the same
|
224
|
+
# name does not exist in all_files.
|
225
|
+
|
226
|
+
def self.new file_name
|
227
|
+
if top_level = @all_files_hash[file_name] then
|
228
|
+
top_level
|
229
|
+
else
|
230
|
+
top_level = super
|
231
|
+
@all_files_hash[file_name] = top_level
|
232
|
+
top_level
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
222
236
|
##
|
223
237
|
# Removes from +all_hash+ the contexts that are nodoc or have no content.
|
224
238
|
#
|
@@ -295,6 +309,15 @@ class RDoc::TopLevel < RDoc::Context
|
|
295
309
|
RDoc::TopLevel.files_hash[file_name] = self
|
296
310
|
end
|
297
311
|
|
312
|
+
##
|
313
|
+
# An RDoc::TopLevel is equal to another with the same absolute_name
|
314
|
+
|
315
|
+
def == other
|
316
|
+
other.class === self and @absolute_name == other.absolute_name
|
317
|
+
end
|
318
|
+
|
319
|
+
alias eql? ==
|
320
|
+
|
298
321
|
##
|
299
322
|
# Adds +an_alias+ to +Object+ instead of +self+.
|
300
323
|
|
@@ -375,6 +398,14 @@ class RDoc::TopLevel < RDoc::Context
|
|
375
398
|
@relative_name
|
376
399
|
end
|
377
400
|
|
401
|
+
##
|
402
|
+
# An RDoc::TopLevel has the same hash as another with the same
|
403
|
+
# absolute_name
|
404
|
+
|
405
|
+
def hash
|
406
|
+
@absolute_name.hash
|
407
|
+
end
|
408
|
+
|
378
409
|
##
|
379
410
|
# URL for this with a +prefix+
|
380
411
|
|
@@ -83,6 +83,40 @@ method(a, b) { |c, d| ... }
|
|
83
83
|
assert_equal '', @c2_a.markup_code
|
84
84
|
end
|
85
85
|
|
86
|
+
def test_marshal_dump
|
87
|
+
top_level = RDoc::TopLevel.new 'file.rb'
|
88
|
+
m = RDoc::AnyMethod.new nil, 'method'
|
89
|
+
m.block_params = 'some_block'
|
90
|
+
m.call_seq = 'call_seq'
|
91
|
+
m.comment = 'this is a comment'
|
92
|
+
m.params = 'param'
|
93
|
+
m.record_location top_level
|
94
|
+
|
95
|
+
cm = RDoc::ClassModule.new 'Klass'
|
96
|
+
cm.add_method m
|
97
|
+
|
98
|
+
al = RDoc::Alias.new nil, 'method', 'aliased', 'alias comment'
|
99
|
+
al_m = m.add_alias al, cm
|
100
|
+
|
101
|
+
loaded = Marshal.load Marshal.dump m
|
102
|
+
|
103
|
+
comment = RDoc::Markup::Document.new(
|
104
|
+
RDoc::Markup::Paragraph.new('this is a comment'))
|
105
|
+
|
106
|
+
assert_equal m, loaded
|
107
|
+
|
108
|
+
assert_equal [al_m], loaded.aliases
|
109
|
+
assert_equal 'some_block', loaded.block_params
|
110
|
+
assert_equal 'call_seq', loaded.call_seq
|
111
|
+
assert_equal comment, loaded.comment
|
112
|
+
assert_equal top_level, loaded.file
|
113
|
+
assert_equal 'Klass#method', loaded.full_name
|
114
|
+
assert_equal 'method', loaded.name
|
115
|
+
assert_equal 'param', loaded.params
|
116
|
+
assert_equal nil, loaded.singleton # defaults to nil
|
117
|
+
assert_equal :public, loaded.visibility
|
118
|
+
end
|
119
|
+
|
86
120
|
def test_marshal_load
|
87
121
|
instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
|
88
122
|
|
@@ -103,6 +137,40 @@ method(a, b) { |c, d| ... }
|
|
103
137
|
assert_equal '()', class_method.params
|
104
138
|
end
|
105
139
|
|
140
|
+
def test_marshal_load_version_0
|
141
|
+
m = RDoc::AnyMethod.new nil, 'method'
|
142
|
+
cm = RDoc::ClassModule.new 'Klass'
|
143
|
+
cm.add_method m
|
144
|
+
al = RDoc::Alias.new nil, 'method', 'aliased', 'alias comment'
|
145
|
+
al_m = m.add_alias al, cm
|
146
|
+
|
147
|
+
loaded = Marshal.load "\x04\bU:\x14RDoc::AnyMethod[\x0Fi\x00I" \
|
148
|
+
"\"\vmethod\x06:\x06EF\"\x11Klass#method0:\vpublic" \
|
149
|
+
"o:\eRDoc::Markup::Document\x06:\v@parts[\x06" \
|
150
|
+
"o:\x1CRDoc::Markup::Paragraph\x06;\t[\x06I" \
|
151
|
+
"\"\x16this is a comment\x06;\x06FI" \
|
152
|
+
"\"\rcall_seq\x06;\x06FI\"\x0Fsome_block\x06;\x06F" \
|
153
|
+
"[\x06[\aI\"\faliased\x06;\x06Fo;\b\x06;\t[\x06" \
|
154
|
+
"o;\n\x06;\t[\x06I\"\x12alias comment\x06;\x06FI" \
|
155
|
+
"\"\nparam\x06;\x06F"
|
156
|
+
|
157
|
+
comment = RDoc::Markup::Document.new(
|
158
|
+
RDoc::Markup::Paragraph.new('this is a comment'))
|
159
|
+
|
160
|
+
assert_equal m, loaded
|
161
|
+
|
162
|
+
assert_equal [al_m], loaded.aliases
|
163
|
+
assert_equal 'some_block', loaded.block_params
|
164
|
+
assert_equal 'call_seq', loaded.call_seq
|
165
|
+
assert_equal comment, loaded.comment
|
166
|
+
assert_equal 'Klass#method', loaded.full_name
|
167
|
+
assert_equal 'method', loaded.name
|
168
|
+
assert_equal 'param', loaded.params
|
169
|
+
assert_equal nil, loaded.singleton # defaults to nil
|
170
|
+
assert_equal :public, loaded.visibility
|
171
|
+
assert_equal nil, loaded.file
|
172
|
+
end
|
173
|
+
|
106
174
|
def test_name
|
107
175
|
m = RDoc::AnyMethod.new nil, nil
|
108
176
|
|
data/test/test_rdoc_attr.rb
CHANGED
@@ -42,6 +42,68 @@ class TestRDocAttr < MiniTest::Unit::TestCase
|
|
42
42
|
assert_equal '(unknown)#attr', @a.full_name
|
43
43
|
end
|
44
44
|
|
45
|
+
def test_marshal_dump
|
46
|
+
tl = RDoc::TopLevel.new 'file.rb'
|
47
|
+
|
48
|
+
@a.comment = 'this is a comment'
|
49
|
+
@a.record_location tl
|
50
|
+
|
51
|
+
cm = RDoc::ClassModule.new 'Klass'
|
52
|
+
cm.add_attribute @a
|
53
|
+
|
54
|
+
loaded = Marshal.load Marshal.dump @a
|
55
|
+
|
56
|
+
assert_equal @a, loaded
|
57
|
+
|
58
|
+
comment = RDoc::Markup::Document.new(
|
59
|
+
RDoc::Markup::Paragraph.new('this is a comment'))
|
60
|
+
|
61
|
+
assert_equal comment, loaded.comment
|
62
|
+
assert_equal 'file.rb', loaded.file.relative_name
|
63
|
+
assert_equal 'Klass#attr', loaded.full_name
|
64
|
+
assert_equal 'attr', loaded.name
|
65
|
+
assert_equal 'RW', loaded.rw
|
66
|
+
assert_equal false, loaded.singleton
|
67
|
+
assert_equal :public, loaded.visibility
|
68
|
+
|
69
|
+
@a.rw = 'R'
|
70
|
+
@a.singleton = true
|
71
|
+
@a.visibility = :protected
|
72
|
+
|
73
|
+
loaded = Marshal.load Marshal.dump @a
|
74
|
+
|
75
|
+
assert_equal @a, loaded
|
76
|
+
|
77
|
+
assert_equal comment, loaded.comment
|
78
|
+
assert_equal 'Klass::attr', loaded.full_name
|
79
|
+
assert_equal 'attr', loaded.name
|
80
|
+
assert_equal 'R', loaded.rw
|
81
|
+
assert_equal true, loaded.singleton
|
82
|
+
assert_equal :protected, loaded.visibility
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_marshal_load_version_1
|
86
|
+
data = "\x04\bU:\x0FRDoc::Attr[\fi\x06I\"\tattr\x06:\x06EF" \
|
87
|
+
"\"\x0FKlass#attrI\"\aRW\x06;\x06F:\vpublic" \
|
88
|
+
"o:\eRDoc::Markup::Document\x06:\v@parts[\x06" \
|
89
|
+
"o:\x1CRDoc::Markup::Paragraph\x06;\t[\x06I" \
|
90
|
+
"\"\x16this is a comment\x06;\x06FF"
|
91
|
+
|
92
|
+
loaded = Marshal.load data
|
93
|
+
|
94
|
+
comment = RDoc::Markup::Document.new(
|
95
|
+
RDoc::Markup::Paragraph.new('this is a comment'))
|
96
|
+
|
97
|
+
assert_equal comment, loaded.comment
|
98
|
+
assert_equal 'Klass#attr', loaded.full_name
|
99
|
+
assert_equal 'attr', loaded.name
|
100
|
+
assert_equal 'RW', loaded.rw
|
101
|
+
assert_equal false, loaded.singleton
|
102
|
+
assert_equal :public, loaded.visibility
|
103
|
+
|
104
|
+
assert_equal nil, loaded.file # version 2
|
105
|
+
end
|
106
|
+
|
45
107
|
def test_params
|
46
108
|
assert_nil @a.params
|
47
109
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pp'
|
1
2
|
require File.expand_path '../xref_test_case', __FILE__
|
2
3
|
|
3
4
|
class TestRDocClassModule < XrefTestCase
|
@@ -8,6 +9,37 @@ class TestRDocClassModule < XrefTestCase
|
|
8
9
|
@RM = RDoc::Markup
|
9
10
|
end
|
10
11
|
|
12
|
+
def mu_pp obj
|
13
|
+
s = ''
|
14
|
+
s = PP.pp obj, s
|
15
|
+
s.force_encoding Encoding.default_external if defined? Encoding
|
16
|
+
s.chomp
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_add_comment
|
20
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
21
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
22
|
+
tl3 = RDoc::TopLevel.new 'three.rb'
|
23
|
+
|
24
|
+
cm = RDoc::ClassModule.new 'Klass'
|
25
|
+
cm.add_comment '# comment 1', tl1
|
26
|
+
|
27
|
+
assert_equal [['comment 1', tl1]], cm.comment_location
|
28
|
+
assert_equal 'comment 1', cm.comment
|
29
|
+
|
30
|
+
cm.add_comment '# comment 2', tl2
|
31
|
+
|
32
|
+
assert_equal [['comment 1', tl1], ['comment 2', tl2]], cm.comment_location
|
33
|
+
assert_equal "comment 1\n---\ncomment 2", cm.comment
|
34
|
+
|
35
|
+
cm.add_comment "# * comment 3", tl3
|
36
|
+
|
37
|
+
assert_equal [['comment 1', tl1],
|
38
|
+
['comment 2', tl2],
|
39
|
+
['* comment 3', tl3]], cm.comment_location
|
40
|
+
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
|
41
|
+
end
|
42
|
+
|
11
43
|
def test_ancestors
|
12
44
|
assert_equal [@parent], @child.ancestors
|
13
45
|
end
|
@@ -45,70 +77,468 @@ class TestRDocClassModule < XrefTestCase
|
|
45
77
|
assert_nil @c2.find_class_named('C1')
|
46
78
|
end
|
47
79
|
|
48
|
-
def
|
80
|
+
def test_from_module_comment
|
81
|
+
tl = RDoc::TopLevel.new 'file.rb'
|
82
|
+
klass = tl.add_class RDoc::NormalModule, 'Klass'
|
83
|
+
klass.add_comment 'really a class', tl
|
84
|
+
|
85
|
+
klass = RDoc::ClassModule.from_module RDoc::NormalClass, klass
|
86
|
+
|
87
|
+
assert_equal [['really a class', tl]], klass.comment_location
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_marshal_dump
|
91
|
+
tl = RDoc::TopLevel.new 'file.rb'
|
92
|
+
|
93
|
+
ns = tl.add_module RDoc::NormalModule, 'Namespace'
|
94
|
+
|
95
|
+
cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
|
96
|
+
cm.record_location tl
|
97
|
+
|
98
|
+
a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
|
99
|
+
a1.record_location tl
|
100
|
+
a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
|
101
|
+
a2.record_location tl
|
102
|
+
|
103
|
+
m1 = RDoc::AnyMethod.new nil, 'm1'
|
104
|
+
m1.record_location tl
|
105
|
+
|
106
|
+
c1 = RDoc::Constant.new 'C1', nil, ''
|
107
|
+
c1.record_location tl
|
108
|
+
|
109
|
+
i1 = RDoc::Include.new 'I1', ''
|
110
|
+
i1.record_location tl
|
111
|
+
|
112
|
+
cm.add_attribute a1
|
113
|
+
cm.add_attribute a2
|
114
|
+
cm.add_method m1
|
115
|
+
cm.add_constant c1
|
116
|
+
cm.add_include i1
|
117
|
+
cm.add_comment 'this is a comment', tl
|
118
|
+
|
119
|
+
loaded = Marshal.load Marshal.dump cm
|
120
|
+
|
121
|
+
assert_equal cm, loaded
|
122
|
+
|
123
|
+
inner = RDoc::Markup::Document.new(
|
124
|
+
RDoc::Markup::Paragraph.new('this is a comment'))
|
125
|
+
inner.file = tl.absolute_name
|
126
|
+
|
127
|
+
comment = RDoc::Markup::Document.new inner
|
128
|
+
|
129
|
+
assert_equal [a2, a1], loaded.attributes.sort
|
130
|
+
assert_equal comment, loaded.comment
|
131
|
+
assert_equal [c1], loaded.constants
|
132
|
+
assert_equal 'Namespace::Klass', loaded.full_name
|
133
|
+
assert_equal [i1], loaded.includes
|
134
|
+
assert_equal [m1], loaded.method_list
|
135
|
+
assert_equal 'Klass', loaded.name
|
136
|
+
assert_equal 'Super', loaded.superclass
|
137
|
+
|
138
|
+
assert_equal tl, loaded.attributes.first.file
|
139
|
+
|
140
|
+
assert_equal tl, loaded.constants.first.file
|
141
|
+
|
142
|
+
assert_equal tl, loaded.includes.first.file
|
143
|
+
|
144
|
+
assert_equal tl, loaded.method_list.first.file
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_marshal_load_version_0
|
148
|
+
tl = RDoc::TopLevel.new 'file.rb'
|
149
|
+
ns = tl.add_module RDoc::NormalModule, 'Namespace'
|
150
|
+
cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
|
151
|
+
|
152
|
+
a = RDoc::Attr.new(nil, 'a1', 'RW', '')
|
153
|
+
m = RDoc::AnyMethod.new(nil, 'm1')
|
154
|
+
c = RDoc::Constant.new('C1', nil, '')
|
155
|
+
i = RDoc::Include.new('I1', '')
|
156
|
+
|
157
|
+
cm.add_attribute a
|
158
|
+
cm.add_method m
|
159
|
+
cm.add_constant c
|
160
|
+
cm.add_include i
|
161
|
+
cm.add_comment 'this is a comment', tl
|
162
|
+
|
163
|
+
loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Ei\x00\"\nKlass" \
|
164
|
+
"\"\x15Namespace::KlassI\"\nSuper\x06:\x06EF" \
|
165
|
+
"o:\eRDoc::Markup::Document\x06:\v@parts[\x06" \
|
166
|
+
"o:\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" \
|
167
|
+
"\"\x16this is a comment\x06;\x06F[\x06[\aI" \
|
168
|
+
"\"\aa1\x06;\x06FI\"\aRW\x06;\x06F[\x06[\aI" \
|
169
|
+
"\"\aC1\x06;\x06Fo;\a\x06;\b[\x00[\x06[\aI" \
|
170
|
+
"\"\aI1\x06;\x06Fo;\a\x06;\b[\x00[\a[\aI" \
|
171
|
+
"\"\nclass\x06;\x06F[\b[\a:\vpublic[\x00[\a" \
|
172
|
+
":\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" \
|
173
|
+
"\"\rinstance\x06;\x06F[\b[\a;\n[\x06I" \
|
174
|
+
"\"\am1\x06;\x06F[\a;\v[\x00[\a;\f[\x00"
|
175
|
+
|
176
|
+
assert_equal cm, loaded
|
177
|
+
|
178
|
+
comment = RDoc::Markup::Document.new(
|
179
|
+
RDoc::Markup::Paragraph.new('this is a comment'))
|
180
|
+
|
181
|
+
assert_equal [a], loaded.attributes
|
182
|
+
assert_equal comment, loaded.comment
|
183
|
+
assert_equal [c], loaded.constants
|
184
|
+
assert_equal 'Namespace::Klass', loaded.full_name
|
185
|
+
assert_equal [i], loaded.includes
|
186
|
+
assert_equal [m], loaded.method_list
|
187
|
+
assert_equal 'Klass', loaded.name
|
188
|
+
assert_equal 'Super', loaded.superclass
|
189
|
+
assert_equal nil, loaded.file
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_merge_attributes
|
193
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
194
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
195
|
+
|
49
196
|
cm1 = RDoc::ClassModule.new 'Klass'
|
50
|
-
|
51
|
-
cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
|
52
|
-
|
53
|
-
cm1.add_attribute RDoc::Attr.new(nil, '
|
54
|
-
|
55
|
-
cm1.
|
56
|
-
|
197
|
+
|
198
|
+
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
|
199
|
+
attr.record_location tl1
|
200
|
+
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a3', 'R', '')
|
201
|
+
attr.record_location tl1
|
202
|
+
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a4', 'R', '')
|
203
|
+
attr.record_location tl1
|
57
204
|
|
58
205
|
cm2 = RDoc::ClassModule.new 'Klass'
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
|
63
|
-
|
64
|
-
cm2.add_attribute RDoc::Attr.new(nil, '
|
65
|
-
|
66
|
-
cm2.
|
67
|
-
|
206
|
+
# TODO allow merging when comment == ''
|
207
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
208
|
+
|
209
|
+
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
|
210
|
+
attr.record_location tl2
|
211
|
+
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a3', 'W', '')
|
212
|
+
attr.record_location tl1
|
213
|
+
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a4', 'W', '')
|
214
|
+
attr.record_location tl1
|
68
215
|
|
69
216
|
cm1.merge cm2
|
70
217
|
|
71
|
-
|
72
|
-
|
73
|
-
|
218
|
+
expected = [
|
219
|
+
RDoc::Attr.new(nil, 'a2', 'RW', ''),
|
220
|
+
RDoc::Attr.new(nil, 'a3', 'W', ''),
|
221
|
+
RDoc::Attr.new(nil, 'a4', 'W', ''),
|
222
|
+
]
|
223
|
+
|
224
|
+
expected.each do |a| a.parent = cm1 end
|
225
|
+
assert_equal expected, cm1.attributes.sort
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_merge_attributes_version_0
|
229
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
230
|
+
|
231
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
232
|
+
|
233
|
+
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
|
234
|
+
attr.record_location tl1
|
235
|
+
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a3', 'R', '')
|
236
|
+
attr.record_location tl1
|
237
|
+
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a4', 'R', '')
|
238
|
+
attr.record_location tl1
|
239
|
+
|
240
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
241
|
+
# TODO allow merging when comment == ''
|
242
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
243
|
+
|
244
|
+
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
|
245
|
+
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a3', 'W', '')
|
246
|
+
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a4', 'W', '')
|
74
247
|
|
75
|
-
|
248
|
+
cm1.merge cm2
|
76
249
|
|
77
250
|
expected = [
|
78
251
|
RDoc::Attr.new(nil, 'a1', 'RW', ''),
|
79
252
|
RDoc::Attr.new(nil, 'a2', 'RW', ''),
|
80
253
|
RDoc::Attr.new(nil, 'a3', 'RW', ''),
|
81
|
-
RDoc::Attr.new(nil, 'a4', '
|
254
|
+
RDoc::Attr.new(nil, 'a4', 'RW', ''),
|
82
255
|
]
|
83
256
|
|
84
257
|
expected.each do |a| a.parent = cm1 end
|
85
258
|
assert_equal expected, cm1.attributes.sort
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_merge_comment
|
262
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
263
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
264
|
+
|
265
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
266
|
+
cm1.add_comment 'klass 1', tl1
|
267
|
+
|
268
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
269
|
+
cm2.add_comment 'klass 2', tl2
|
270
|
+
cm2.add_comment 'klass 3', tl1
|
271
|
+
|
272
|
+
cm2 = Marshal.load Marshal.dump cm2
|
273
|
+
|
274
|
+
cm1.merge cm2
|
275
|
+
|
276
|
+
inner1 = @RM::Document.new @RM::Paragraph.new 'klass 3'
|
277
|
+
inner1.file = 'one.rb'
|
278
|
+
inner2 = @RM::Document.new @RM::Paragraph.new 'klass 2'
|
279
|
+
inner2.file = 'two.rb'
|
280
|
+
|
281
|
+
expected = @RM::Document.new inner2, inner1
|
282
|
+
|
283
|
+
assert_equal expected, cm1.comment
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_merge_comment_version_0
|
287
|
+
tl = RDoc::TopLevel.new 'file.rb'
|
288
|
+
|
289
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
290
|
+
cm1.add_comment 'klass 1', tl
|
291
|
+
|
292
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
293
|
+
|
294
|
+
cm2.instance_variable_set(:@comment,
|
295
|
+
@RM::Document.new(
|
296
|
+
@RM::Paragraph.new('klass 2')))
|
297
|
+
cm2.instance_variable_set :@comment_location, @RM::Document.new(cm2.comment)
|
298
|
+
|
299
|
+
cm1.merge cm2
|
300
|
+
|
301
|
+
inner = @RM::Document.new @RM::Paragraph.new 'klass 1'
|
302
|
+
inner.file = 'file.rb'
|
303
|
+
|
304
|
+
expected = @RM::Document.new \
|
305
|
+
inner,
|
306
|
+
@RM::Document.new(@RM::Paragraph.new('klass 2'))
|
307
|
+
|
308
|
+
assert_equal expected, cm1.comment
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_merge_constants
|
312
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
313
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
314
|
+
|
315
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
316
|
+
|
317
|
+
const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
|
318
|
+
const.record_location tl1
|
319
|
+
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
|
320
|
+
const.record_location tl1
|
321
|
+
|
322
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
323
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
324
|
+
|
325
|
+
const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
|
326
|
+
const.record_location tl2
|
327
|
+
const = cm2.add_constant RDoc::Constant.new('C3', nil, 'one')
|
328
|
+
const.record_location tl1
|
329
|
+
const = cm2.add_constant RDoc::Constant.new('C4', nil, 'one')
|
330
|
+
const.record_location tl1
|
331
|
+
|
332
|
+
cm1.merge cm2
|
333
|
+
|
334
|
+
expected = [
|
335
|
+
RDoc::Constant.new('C2', nil, 'two'),
|
336
|
+
RDoc::Constant.new('C3', nil, 'one'),
|
337
|
+
RDoc::Constant.new('C4', nil, 'one'),
|
338
|
+
]
|
339
|
+
|
340
|
+
expected.each do |a| a.parent = cm1 end
|
341
|
+
|
342
|
+
assert_equal expected, cm1.constants.sort
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_merge_constants_version_0
|
346
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
347
|
+
|
348
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
349
|
+
|
350
|
+
const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
|
351
|
+
const.record_location tl1
|
352
|
+
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
|
353
|
+
const.record_location tl1
|
354
|
+
|
355
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
356
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
357
|
+
|
358
|
+
const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
|
359
|
+
const = cm2.add_constant RDoc::Constant.new('C3', nil, 'two')
|
360
|
+
const = cm2.add_constant RDoc::Constant.new('C4', nil, 'two')
|
361
|
+
|
362
|
+
cm1.merge cm2
|
86
363
|
|
87
364
|
expected = [
|
88
|
-
RDoc::Constant.new('C1', nil, ''),
|
89
|
-
RDoc::Constant.new('C2', nil, ''),
|
365
|
+
RDoc::Constant.new('C1', nil, 'one'),
|
366
|
+
RDoc::Constant.new('C2', nil, 'two'),
|
367
|
+
RDoc::Constant.new('C3', nil, 'one'),
|
368
|
+
RDoc::Constant.new('C4', nil, 'two'),
|
90
369
|
]
|
91
370
|
|
92
|
-
expected.each do |
|
371
|
+
expected.each do |a| a.parent = cm1 end
|
372
|
+
|
93
373
|
assert_equal expected, cm1.constants.sort
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_merge_includes
|
377
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
378
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
379
|
+
|
380
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
381
|
+
|
382
|
+
incl = cm1.add_include RDoc::Include.new('I1', 'one')
|
383
|
+
incl.record_location tl1
|
384
|
+
incl = cm1.add_include RDoc::Include.new('I3', 'one')
|
385
|
+
incl.record_location tl1
|
386
|
+
|
387
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
388
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
389
|
+
|
390
|
+
incl = cm2.add_include RDoc::Include.new('I2', 'two')
|
391
|
+
incl.record_location tl2
|
392
|
+
incl = cm2.add_include RDoc::Include.new('I3', 'one')
|
393
|
+
incl.record_location tl1
|
394
|
+
incl = cm2.add_include RDoc::Include.new('I4', 'one')
|
395
|
+
incl.record_location tl1
|
396
|
+
|
397
|
+
cm1.merge cm2
|
398
|
+
|
399
|
+
expected = [
|
400
|
+
RDoc::Include.new('I2', 'two'),
|
401
|
+
RDoc::Include.new('I3', 'one'),
|
402
|
+
RDoc::Include.new('I4', 'one'),
|
403
|
+
]
|
404
|
+
|
405
|
+
expected.each do |a| a.parent = cm1 end
|
406
|
+
|
407
|
+
assert_equal expected, cm1.includes.sort
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_merge_includes_version_0
|
411
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
412
|
+
|
413
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
414
|
+
|
415
|
+
incl = cm1.add_include RDoc::Include.new('I1', 'one')
|
416
|
+
incl.record_location tl1
|
417
|
+
incl = cm1.add_include RDoc::Include.new('I3', 'one')
|
418
|
+
incl.record_location tl1
|
419
|
+
|
420
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
421
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
422
|
+
|
423
|
+
incl = cm2.add_include RDoc::Include.new('I2', 'two')
|
424
|
+
incl = cm2.add_include RDoc::Include.new('I3', 'two')
|
425
|
+
incl = cm2.add_include RDoc::Include.new('I4', 'two')
|
426
|
+
|
427
|
+
cm1.merge cm2
|
94
428
|
|
95
429
|
expected = [
|
96
|
-
RDoc::Include.new('I1', ''),
|
97
|
-
RDoc::Include.new('I2', ''),
|
430
|
+
RDoc::Include.new('I1', 'one'),
|
431
|
+
RDoc::Include.new('I2', 'two'),
|
432
|
+
RDoc::Include.new('I3', 'one'),
|
433
|
+
RDoc::Include.new('I4', 'two'),
|
98
434
|
]
|
99
435
|
|
100
|
-
expected.each do |
|
436
|
+
expected.each do |a| a.parent = cm1 end
|
437
|
+
|
101
438
|
assert_equal expected, cm1.includes.sort
|
439
|
+
end
|
440
|
+
|
441
|
+
def test_merge_methods
|
442
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
443
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
444
|
+
|
445
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
446
|
+
|
447
|
+
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
|
448
|
+
meth.record_location tl1
|
449
|
+
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm3')
|
450
|
+
meth.record_location tl1
|
451
|
+
|
452
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
453
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
454
|
+
|
455
|
+
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
|
456
|
+
meth.record_location tl2
|
457
|
+
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm3')
|
458
|
+
meth.record_location tl1
|
459
|
+
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm4')
|
460
|
+
meth.record_location tl1
|
461
|
+
|
462
|
+
cm1.merge cm2
|
463
|
+
|
464
|
+
expected = [
|
465
|
+
RDoc::AnyMethod.new(nil, 'm2'),
|
466
|
+
RDoc::AnyMethod.new(nil, 'm3'),
|
467
|
+
RDoc::AnyMethod.new(nil, 'm4'),
|
468
|
+
]
|
469
|
+
|
470
|
+
expected.each do |a| a.parent = cm1 end
|
471
|
+
|
472
|
+
assert_equal expected, cm1.method_list.sort
|
473
|
+
end
|
474
|
+
|
475
|
+
def test_merge_methods_version_0
|
476
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
477
|
+
|
478
|
+
cm1 = RDoc::ClassModule.new 'Klass'
|
479
|
+
|
480
|
+
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
|
481
|
+
meth.record_location tl1
|
482
|
+
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm3')
|
483
|
+
meth.record_location tl1
|
484
|
+
|
485
|
+
cm2 = RDoc::ClassModule.new 'Klass'
|
486
|
+
cm2.instance_variable_set :@comment, @RM::Document.new
|
487
|
+
|
488
|
+
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
|
489
|
+
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm3')
|
490
|
+
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm4')
|
491
|
+
|
492
|
+
cm1.merge cm2
|
102
493
|
|
103
494
|
expected = [
|
104
495
|
RDoc::AnyMethod.new(nil, 'm1'),
|
105
496
|
RDoc::AnyMethod.new(nil, 'm2'),
|
497
|
+
RDoc::AnyMethod.new(nil, 'm3'),
|
498
|
+
RDoc::AnyMethod.new(nil, 'm4'),
|
106
499
|
]
|
107
500
|
|
108
|
-
expected.each do |
|
501
|
+
expected.each do |a| a.parent = cm1 end
|
502
|
+
|
109
503
|
assert_equal expected, cm1.method_list.sort
|
110
504
|
end
|
111
505
|
|
506
|
+
def test_parse
|
507
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
508
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
509
|
+
|
510
|
+
cm = RDoc::ClassModule.new 'Klass'
|
511
|
+
cm.add_comment 'comment 1', tl1
|
512
|
+
cm.add_comment 'comment 2', tl2
|
513
|
+
|
514
|
+
doc1 = @RM::Document.new @RM::Paragraph.new 'comment 1'
|
515
|
+
doc1.file = tl1.absolute_name
|
516
|
+
doc2 = @RM::Document.new @RM::Paragraph.new 'comment 2'
|
517
|
+
doc2.file = tl2.absolute_name
|
518
|
+
|
519
|
+
expected = @RM::Document.new doc1, doc2
|
520
|
+
|
521
|
+
assert_equal expected, cm.parse(cm.comment_location)
|
522
|
+
end
|
523
|
+
|
524
|
+
def test_parse_comment_location
|
525
|
+
tl1 = RDoc::TopLevel.new 'one.rb'
|
526
|
+
tl2 = RDoc::TopLevel.new 'two.rb'
|
527
|
+
|
528
|
+
cm = RDoc::ClassModule.new 'Klass'
|
529
|
+
cm.add_comment 'comment 1', tl1
|
530
|
+
cm.add_comment 'comment 2', tl2
|
531
|
+
|
532
|
+
cm = Marshal.load Marshal.dump cm
|
533
|
+
|
534
|
+
doc1 = @RM::Document.new @RM::Paragraph.new 'comment 1'
|
535
|
+
doc1.file = tl1.absolute_name
|
536
|
+
doc2 = @RM::Document.new @RM::Paragraph.new 'comment 2'
|
537
|
+
doc2.file = tl2.absolute_name
|
538
|
+
|
539
|
+
assert_same cm.comment_location, cm.parse(cm.comment_location)
|
540
|
+
end
|
541
|
+
|
112
542
|
def test_remove_nodoc_children
|
113
543
|
parent = RDoc::ClassModule.new 'A'
|
114
544
|
parent.modules_hash.replace 'B' => true, 'C' => true
|