rdoc 2.5.9 → 2.5.10
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 +18 -0
- data/lib/rdoc.rb +1 -1
- data/lib/rdoc/alias.rb +10 -0
- data/lib/rdoc/attr.rb +9 -0
- data/lib/rdoc/context.rb +11 -4
- data/lib/rdoc/generator/darkfish.rb +1 -1
- data/lib/rdoc/markup/to_html_crossref.rb +8 -4
- data/lib/rdoc/parser.rb +11 -0
- data/lib/rdoc/parser/c.rb +41 -14
- data/lib/rdoc/parser/ruby.rb +5 -0
- data/lib/rdoc/rdoc.rb +1 -9
- data/test/test.ja.rdoc +2 -0
- data/test/test_rdoc_attr.rb +6 -0
- data/test/test_rdoc_context.rb +19 -0
- data/test/test_rdoc_markup_pre_process.rb +2 -2
- data/test/test_rdoc_markup_to_html_crossref.rb +7 -0
- data/test/test_rdoc_parser.rb +16 -0
- data/test/test_rdoc_parser_c.rb +158 -3
- data/test/test_rdoc_parser_ruby.rb +17 -0
- metadata +15 -31
- metadata.gz.sig +4 -2
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
=== 2.5.10 / 2010-08-17
|
2
|
+
|
3
|
+
* Minor Enhancements
|
4
|
+
* Support rb_singleton_class(). Reported by Jeremy Evans.
|
5
|
+
* Support rb_define_private_method() on rb_singleton_class(). Reported by
|
6
|
+
Jeremy Evans.
|
7
|
+
|
8
|
+
* Bug Fixes
|
9
|
+
* Treat non-ASCII RDoc files as text. Bug #28391 by Kouhei Sutou.
|
10
|
+
* Fix potential test failures due to ivar collision. Bug #28390 by Kouhei
|
11
|
+
Sutou.
|
12
|
+
* Added duck-typed #aref for RDoc::Attr to RDoc::AnyMethod. Bug #28375 by
|
13
|
+
Erik Hollensbe
|
14
|
+
* Fixed method references in HTML output when show_hash is false.
|
15
|
+
* Fixed comments with '.' in call-seq in C sources. Reported by Jeremy
|
16
|
+
Evans.
|
17
|
+
* RDoc now understands singleton aliases. Reported by Jeremy Evans.
|
18
|
+
|
1
19
|
=== 2.5.9 / 2010-07-06
|
2
20
|
|
3
21
|
* Bug Fixes
|
data/lib/rdoc.rb
CHANGED
data/lib/rdoc/alias.rb
CHANGED
@@ -3,6 +3,8 @@ require 'rdoc/code_object'
|
|
3
3
|
##
|
4
4
|
# Represent an alias, which is an old_name/new_name pair associated with a
|
5
5
|
# particular context
|
6
|
+
#
|
7
|
+
# TODO: RDoc::Alias needs to know if it's a singleton alias or not
|
6
8
|
|
7
9
|
class RDoc::Alias < RDoc::CodeObject
|
8
10
|
|
@@ -21,6 +23,11 @@ class RDoc::Alias < RDoc::CodeObject
|
|
21
23
|
|
22
24
|
attr_accessor :old_name
|
23
25
|
|
26
|
+
##
|
27
|
+
# Is this a singeton alias?
|
28
|
+
|
29
|
+
attr_accessor :singleton
|
30
|
+
|
24
31
|
##
|
25
32
|
# Source file token stream
|
26
33
|
|
@@ -32,10 +39,13 @@ class RDoc::Alias < RDoc::CodeObject
|
|
32
39
|
|
33
40
|
def initialize(text, old_name, new_name, comment)
|
34
41
|
super()
|
42
|
+
|
35
43
|
@text = text
|
36
44
|
@old_name = old_name
|
37
45
|
@new_name = new_name
|
38
46
|
self.comment = comment
|
47
|
+
|
48
|
+
@singleton = false
|
39
49
|
end
|
40
50
|
|
41
51
|
def inspect # :nodoc:
|
data/lib/rdoc/attr.rb
CHANGED
@@ -53,6 +53,15 @@ class RDoc::Attr < RDoc::CodeObject
|
|
53
53
|
self.rw == other.rw
|
54
54
|
end
|
55
55
|
|
56
|
+
##
|
57
|
+
# HTML fragment reference for this attr
|
58
|
+
|
59
|
+
def aref
|
60
|
+
type = singleton ? 'c' : 'i'
|
61
|
+
|
62
|
+
"attribute-#{type}-#{CGI.escape name}"
|
63
|
+
end
|
64
|
+
|
56
65
|
##
|
57
66
|
# Returns nil, for duck typing with RDoc::AnyMethod
|
58
67
|
|
data/lib/rdoc/context.rb
CHANGED
@@ -220,16 +220,23 @@ class RDoc::Context < RDoc::CodeObject
|
|
220
220
|
end
|
221
221
|
|
222
222
|
##
|
223
|
-
# Adds +an_alias+ that is automatically resolved
|
223
|
+
# Adds +an_alias+ that is automatically resolved to it's corresponding
|
224
|
+
# RDoc::AnyMethod object.
|
224
225
|
|
225
|
-
def add_alias
|
226
|
-
|
226
|
+
def add_alias an_alias
|
227
|
+
old_name = an_alias.old_name
|
228
|
+
|
229
|
+
meth = if an_alias.singleton then
|
230
|
+
find_class_method_named old_name
|
231
|
+
else
|
232
|
+
find_instance_method_named old_name
|
233
|
+
end
|
227
234
|
|
228
235
|
if meth then
|
229
236
|
add_alias_impl an_alias, meth
|
230
237
|
else
|
231
238
|
add_to @aliases, an_alias
|
232
|
-
unmatched_alias_list = @unmatched_alias_lists[
|
239
|
+
unmatched_alias_list = @unmatched_alias_lists[old_name] ||= []
|
233
240
|
unmatched_alias_list.push an_alias
|
234
241
|
end
|
235
242
|
|
@@ -151,7 +151,7 @@ class RDoc::Generator::Darkfish
|
|
151
151
|
|
152
152
|
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
|
153
153
|
next if File.directory? path
|
154
|
-
next if path =~
|
154
|
+
next if File.basename(path) =~ /^\./
|
155
155
|
|
156
156
|
dst = Pathname.new(path).relative_path_from @template_dir
|
157
157
|
|
@@ -70,6 +70,11 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
70
70
|
|
71
71
|
attr_accessor :context
|
72
72
|
|
73
|
+
##
|
74
|
+
# Should we show '#' characters on method references?
|
75
|
+
|
76
|
+
attr_accessor :show_hash
|
77
|
+
|
73
78
|
##
|
74
79
|
# Creates a new crossref resolver that generates links relative to +context+
|
75
80
|
# which lives at +from_path+ in the generated files. '#' characters on
|
@@ -98,16 +103,15 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
98
103
|
def handle_special_CROSSREF(special)
|
99
104
|
name = special.text
|
100
105
|
|
101
|
-
# This ensures that words
|
102
|
-
#
|
106
|
+
# This ensures that words consisting of only lowercase letters will not
|
107
|
+
# have cross-references generated (to suppress lots of erroneous
|
103
108
|
# cross-references to "new" in text, for instance)
|
104
109
|
return name if name =~ /\A[a-z]*\z/
|
105
110
|
|
106
111
|
return @seen[name] if @seen.include? name
|
107
|
-
|
108
112
|
lookup = name
|
109
113
|
|
110
|
-
name = name[
|
114
|
+
name = name[1..-1] unless @show_hash if name[0, 1] == '#'
|
111
115
|
|
112
116
|
# Find class, module, or method in class or module.
|
113
117
|
#
|
data/lib/rdoc/parser.rb
CHANGED
@@ -62,12 +62,23 @@ class RDoc::Parser
|
|
62
62
|
true
|
63
63
|
end
|
64
64
|
|
65
|
+
def self.set_encoding(string)
|
66
|
+
if defined? Encoding then
|
67
|
+
if /coding[=:]\s*([^\s;]+)/i =~ string[%r"\A(?:#!.*\n)?.*\n"]
|
68
|
+
if enc = ::Encoding.find($1)
|
69
|
+
string.force_encoding(enc)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
65
75
|
##
|
66
76
|
# Determines if the file is a "binary" file which basically means it has
|
67
77
|
# content that an RDoc parser shouldn't try to consume.
|
68
78
|
|
69
79
|
def self.binary?(file)
|
70
80
|
s = File.read(file, 1024) or return false
|
81
|
+
set_encoding(s)
|
71
82
|
|
72
83
|
if s[0, 2] == Marshal.dump('')[0, 2] then
|
73
84
|
true
|
data/lib/rdoc/parser/c.rb
CHANGED
@@ -120,18 +120,24 @@ class RDoc::Parser::C < RDoc::Parser
|
|
120
120
|
@known_classes = RDoc::KNOWN_CLASSES.dup
|
121
121
|
@content = handle_tab_width handle_ifdefs_in(@content)
|
122
122
|
@classes = Hash.new
|
123
|
+
@singleton_classes = Hash.new
|
123
124
|
@file_dir = File.dirname(@file_name)
|
124
125
|
end
|
125
126
|
|
126
127
|
def do_aliases
|
127
|
-
@content.scan(
|
128
|
-
|
128
|
+
@content.scan(/rb_define_alias\s*\(
|
129
|
+
\s*(\w+),
|
130
|
+
\s*"(.+?)",
|
131
|
+
\s*"(.+?)"
|
132
|
+
\s*\)/xm) do |var_name, new_name, old_name|
|
129
133
|
class_name = @known_classes[var_name] || var_name
|
130
|
-
class_obj = find_class
|
134
|
+
class_obj = find_class var_name, class_name
|
131
135
|
|
132
|
-
|
136
|
+
al = RDoc::Alias.new '', old_name, new_name, ''
|
137
|
+
al.singleton = @singleton_classes.key?(var_name)
|
133
138
|
|
134
|
-
|
139
|
+
class_obj.add_alias al
|
140
|
+
@stats.add_alias al
|
135
141
|
end
|
136
142
|
end
|
137
143
|
|
@@ -165,13 +171,20 @@ class RDoc::Parser::C < RDoc::Parser
|
|
165
171
|
end
|
166
172
|
|
167
173
|
@content.scan(/([\w\.]+)\s* = \s*rb_define_class_under\s*
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
174
|
+
\(
|
175
|
+
\s*(\w+),
|
176
|
+
\s*"(\w+)",
|
177
|
+
\s*([\w\*\s\(\)\.\->]+)\s* # for SWIG
|
178
|
+
\s*\)/mx) do |var_name, in_module, class_name, parent|
|
173
179
|
handle_class_module(var_name, "class", class_name, parent, in_module)
|
174
180
|
end
|
181
|
+
|
182
|
+
@content.scan(/([\w\.]+)\s* = \s*rb_singleton_class\s*
|
183
|
+
\(
|
184
|
+
\s*(\w+)
|
185
|
+
\s*\)/mx) do |sclass_var, class_var|
|
186
|
+
handle_singleton sclass_var, class_var
|
187
|
+
end
|
175
188
|
end
|
176
189
|
|
177
190
|
def do_constants
|
@@ -432,11 +445,12 @@ class RDoc::Parser::C < RDoc::Parser
|
|
432
445
|
|
433
446
|
def find_modifiers(comment, meth_obj)
|
434
447
|
if comment.sub!(/:nodoc:\s*^\s*\*?\s*$/m, '') or
|
435
|
-
comment.sub!(/\A\/\*\s*:nodoc:\s*\*\/\Z/, '')
|
448
|
+
comment.sub!(/\A\/\*\s*:nodoc:\s*\*\/\Z/, '') then
|
436
449
|
meth_obj.document_self = false
|
437
450
|
end
|
451
|
+
|
438
452
|
if comment.sub!(/call-seq:(.*?)^\s*\*?\s*$/m, '') or
|
439
|
-
comment.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '')
|
453
|
+
comment.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '') then
|
440
454
|
seq = $1
|
441
455
|
seq.gsub!(/^\s*\*\s*/, '')
|
442
456
|
meth_obj.call_seq = seq
|
@@ -592,8 +606,14 @@ class RDoc::Parser::C < RDoc::Parser
|
|
592
606
|
|
593
607
|
def handle_method(type, var_name, meth_name, meth_body, param_count,
|
594
608
|
source_file = nil)
|
609
|
+
singleton = false
|
595
610
|
class_name = @known_classes[var_name]
|
596
611
|
|
612
|
+
unless class_name then
|
613
|
+
class_name = @singleton_classes[var_name]
|
614
|
+
singleton = true if class_name
|
615
|
+
end
|
616
|
+
|
597
617
|
return unless class_name
|
598
618
|
|
599
619
|
class_obj = find_class var_name, class_name
|
@@ -601,11 +621,12 @@ class RDoc::Parser::C < RDoc::Parser
|
|
601
621
|
if class_obj then
|
602
622
|
if meth_name == "initialize" then
|
603
623
|
meth_name = "new"
|
604
|
-
|
624
|
+
singleton = true
|
605
625
|
end
|
606
626
|
|
607
627
|
meth_obj = RDoc::AnyMethod.new '', meth_name
|
608
|
-
meth_obj.singleton =
|
628
|
+
meth_obj.singleton =
|
629
|
+
singleton || %w[singleton_method module_function].include?(type)
|
609
630
|
|
610
631
|
p_count = Integer(param_count) rescue -1
|
611
632
|
|
@@ -637,6 +658,12 @@ class RDoc::Parser::C < RDoc::Parser
|
|
637
658
|
end
|
638
659
|
end
|
639
660
|
|
661
|
+
def handle_singleton sclass_var, class_var
|
662
|
+
class_name = @known_classes[class_var]
|
663
|
+
|
664
|
+
@singleton_classes[sclass_var] = class_name
|
665
|
+
end
|
666
|
+
|
640
667
|
def handle_tab_width(body)
|
641
668
|
if /\t/ =~ body
|
642
669
|
tab_width = @options.tab_width
|
data/lib/rdoc/parser/ruby.rb
CHANGED
@@ -498,8 +498,13 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
498
498
|
end
|
499
499
|
|
500
500
|
al = RDoc::Alias.new get_tkread, old_name, new_name, comment
|
501
|
+
al.singleton = SINGLE == single
|
501
502
|
read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
|
503
|
+
|
502
504
|
context.add_alias al if al.document_self
|
505
|
+
@stats.add_alias al
|
506
|
+
|
507
|
+
al
|
503
508
|
end
|
504
509
|
|
505
510
|
def parse_call_parameters(tk)
|
data/lib/rdoc/rdoc.rb
CHANGED
@@ -405,15 +405,7 @@ The internal error was:
|
|
405
405
|
|
406
406
|
def read_file_contents(filename)
|
407
407
|
content = open filename, "rb" do |f| f.read end
|
408
|
-
|
409
|
-
if defined? Encoding then
|
410
|
-
if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"]
|
411
|
-
if enc = ::Encoding.find($1)
|
412
|
-
content.force_encoding(enc)
|
413
|
-
end
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
408
|
+
RDoc::Parser.set_encoding(content)
|
417
409
|
content
|
418
410
|
rescue Errno::EISDIR, Errno::ENOENT
|
419
411
|
nil
|
data/test/test.ja.rdoc
CHANGED
data/test/test_rdoc_attr.rb
CHANGED
@@ -8,6 +8,12 @@ class TestRDocAttr < MiniTest::Unit::TestCase
|
|
8
8
|
@a = RDoc::Attr.new nil, 'attr', 'RW', ''
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_aref
|
12
|
+
m = RDoc::Attr.new nil, 'attr', 'RW', nil
|
13
|
+
|
14
|
+
assert_equal 'attribute-i-attr', m.aref
|
15
|
+
end
|
16
|
+
|
11
17
|
def test_arglists
|
12
18
|
assert_nil @a.arglists
|
13
19
|
end
|
data/test/test_rdoc_context.rb
CHANGED
@@ -51,6 +51,25 @@ 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_method_singleton
|
55
|
+
meth = RDoc::AnyMethod.new nil, 'old_name'
|
56
|
+
meth.singleton = true
|
57
|
+
|
58
|
+
as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
|
59
|
+
as.singleton = true
|
60
|
+
|
61
|
+
as.parent = @context
|
62
|
+
|
63
|
+
@context.add_method meth
|
64
|
+
@context.add_alias as
|
65
|
+
|
66
|
+
assert_empty @context.aliases
|
67
|
+
assert_empty @context.unmatched_alias_lists
|
68
|
+
assert_equal %w[old_name new_name], @context.method_list.map { |m| m.name }
|
69
|
+
|
70
|
+
assert @context.method_list.last.singleton
|
71
|
+
end
|
72
|
+
|
54
73
|
def test_add_alias_impl
|
55
74
|
meth = RDoc::AnyMethod.new nil, 'old_name'
|
56
75
|
meth.comment = 'old comment'
|
@@ -10,7 +10,7 @@ class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase
|
|
10
10
|
RDoc::Markup::PreProcess.registered.clear
|
11
11
|
|
12
12
|
@tempfile = Tempfile.new 'test_rdoc_markup_pre_process'
|
13
|
-
@
|
13
|
+
@file_name = File.basename @tempfile.path
|
14
14
|
@dir = File.dirname @tempfile.path
|
15
15
|
|
16
16
|
@pp = RDoc::Markup::PreProcess.new __FILE__, [@dir]
|
@@ -31,7 +31,7 @@ contents of a string.
|
|
31
31
|
@tempfile.flush
|
32
32
|
@tempfile.rewind
|
33
33
|
|
34
|
-
content = @pp.include_file @
|
34
|
+
content = @pp.include_file @file_name, ''
|
35
35
|
|
36
36
|
expected = <<-EXPECTED
|
37
37
|
Regular expressions (<i>regexp</i>s) are patterns which describe the
|
@@ -153,6 +153,13 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|
153
153
|
refute_ref '::C3::H1#n', '\::C3::H1#n'
|
154
154
|
end
|
155
155
|
|
156
|
+
def test_handle_special_CROSSREF_show_hash_false
|
157
|
+
@xref.show_hash = false
|
158
|
+
|
159
|
+
assert_equal "<p>\n<a href=\"C1.html#method-i-m\">m</a>\n</p>\n",
|
160
|
+
@xref.convert('#m')
|
161
|
+
end
|
162
|
+
|
156
163
|
def test_handle_special_CROSSREF_special
|
157
164
|
assert_equal "<p>\n<a href=\"C2/C3.html\">C2::C3</a>;method(*)\n</p>\n",
|
158
165
|
@xref.convert('C2::C3;method(*)')
|
data/test/test_rdoc_parser.rb
CHANGED
@@ -42,6 +42,18 @@ class TestRDocParser < MiniTest::Unit::TestCase
|
|
42
42
|
File.unlink marshal
|
43
43
|
end
|
44
44
|
|
45
|
+
def test_class_binary_japanese_text
|
46
|
+
file_name = File.expand_path '../test.ja.txt', __FILE__
|
47
|
+
assert @RP.binary?(file_name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_class_binary_japanese_rdoc
|
51
|
+
skip "Encoding not implemented" unless defined? ::Encoding
|
52
|
+
|
53
|
+
file_name = File.expand_path '../test.ja.rdoc', __FILE__
|
54
|
+
assert !@RP.binary?(file_name)
|
55
|
+
end
|
56
|
+
|
45
57
|
def test_class_can_parse
|
46
58
|
assert_equal @RP.can_parse(__FILE__), @RP::Ruby
|
47
59
|
|
@@ -72,6 +84,10 @@ class TestRDocParser < MiniTest::Unit::TestCase
|
|
72
84
|
def test_class_for_binary
|
73
85
|
rp = @RP.dup
|
74
86
|
|
87
|
+
class << rp
|
88
|
+
alias old_can_parse can_parse
|
89
|
+
end
|
90
|
+
|
75
91
|
def rp.can_parse(*args) nil end
|
76
92
|
|
77
93
|
assert_nil @RP.for(nil, @binary_dat, nil, nil, nil)
|
data/test/test_rdoc_parser_c.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
require 'tempfile'
|
3
3
|
require 'rubygems'
|
4
|
-
require 'minitest/
|
4
|
+
require 'minitest/autorun'
|
5
5
|
require 'rdoc/options'
|
6
6
|
require 'rdoc/parser/c'
|
7
7
|
|
8
8
|
class RDoc::Parser::C
|
9
|
-
attr_accessor :classes
|
9
|
+
attr_accessor :classes, :singleton_classes
|
10
10
|
|
11
11
|
public :do_classes, :do_constants
|
12
12
|
end
|
@@ -30,6 +30,59 @@ class TestRDocParserC < MiniTest::Unit::TestCase
|
|
30
30
|
@tempfile.close
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_do_aliases
|
34
|
+
content = <<-EOF
|
35
|
+
/*
|
36
|
+
* This should show up as an alias with documentation
|
37
|
+
*/
|
38
|
+
VALUE blah(VALUE klass, VALUE year) {
|
39
|
+
}
|
40
|
+
|
41
|
+
void Init_Blah(void) {
|
42
|
+
cDate = rb_define_class("Date", rb_cObject);
|
43
|
+
|
44
|
+
rb_define_method(cDate, "blah", blah, 1);
|
45
|
+
|
46
|
+
rb_define_alias(cDate, "bleh", "blah");
|
47
|
+
}
|
48
|
+
EOF
|
49
|
+
|
50
|
+
klass = util_get_class content, 'cDate'
|
51
|
+
|
52
|
+
methods = klass.method_list
|
53
|
+
assert_equal 2, methods.length
|
54
|
+
assert_equal 'bleh', methods.last.name
|
55
|
+
assert_equal 'blah', methods.last.is_alias_for.name
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_do_aliases_singleton
|
59
|
+
content = <<-EOF
|
60
|
+
/*
|
61
|
+
* This should show up as an alias with documentation
|
62
|
+
*/
|
63
|
+
VALUE blah(VALUE klass, VALUE year) {
|
64
|
+
}
|
65
|
+
|
66
|
+
void Init_Blah(void) {
|
67
|
+
cDate = rb_define_class("Date", rb_cObject);
|
68
|
+
sDate = rb_singleton_class(cDate);
|
69
|
+
|
70
|
+
rb_define_method(sDate, "blah", blah, 1);
|
71
|
+
|
72
|
+
rb_define_alias(sDate, "bleh", "blah");
|
73
|
+
}
|
74
|
+
EOF
|
75
|
+
|
76
|
+
klass = util_get_class content, 'cDate'
|
77
|
+
|
78
|
+
methods = klass.method_list
|
79
|
+
|
80
|
+
assert_equal 2, methods.length
|
81
|
+
assert_equal 'bleh', methods.last.name
|
82
|
+
assert methods.last.singleton
|
83
|
+
assert_equal 'blah', methods.last.is_alias_for.name
|
84
|
+
end
|
85
|
+
|
33
86
|
def test_do_classes_boot_class
|
34
87
|
content = <<-EOF
|
35
88
|
/* Document-class: Foo
|
@@ -68,6 +121,17 @@ VALUE cFoo = rb_define_class("Foo", rb_cObject);
|
|
68
121
|
assert_equal "this is the Foo class", klass.comment
|
69
122
|
end
|
70
123
|
|
124
|
+
def test_do_classes_singleton
|
125
|
+
content = <<-EOF
|
126
|
+
VALUE cFoo = rb_define_class("Foo", rb_cObject);
|
127
|
+
VALUE cFooS = rb_singleton_class(cFoo);
|
128
|
+
EOF
|
129
|
+
|
130
|
+
util_get_class content, 'cFooS'
|
131
|
+
|
132
|
+
assert_equal 'Foo', @parser.singleton_classes['cFooS']
|
133
|
+
end
|
134
|
+
|
71
135
|
def test_do_classes_class_under
|
72
136
|
content = <<-EOF
|
73
137
|
/* Document-class: Kernel::Foo
|
@@ -406,6 +470,38 @@ Init_Foo(void) {
|
|
406
470
|
assert_equal "a comment for bar", bar.comment
|
407
471
|
end
|
408
472
|
|
473
|
+
def test_find_modifiers
|
474
|
+
comment = <<-COMMENT
|
475
|
+
/* call-seq:
|
476
|
+
* commercial() -> Date <br />
|
477
|
+
* commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
|
478
|
+
* commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
|
479
|
+
*
|
480
|
+
* If no arguments are given:
|
481
|
+
* * ruby 1.8: returns a +Date+ for 1582-10-15 (the Day of Calendar Reform in
|
482
|
+
* Italy)
|
483
|
+
* * ruby 1.9: returns a +Date+ for julian day 0
|
484
|
+
*
|
485
|
+
* Otherwise, returns a +Date+ for the commercial week year, commercial week,
|
486
|
+
* and commercial week day given. Ignores the 4th argument.
|
487
|
+
*/
|
488
|
+
|
489
|
+
COMMENT
|
490
|
+
|
491
|
+
parser = util_parser ''
|
492
|
+
method_obj = RDoc::AnyMethod.new nil, 'blah'
|
493
|
+
|
494
|
+
parser.find_modifiers comment, method_obj
|
495
|
+
|
496
|
+
expected = <<-CALL_SEQ
|
497
|
+
commercial() -> Date <br />
|
498
|
+
commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
|
499
|
+
commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
|
500
|
+
CALL_SEQ
|
501
|
+
|
502
|
+
assert_equal expected, method_obj.call_seq
|
503
|
+
end
|
504
|
+
|
409
505
|
def test_look_for_directives_in
|
410
506
|
parser = util_parser ''
|
411
507
|
|
@@ -442,6 +538,7 @@ Init_IO(void) {
|
|
442
538
|
read_method = klass.method_list.first
|
443
539
|
assert_equal "read", read_method.name
|
444
540
|
assert_equal "Method Comment! ", read_method.comment
|
541
|
+
assert read_method.singleton
|
445
542
|
end
|
446
543
|
|
447
544
|
def test_define_method_private
|
@@ -472,6 +569,65 @@ Init_IO(void) {
|
|
472
569
|
assert_equal "Method Comment! ", read_method.comment
|
473
570
|
end
|
474
571
|
|
572
|
+
def test_define_method_private_singleton
|
573
|
+
content = <<-EOF
|
574
|
+
/*Method Comment! */
|
575
|
+
static VALUE
|
576
|
+
rb_io_s_read(argc, argv, io)
|
577
|
+
int argc;
|
578
|
+
VALUE *argv;
|
579
|
+
VALUE io;
|
580
|
+
{
|
581
|
+
}
|
582
|
+
|
583
|
+
void
|
584
|
+
Init_IO(void) {
|
585
|
+
/*
|
586
|
+
* a comment for class Foo on rb_define_class
|
587
|
+
*/
|
588
|
+
VALUE rb_cIO = rb_define_class("IO", rb_cObject);
|
589
|
+
VALUE rb_cIO_s = rb_singleton_class(rb_cIO);
|
590
|
+
rb_define_private_method(rb_cIO_s, "read", rb_io_s_read, -1);
|
591
|
+
}
|
592
|
+
EOF
|
593
|
+
|
594
|
+
klass = util_get_class content, 'rb_cIO'
|
595
|
+
read_method = klass.method_list.first
|
596
|
+
assert_equal "read", read_method.name
|
597
|
+
assert_equal "Method Comment! ", read_method.comment
|
598
|
+
assert_equal :private, read_method.visibility
|
599
|
+
assert read_method.singleton
|
600
|
+
end
|
601
|
+
|
602
|
+
def test_define_method_singleton
|
603
|
+
content = <<-EOF
|
604
|
+
/*Method Comment! */
|
605
|
+
static VALUE
|
606
|
+
rb_io_s_read(argc, argv, io)
|
607
|
+
int argc;
|
608
|
+
VALUE *argv;
|
609
|
+
VALUE io;
|
610
|
+
{
|
611
|
+
}
|
612
|
+
|
613
|
+
void
|
614
|
+
Init_IO(void) {
|
615
|
+
/*
|
616
|
+
* a comment for class Foo on rb_define_class
|
617
|
+
*/
|
618
|
+
VALUE rb_cIO = rb_define_class("IO", rb_cObject);
|
619
|
+
VALUE rb_cIO_s = rb_singleton_class(rb_cIO);
|
620
|
+
rb_define_method(rb_cIO_s, "read", rb_io_s_read, -1);
|
621
|
+
}
|
622
|
+
EOF
|
623
|
+
|
624
|
+
klass = util_get_class content, 'rb_cIO'
|
625
|
+
read_method = klass.method_list.first
|
626
|
+
assert_equal "read", read_method.name
|
627
|
+
assert_equal "Method Comment! ", read_method.comment
|
628
|
+
assert read_method.singleton
|
629
|
+
end
|
630
|
+
|
475
631
|
def util_get_class(content, name)
|
476
632
|
@parser = util_parser content
|
477
633
|
@parser.scan
|
@@ -484,4 +640,3 @@ Init_IO(void) {
|
|
484
640
|
|
485
641
|
end
|
486
642
|
|
487
|
-
MiniTest::Unit.autorun
|
@@ -172,6 +172,23 @@ class TestRDocParserRuby < MiniTest::Unit::TestCase
|
|
172
172
|
assert_equal 'comment', alas.comment
|
173
173
|
end
|
174
174
|
|
175
|
+
def test_parse_alias_singleton
|
176
|
+
klass = RDoc::NormalClass.new 'Foo'
|
177
|
+
klass.parent = @top_level
|
178
|
+
|
179
|
+
util_parser "alias :next= :bar"
|
180
|
+
|
181
|
+
tk = @parser.get_tk
|
182
|
+
|
183
|
+
alas = @parser.parse_alias klass, RDoc::Parser::Ruby::SINGLE, tk, 'comment'
|
184
|
+
|
185
|
+
assert_equal 'bar', alas.old_name
|
186
|
+
assert_equal 'next=', alas.new_name
|
187
|
+
assert_equal klass, alas.parent
|
188
|
+
assert_equal 'comment', alas.comment
|
189
|
+
assert alas.singleton
|
190
|
+
end
|
191
|
+
|
175
192
|
def test_parse_alias_meta
|
176
193
|
klass = RDoc::NormalClass.new 'Foo'
|
177
194
|
klass.parent = @top_level
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 2.5.
|
9
|
+
- 10
|
10
|
+
version: 2.5.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Hodel
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
x52qPcexcYZR7w==
|
40
40
|
-----END CERTIFICATE-----
|
41
41
|
|
42
|
-
date: 2010-
|
42
|
+
date: 2010-08-17 00:00:00 -07:00
|
43
43
|
default_executable:
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
@@ -50,34 +50,18 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
hash:
|
53
|
+
hash: 7
|
54
54
|
segments:
|
55
55
|
- 2
|
56
56
|
- 0
|
57
|
-
-
|
58
|
-
version: 2.0.
|
57
|
+
- 4
|
58
|
+
version: 2.0.4
|
59
59
|
type: :development
|
60
60
|
version_requirements: *id001
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: gemcutter
|
63
|
-
prerelease: false
|
64
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
hash: 11
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
- 5
|
73
|
-
- 0
|
74
|
-
version: 0.5.0
|
75
|
-
type: :development
|
76
|
-
version_requirements: *id002
|
77
61
|
- !ruby/object:Gem::Dependency
|
78
62
|
name: minitest
|
79
63
|
prerelease: false
|
80
|
-
requirement: &
|
64
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
81
65
|
none: false
|
82
66
|
requirements:
|
83
67
|
- - ~>
|
@@ -88,23 +72,23 @@ dependencies:
|
|
88
72
|
- 3
|
89
73
|
version: "1.3"
|
90
74
|
type: :development
|
91
|
-
version_requirements: *
|
75
|
+
version_requirements: *id002
|
92
76
|
- !ruby/object:Gem::Dependency
|
93
77
|
name: hoe
|
94
78
|
prerelease: false
|
95
|
-
requirement: &
|
79
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
96
80
|
none: false
|
97
81
|
requirements:
|
98
82
|
- - ">="
|
99
83
|
- !ruby/object:Gem::Version
|
100
|
-
hash:
|
84
|
+
hash: 21
|
101
85
|
segments:
|
102
86
|
- 2
|
103
|
-
-
|
104
|
-
-
|
105
|
-
version: 2.
|
87
|
+
- 6
|
88
|
+
- 1
|
89
|
+
version: 2.6.1
|
106
90
|
type: :development
|
107
|
-
version_requirements: *
|
91
|
+
version_requirements: *id003
|
108
92
|
description: |-
|
109
93
|
RDoc is an application that produces documentation for one or more Ruby source
|
110
94
|
files. RDoc includes the +rdoc+ and +ri+ tools for generating and displaying
|
metadata.gz.sig
CHANGED