rdoc 3.1 → 6.3.3
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 +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +129 -0
- data/RI.rdoc +57 -0
- data/Rakefile +84 -81
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/{bin → exe}/rdoc +11 -2
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +1 -2
- data/lib/rdoc/anon_class.rb +3 -2
- data/lib/rdoc/any_method.rb +234 -40
- data/lib/rdoc/attr.rb +79 -11
- data/lib/rdoc/class_module.rb +443 -71
- data/lib/rdoc/code_object.rb +216 -20
- data/lib/rdoc/code_objects.rb +4 -21
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +110 -9
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +392 -172
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +83 -28
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +8 -3
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +507 -84
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +27 -74
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +98 -0
- data/lib/rdoc/generator/ri.rb +8 -62
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.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 +18 -60
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +24 -13
- data/lib/rdoc/ghost_method.rb +1 -2
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +5 -95
- data/lib/rdoc/known_classes.rb +5 -2
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +416 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16684 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +135 -62
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +1 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +96 -9
- data/lib/rdoc/markup/formatter.rb +138 -25
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +61 -2
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +25 -4
- data/lib/rdoc/markup/list_item.rb +18 -4
- data/lib/rdoc/markup/paragraph.rb +15 -0
- data/lib/rdoc/markup/parser.rb +180 -88
- data/lib/rdoc/markup/pre_process.rb +183 -38
- data/lib/rdoc/markup/raw.rb +6 -5
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +17 -7
- data/lib/rdoc/markup/to_bs.rb +5 -8
- data/lib/rdoc/markup/to_html.rb +238 -137
- data/lib/rdoc/markup/to_html_crossref.rb +125 -152
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +85 -15
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +2 -4
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +39 -0
- data/lib/rdoc/markup.rb +388 -110
- data/lib/rdoc/meta_method.rb +1 -2
- data/lib/rdoc/method_attr.rb +87 -21
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +39 -10
- data/lib/rdoc/normal_module.rb +22 -7
- data/lib/rdoc/options.rb +613 -73
- data/lib/rdoc/parser/c.rb +621 -287
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +1368 -762
- data/lib/rdoc/parser/ruby_tools.rb +42 -35
- data/lib/rdoc/parser/simple.rb +23 -11
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +162 -89
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +208 -115
- data/lib/rdoc/require.rb +1 -2
- data/lib/rdoc/ri/driver.rb +734 -239
- data/lib/rdoc/ri/formatter.rb +1 -0
- data/lib/rdoc/ri/paths.rb +91 -48
- data/lib/rdoc/ri/store.rb +3 -261
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +5 -2
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +14 -2
- data/lib/rdoc/stats/normal.rb +19 -12
- data/lib/rdoc/stats/quiet.rb +1 -0
- data/lib/rdoc/stats/verbose.rb +1 -0
- data/lib/rdoc/stats.rb +262 -104
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +84 -44
- data/lib/rdoc/text.rb +117 -72
- data/lib/rdoc/token_stream.rb +73 -4
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +111 -261
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +127 -64
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +171 -291
- data/.autotest +0 -16
- data/.document +0 -5
- data/History.txt +0 -594
- data/LICENSE.txt +0 -57
- data/Manifest.txt +0 -158
- data/README.txt +0 -45
- data/RI.txt +0 -58
- data/bin/ri +0 -5
- data/lib/rdoc/gauntlet.rb +0 -52
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
- data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
- data/lib/rdoc/markup/formatter_test_case.rb +0 -689
- data/lib/rdoc/markup/inline.rb +0 -137
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
- data/lib/rdoc/ruby_lex.rb +0 -1291
- data/lib/rdoc/ruby_token.rb +0 -416
- data/test/README +0 -1
- data/test/binary.dat +0 -0
- data/test/hidden.zip.txt +0 -1
- data/test/test.ja.rdoc +0 -10
- data/test/test.ja.txt +0 -8
- data/test/test.txt +0 -1
- data/test/test_attribute_manager.rb +0 -120
- data/test/test_rdoc_alias.rb +0 -13
- data/test/test_rdoc_any_method.rb +0 -126
- data/test/test_rdoc_attr.rb +0 -61
- data/test/test_rdoc_class_module.rb +0 -233
- data/test/test_rdoc_code_object.rb +0 -165
- data/test/test_rdoc_constant.rb +0 -15
- data/test/test_rdoc_context.rb +0 -370
- data/test/test_rdoc_encoding.rb +0 -166
- data/test/test_rdoc_generator_darkfish.rb +0 -119
- data/test/test_rdoc_generator_ri.rb +0 -76
- data/test/test_rdoc_include.rb +0 -96
- data/test/test_rdoc_markup.rb +0 -37
- data/test/test_rdoc_markup_attribute_manager.rb +0 -240
- data/test/test_rdoc_markup_document.rb +0 -51
- data/test/test_rdoc_markup_paragraph.rb +0 -9
- data/test/test_rdoc_markup_parser.rb +0 -1395
- data/test/test_rdoc_markup_pre_process.rb +0 -185
- data/test/test_rdoc_markup_raw.rb +0 -27
- data/test/test_rdoc_markup_to_ansi.rb +0 -328
- data/test/test_rdoc_markup_to_bs.rb +0 -341
- data/test/test_rdoc_markup_to_html.rb +0 -335
- data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
- data/test/test_rdoc_markup_to_rdoc.rb +0 -327
- data/test/test_rdoc_method_attr.rb +0 -122
- data/test/test_rdoc_normal_class.rb +0 -17
- data/test/test_rdoc_normal_module.rb +0 -31
- data/test/test_rdoc_options.rb +0 -342
- data/test/test_rdoc_parser.rb +0 -83
- data/test/test_rdoc_parser_c.rb +0 -912
- data/test/test_rdoc_parser_ruby.rb +0 -1754
- data/test/test_rdoc_parser_simple.rb +0 -99
- data/test/test_rdoc_rdoc.rb +0 -164
- data/test/test_rdoc_require.rb +0 -25
- data/test/test_rdoc_ri_driver.rb +0 -846
- data/test/test_rdoc_ri_paths.rb +0 -43
- data/test/test_rdoc_ri_store.rb +0 -352
- data/test/test_rdoc_ruby_lex.rb +0 -23
- data/test/test_rdoc_stats.rb +0 -38
- data/test/test_rdoc_task.rb +0 -92
- data/test/test_rdoc_text.rb +0 -251
- data/test/test_rdoc_top_level.rb +0 -120
- data/test/xref_data.rb +0 -62
- data/test/xref_test_case.rb +0 -61
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
data/test/test_rdoc_parser_c.rb
DELETED
@@ -1,912 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
require 'tempfile'
|
3
|
-
require 'rubygems'
|
4
|
-
require 'minitest/autorun'
|
5
|
-
require 'rdoc/options'
|
6
|
-
require 'rdoc/parser/c'
|
7
|
-
|
8
|
-
=begin
|
9
|
-
TODO: test call-seq parsing
|
10
|
-
|
11
|
-
/*
|
12
|
-
* call-seq:
|
13
|
-
* ARGF.readlines(sep=$/) -> array
|
14
|
-
* ARGF.readlines(limit) -> array
|
15
|
-
* ARGF.readlines(sep, limit) -> array
|
16
|
-
*
|
17
|
-
* ARGF.to_a(sep=$/) -> array
|
18
|
-
* ARGF.to_a(limit) -> array
|
19
|
-
* ARGF.to_a(sep, limit) -> array
|
20
|
-
*
|
21
|
-
* Reads +ARGF+'s current file in its entirety, returning an +Array+ of its
|
22
|
-
* lines, one line per element. Lines are assumed to be separated by _sep_.
|
23
|
-
*
|
24
|
-
* lines = ARGF.readlines
|
25
|
-
* lines[0] #=> "This is line one\n"
|
26
|
-
*/
|
27
|
-
|
28
|
-
assert call-seq did not stop at first empty line
|
29
|
-
|
30
|
-
/*
|
31
|
-
* call-seq:
|
32
|
-
*
|
33
|
-
* flt ** other -> float
|
34
|
-
*
|
35
|
-
* Raises <code>float</code> the <code>other</code> power.
|
36
|
-
*
|
37
|
-
* 2.0**3 #=> 8.0
|
38
|
-
*/
|
39
|
-
|
40
|
-
assert call-seq correct (bug: was empty)
|
41
|
-
|
42
|
-
/* call-seq: flt ** other -> float */
|
43
|
-
|
44
|
-
assert call-seq correct
|
45
|
-
|
46
|
-
=end
|
47
|
-
|
48
|
-
class RDoc::Parser::C
|
49
|
-
attr_accessor :classes, :singleton_classes
|
50
|
-
|
51
|
-
public :do_classes, :do_constants
|
52
|
-
end
|
53
|
-
|
54
|
-
class TestRDocParserC < MiniTest::Unit::TestCase
|
55
|
-
|
56
|
-
def setup
|
57
|
-
@tempfile = Tempfile.new self.class.name
|
58
|
-
filename = @tempfile.path
|
59
|
-
|
60
|
-
@top_level = RDoc::TopLevel.new filename
|
61
|
-
@fn = filename
|
62
|
-
@options = RDoc::Options.new
|
63
|
-
@stats = RDoc::Stats.new 0
|
64
|
-
|
65
|
-
RDoc::Parser::C.reset
|
66
|
-
RDoc::TopLevel.reset
|
67
|
-
end
|
68
|
-
|
69
|
-
def teardown
|
70
|
-
@tempfile.close
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_do_attr_rb_attr
|
74
|
-
content = <<-EOF
|
75
|
-
void Init_Blah(void) {
|
76
|
-
cBlah = rb_define_class("Blah", rb_cObject);
|
77
|
-
|
78
|
-
/*
|
79
|
-
* This is an accessor
|
80
|
-
*/
|
81
|
-
rb_attr(cBlah, rb_intern("accessor"), 1, 1, Qfalse);
|
82
|
-
|
83
|
-
/*
|
84
|
-
* This is a reader
|
85
|
-
*/
|
86
|
-
rb_attr(cBlah, rb_intern("reader"), 1, 0, Qfalse);
|
87
|
-
|
88
|
-
/*
|
89
|
-
* This is a writer
|
90
|
-
*/
|
91
|
-
rb_attr(cBlah, rb_intern("writer"), 0, 1, Qfalse);
|
92
|
-
}
|
93
|
-
EOF
|
94
|
-
|
95
|
-
klass = util_get_class content, 'cBlah'
|
96
|
-
|
97
|
-
attrs = klass.attributes
|
98
|
-
assert_equal 3, attrs.length, attrs.inspect
|
99
|
-
|
100
|
-
accessor = attrs.shift
|
101
|
-
assert_equal 'accessor', accessor.name
|
102
|
-
assert_equal 'RW', accessor.rw
|
103
|
-
assert_equal 'This is an accessor', accessor.comment
|
104
|
-
|
105
|
-
reader = attrs.shift
|
106
|
-
assert_equal 'reader', reader.name
|
107
|
-
assert_equal 'R', reader.rw
|
108
|
-
assert_equal 'This is a reader', reader.comment
|
109
|
-
|
110
|
-
writer = attrs.shift
|
111
|
-
assert_equal 'writer', writer.name
|
112
|
-
assert_equal 'W', writer.rw
|
113
|
-
assert_equal 'This is a writer', writer.comment
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_do_attr_rb_define_attr
|
117
|
-
content = <<-EOF
|
118
|
-
void Init_Blah(void) {
|
119
|
-
cBlah = rb_define_class("Blah", rb_cObject);
|
120
|
-
|
121
|
-
/*
|
122
|
-
* This is an accessor
|
123
|
-
*/
|
124
|
-
rb_define_attr(cBlah, "accessor", 1, 1);
|
125
|
-
}
|
126
|
-
EOF
|
127
|
-
|
128
|
-
klass = util_get_class content, 'cBlah'
|
129
|
-
|
130
|
-
attrs = klass.attributes
|
131
|
-
assert_equal 1, attrs.length, attrs.inspect
|
132
|
-
|
133
|
-
accessor = attrs.shift
|
134
|
-
assert_equal 'accessor', accessor.name
|
135
|
-
assert_equal 'RW', accessor.rw
|
136
|
-
assert_equal 'This is an accessor', accessor.comment
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_do_aliases
|
140
|
-
content = <<-EOF
|
141
|
-
/*
|
142
|
-
* This should show up as an alias with documentation
|
143
|
-
*/
|
144
|
-
VALUE blah(VALUE klass, VALUE year) {
|
145
|
-
}
|
146
|
-
|
147
|
-
void Init_Blah(void) {
|
148
|
-
cDate = rb_define_class("Date", rb_cObject);
|
149
|
-
|
150
|
-
rb_define_method(cDate, "blah", blah, 1);
|
151
|
-
|
152
|
-
rb_define_alias(cDate, "bleh", "blah");
|
153
|
-
}
|
154
|
-
EOF
|
155
|
-
|
156
|
-
klass = util_get_class content, 'cDate'
|
157
|
-
|
158
|
-
methods = klass.method_list
|
159
|
-
assert_equal 2, methods.length
|
160
|
-
assert_equal 'bleh', methods.last.name
|
161
|
-
assert_equal 'blah', methods.last.is_alias_for.name
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_do_aliases_singleton
|
165
|
-
content = <<-EOF
|
166
|
-
/*
|
167
|
-
* This should show up as a method with documentation
|
168
|
-
*/
|
169
|
-
VALUE blah(VALUE klass, VALUE year) {
|
170
|
-
}
|
171
|
-
|
172
|
-
void Init_Blah(void) {
|
173
|
-
cDate = rb_define_class("Date", rb_cObject);
|
174
|
-
sDate = rb_singleton_class(cDate);
|
175
|
-
|
176
|
-
rb_define_method(sDate, "blah", blah, 1);
|
177
|
-
|
178
|
-
/*
|
179
|
-
* This should show up as an alias
|
180
|
-
*/
|
181
|
-
rb_define_alias(sDate, "bleh", "blah");
|
182
|
-
}
|
183
|
-
EOF
|
184
|
-
|
185
|
-
klass = util_get_class content, 'cDate'
|
186
|
-
|
187
|
-
methods = klass.method_list
|
188
|
-
|
189
|
-
assert_equal 2, methods.length
|
190
|
-
assert_equal 'bleh', methods.last.name
|
191
|
-
assert methods.last.singleton
|
192
|
-
assert_equal 'blah', methods.last.is_alias_for.name
|
193
|
-
assert_equal 'This should show up as an alias', methods.last.comment
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_do_classes_boot_class
|
197
|
-
content = <<-EOF
|
198
|
-
/* Document-class: Foo
|
199
|
-
* this is the Foo boot class
|
200
|
-
*/
|
201
|
-
VALUE cFoo = boot_defclass("Foo", rb_cObject);
|
202
|
-
EOF
|
203
|
-
|
204
|
-
klass = util_get_class content, 'cFoo'
|
205
|
-
assert_equal "this is the Foo boot class", klass.comment
|
206
|
-
assert_equal 'Object', klass.superclass
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_do_classes_boot_class_nil
|
210
|
-
content = <<-EOF
|
211
|
-
/* Document-class: Foo
|
212
|
-
* this is the Foo boot class
|
213
|
-
*/
|
214
|
-
VALUE cFoo = boot_defclass("Foo", 0);
|
215
|
-
EOF
|
216
|
-
|
217
|
-
klass = util_get_class content, 'cFoo'
|
218
|
-
assert_equal "this is the Foo boot class", klass.comment
|
219
|
-
assert_equal nil, klass.superclass
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_do_classes_class
|
223
|
-
content = <<-EOF
|
224
|
-
/* Document-class: Foo
|
225
|
-
* this is the Foo class
|
226
|
-
*/
|
227
|
-
VALUE cFoo = rb_define_class("Foo", rb_cObject);
|
228
|
-
EOF
|
229
|
-
|
230
|
-
klass = util_get_class content, 'cFoo'
|
231
|
-
assert_equal "this is the Foo class", klass.comment
|
232
|
-
end
|
233
|
-
|
234
|
-
def test_do_classes_singleton
|
235
|
-
content = <<-EOF
|
236
|
-
VALUE cFoo = rb_define_class("Foo", rb_cObject);
|
237
|
-
VALUE cFooS = rb_singleton_class(cFoo);
|
238
|
-
EOF
|
239
|
-
|
240
|
-
util_get_class content, 'cFooS'
|
241
|
-
|
242
|
-
assert_equal 'Foo', @parser.singleton_classes['cFooS']
|
243
|
-
end
|
244
|
-
|
245
|
-
def test_do_classes_class_under
|
246
|
-
content = <<-EOF
|
247
|
-
/* Document-class: Kernel::Foo
|
248
|
-
* this is the Foo class under Kernel
|
249
|
-
*/
|
250
|
-
VALUE cFoo = rb_define_class_under(rb_mKernel, "Foo", rb_cObject);
|
251
|
-
EOF
|
252
|
-
|
253
|
-
klass = util_get_class content, 'cFoo'
|
254
|
-
assert_equal "this is the Foo class under Kernel", klass.comment
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_do_classes_module
|
258
|
-
content = <<-EOF
|
259
|
-
/* Document-module: Foo
|
260
|
-
* this is the Foo module
|
261
|
-
*/
|
262
|
-
VALUE mFoo = rb_define_module("Foo");
|
263
|
-
EOF
|
264
|
-
|
265
|
-
klass = util_get_class content, 'mFoo'
|
266
|
-
assert_equal "this is the Foo module", klass.comment
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_do_classes_module_under
|
270
|
-
content = <<-EOF
|
271
|
-
/* Document-module: Kernel::Foo
|
272
|
-
* this is the Foo module under Kernel
|
273
|
-
*/
|
274
|
-
VALUE mFoo = rb_define_module_under(rb_mKernel, "Foo");
|
275
|
-
EOF
|
276
|
-
|
277
|
-
klass = util_get_class content, 'mFoo'
|
278
|
-
assert_equal "this is the Foo module under Kernel", klass.comment
|
279
|
-
end
|
280
|
-
|
281
|
-
def test_do_constants
|
282
|
-
content = <<-EOF
|
283
|
-
#include <ruby.h>
|
284
|
-
|
285
|
-
void Init_foo(){
|
286
|
-
VALUE cFoo = rb_define_class("Foo", rb_cObject);
|
287
|
-
|
288
|
-
/* 300: The highest possible score in bowling */
|
289
|
-
rb_define_const(cFoo, "PERFECT", INT2FIX(300));
|
290
|
-
|
291
|
-
/* Huzzah!: What you cheer when you roll a perfect game */
|
292
|
-
rb_define_const(cFoo, "CHEER", rb_str_new2("Huzzah!"));
|
293
|
-
|
294
|
-
/* TEST\:TEST: Checking to see if escaped colon works */
|
295
|
-
rb_define_const(cFoo, "TEST", rb_str_new2("TEST:TEST"));
|
296
|
-
|
297
|
-
/* \\: The file separator on MS Windows */
|
298
|
-
rb_define_const(cFoo, "MSEPARATOR", rb_str_new2("\\"));
|
299
|
-
|
300
|
-
/* /: The file separator on Unix */
|
301
|
-
rb_define_const(cFoo, "SEPARATOR", rb_str_new2("/"));
|
302
|
-
|
303
|
-
/* C:\\Program Files\\Stuff: A directory on MS Windows */
|
304
|
-
rb_define_const(cFoo, "STUFF", rb_str_new2("C:\\Program Files\\Stuff"));
|
305
|
-
|
306
|
-
/* Default definition */
|
307
|
-
rb_define_const(cFoo, "NOSEMI", INT2FIX(99));
|
308
|
-
|
309
|
-
rb_define_const(cFoo, "NOCOMMENT", rb_str_new2("No comment"));
|
310
|
-
|
311
|
-
/*
|
312
|
-
* Multiline comment goes here because this comment spans multiple lines.
|
313
|
-
* Multiline comment goes here because this comment spans multiple lines.
|
314
|
-
*/
|
315
|
-
rb_define_const(cFoo, "MULTILINE", INT2FIX(1));
|
316
|
-
|
317
|
-
/*
|
318
|
-
* 1: Multiline comment goes here because this comment spans multiple lines.
|
319
|
-
* Multiline comment goes here because this comment spans multiple lines.
|
320
|
-
*/
|
321
|
-
rb_define_const(cFoo, "MULTILINE_VALUE", INT2FIX(1));
|
322
|
-
|
323
|
-
/* Multiline comment goes here because this comment spans multiple lines.
|
324
|
-
* Multiline comment goes here because this comment spans multiple lines.
|
325
|
-
*/
|
326
|
-
rb_define_const(cFoo, "MULTILINE_NOT_EMPTY", INT2FIX(1));
|
327
|
-
|
328
|
-
}
|
329
|
-
EOF
|
330
|
-
|
331
|
-
@parser = util_parser content
|
332
|
-
|
333
|
-
@parser.do_classes
|
334
|
-
@parser.do_constants
|
335
|
-
|
336
|
-
klass = @parser.classes['cFoo']
|
337
|
-
assert klass
|
338
|
-
|
339
|
-
constants = klass.constants
|
340
|
-
assert !klass.constants.empty?
|
341
|
-
|
342
|
-
constants = constants.map { |c| [c.name, c.value, c.comment] }
|
343
|
-
|
344
|
-
assert_equal ['PERFECT', '300', 'The highest possible score in bowling '],
|
345
|
-
constants.shift
|
346
|
-
assert_equal ['CHEER', 'Huzzah!',
|
347
|
-
'What you cheer when you roll a perfect game '],
|
348
|
-
constants.shift
|
349
|
-
assert_equal ['TEST', 'TEST:TEST',
|
350
|
-
'Checking to see if escaped colon works '],
|
351
|
-
constants.shift
|
352
|
-
assert_equal ['MSEPARATOR', '\\',
|
353
|
-
'The file separator on MS Windows '],
|
354
|
-
constants.shift
|
355
|
-
assert_equal ['SEPARATOR', '/',
|
356
|
-
'The file separator on Unix '],
|
357
|
-
constants.shift
|
358
|
-
assert_equal ['STUFF', 'C:\\Program Files\\Stuff',
|
359
|
-
'A directory on MS Windows '],
|
360
|
-
constants.shift
|
361
|
-
assert_equal ['NOSEMI', 'INT2FIX(99)',
|
362
|
-
'Default definition '],
|
363
|
-
constants.shift
|
364
|
-
assert_equal ['NOCOMMENT', 'rb_str_new2("No comment")', ''],
|
365
|
-
constants.shift
|
366
|
-
|
367
|
-
comment = <<-EOF.chomp
|
368
|
-
Multiline comment goes here because this comment spans multiple lines.
|
369
|
-
Multiline comment goes here because this comment spans multiple lines.
|
370
|
-
EOF
|
371
|
-
assert_equal ['MULTILINE', 'INT2FIX(1)', comment], constants.shift
|
372
|
-
assert_equal ['MULTILINE_VALUE', '1', comment], constants.shift
|
373
|
-
assert_equal ['MULTILINE_NOT_EMPTY', 'INT2FIX(1)', comment], constants.shift
|
374
|
-
|
375
|
-
assert constants.empty?, constants.inspect
|
376
|
-
end
|
377
|
-
|
378
|
-
def test_find_alias_comment
|
379
|
-
parser = util_parser ''
|
380
|
-
|
381
|
-
comment = parser.find_alias_comment 'C', '[]', 'index'
|
382
|
-
|
383
|
-
assert_equal '', comment
|
384
|
-
|
385
|
-
parser = util_parser <<-C
|
386
|
-
/*
|
387
|
-
* comment
|
388
|
-
*/
|
389
|
-
|
390
|
-
rb_define_alias(C, "[]", "index");
|
391
|
-
C
|
392
|
-
|
393
|
-
comment = parser.find_alias_comment 'C', '[]', 'index'
|
394
|
-
|
395
|
-
assert_equal "/*\n * comment\n */\n\n", comment
|
396
|
-
end
|
397
|
-
|
398
|
-
def test_find_class_comment_include
|
399
|
-
@options.rdoc_include << File.dirname(__FILE__)
|
400
|
-
|
401
|
-
content = <<-EOF
|
402
|
-
/*
|
403
|
-
* a comment for class Foo
|
404
|
-
*
|
405
|
-
* :include: test.txt
|
406
|
-
*/
|
407
|
-
void
|
408
|
-
Init_Foo(void) {
|
409
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
410
|
-
}
|
411
|
-
EOF
|
412
|
-
|
413
|
-
klass = util_get_class content, 'foo'
|
414
|
-
|
415
|
-
assert_equal "a comment for class Foo\n\ntest file", klass.comment
|
416
|
-
end
|
417
|
-
|
418
|
-
def test_find_class_comment_init
|
419
|
-
content = <<-EOF
|
420
|
-
/*
|
421
|
-
* a comment for class Foo
|
422
|
-
*/
|
423
|
-
void
|
424
|
-
Init_Foo(void) {
|
425
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
426
|
-
}
|
427
|
-
EOF
|
428
|
-
|
429
|
-
klass = util_get_class content, 'foo'
|
430
|
-
|
431
|
-
assert_equal "a comment for class Foo", klass.comment
|
432
|
-
end
|
433
|
-
|
434
|
-
def test_find_class_comment_define_class
|
435
|
-
content = <<-EOF
|
436
|
-
/*
|
437
|
-
* a comment for class Foo
|
438
|
-
*/
|
439
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
440
|
-
EOF
|
441
|
-
|
442
|
-
klass = util_get_class content, 'foo'
|
443
|
-
|
444
|
-
assert_equal "a comment for class Foo", klass.comment
|
445
|
-
end
|
446
|
-
|
447
|
-
def test_find_class_comment_define_class_Init_Foo
|
448
|
-
content = <<-EOF
|
449
|
-
/*
|
450
|
-
* a comment for class Foo on Init
|
451
|
-
*/
|
452
|
-
void
|
453
|
-
Init_Foo(void) {
|
454
|
-
/*
|
455
|
-
* a comment for class Foo on rb_define_class
|
456
|
-
*/
|
457
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
458
|
-
}
|
459
|
-
EOF
|
460
|
-
|
461
|
-
klass = util_get_class content, 'foo'
|
462
|
-
|
463
|
-
assert_equal "a comment for class Foo on Init", klass.comment
|
464
|
-
end
|
465
|
-
|
466
|
-
def test_find_class_comment_define_class_Init_Foo_no_void
|
467
|
-
content = <<-EOF
|
468
|
-
/*
|
469
|
-
* a comment for class Foo on Init
|
470
|
-
*/
|
471
|
-
void
|
472
|
-
Init_Foo() {
|
473
|
-
/*
|
474
|
-
* a comment for class Foo on rb_define_class
|
475
|
-
*/
|
476
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
477
|
-
}
|
478
|
-
EOF
|
479
|
-
|
480
|
-
klass = util_get_class content, 'foo'
|
481
|
-
|
482
|
-
assert_equal "a comment for class Foo on Init", klass.comment
|
483
|
-
end
|
484
|
-
|
485
|
-
def test_find_class_comment_define_class_bogus_comment
|
486
|
-
content = <<-EOF
|
487
|
-
/*
|
488
|
-
* a comment for other_function
|
489
|
-
*/
|
490
|
-
void
|
491
|
-
other_function() {
|
492
|
-
}
|
493
|
-
|
494
|
-
void
|
495
|
-
Init_Foo(void) {
|
496
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
497
|
-
}
|
498
|
-
EOF
|
499
|
-
|
500
|
-
klass = util_get_class content, 'foo'
|
501
|
-
|
502
|
-
assert_equal '', klass.comment
|
503
|
-
end
|
504
|
-
|
505
|
-
def test_find_body
|
506
|
-
content = <<-EOF
|
507
|
-
/*
|
508
|
-
* a comment for other_function
|
509
|
-
*/
|
510
|
-
VALUE
|
511
|
-
other_function() {
|
512
|
-
}
|
513
|
-
|
514
|
-
void
|
515
|
-
Init_Foo(void) {
|
516
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
517
|
-
|
518
|
-
rb_define_method(foo, "my_method", other_function, 0);
|
519
|
-
}
|
520
|
-
EOF
|
521
|
-
|
522
|
-
klass = util_get_class content, 'foo'
|
523
|
-
other_function = klass.method_list.first
|
524
|
-
|
525
|
-
assert_equal 'my_method', other_function.name
|
526
|
-
assert_equal "a comment for other_function",
|
527
|
-
other_function.comment
|
528
|
-
assert_equal '()', other_function.params
|
529
|
-
|
530
|
-
code = other_function.token_stream.first.text
|
531
|
-
|
532
|
-
assert_equal "VALUE\nother_function() ", code
|
533
|
-
end
|
534
|
-
|
535
|
-
def test_find_body_2
|
536
|
-
content = <<-CONTENT
|
537
|
-
/* Copyright (C) 2010 Sven Herzberg
|
538
|
-
*
|
539
|
-
* This file is free software; the author(s) gives unlimited
|
540
|
-
* permission to copy and/or distribute it, with or without
|
541
|
-
* modifications, as long as this notice is preserved.
|
542
|
-
*/
|
543
|
-
|
544
|
-
#include <ruby.h>
|
545
|
-
|
546
|
-
static VALUE
|
547
|
-
wrap_initialize (VALUE self)
|
548
|
-
{
|
549
|
-
return self;
|
550
|
-
}
|
551
|
-
|
552
|
-
/* */
|
553
|
-
static VALUE
|
554
|
-
wrap_shift (VALUE self,
|
555
|
-
VALUE arg)
|
556
|
-
{
|
557
|
-
return self;
|
558
|
-
}
|
559
|
-
|
560
|
-
void
|
561
|
-
init_gi_repository (void)
|
562
|
-
{
|
563
|
-
VALUE mTest = rb_define_module ("Test");
|
564
|
-
VALUE cTest = rb_define_class_under (mTest, "Test", rb_cObject);
|
565
|
-
|
566
|
-
rb_define_method (cTest, "initialize", wrap_initialize, 0);
|
567
|
-
rb_define_method (cTest, "shift", wrap_shift, 0);
|
568
|
-
}
|
569
|
-
CONTENT
|
570
|
-
|
571
|
-
klass = util_get_class content, 'cTest'
|
572
|
-
assert_equal 2, klass.method_list.length
|
573
|
-
end
|
574
|
-
|
575
|
-
def test_find_body_define
|
576
|
-
content = <<-EOF
|
577
|
-
/*
|
578
|
-
* a comment for other_function
|
579
|
-
*/
|
580
|
-
#define other_function rb_other_function
|
581
|
-
|
582
|
-
/* */
|
583
|
-
VALUE
|
584
|
-
rb_other_function() {
|
585
|
-
}
|
586
|
-
|
587
|
-
void
|
588
|
-
Init_Foo(void) {
|
589
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
590
|
-
|
591
|
-
rb_define_method(foo, "my_method", other_function, 0);
|
592
|
-
}
|
593
|
-
EOF
|
594
|
-
|
595
|
-
klass = util_get_class content, 'foo'
|
596
|
-
other_function = klass.method_list.first
|
597
|
-
|
598
|
-
assert_equal 'my_method', other_function.name
|
599
|
-
assert_equal "a comment for other_function",
|
600
|
-
other_function.comment
|
601
|
-
assert_equal '()', other_function.params
|
602
|
-
|
603
|
-
code = other_function.token_stream.first.text
|
604
|
-
|
605
|
-
assert_equal "#define other_function rb_other_function", code
|
606
|
-
end
|
607
|
-
|
608
|
-
def test_find_body_document_method
|
609
|
-
content = <<-EOF
|
610
|
-
/*
|
611
|
-
* Document-method: bar
|
612
|
-
* Document-method: baz
|
613
|
-
*
|
614
|
-
* a comment for bar
|
615
|
-
*/
|
616
|
-
VALUE
|
617
|
-
bar() {
|
618
|
-
}
|
619
|
-
|
620
|
-
void
|
621
|
-
Init_Foo(void) {
|
622
|
-
VALUE foo = rb_define_class("Foo", rb_cObject);
|
623
|
-
|
624
|
-
rb_define_method(foo, "bar", bar, 0);
|
625
|
-
rb_define_method(foo, "baz", bar, 0);
|
626
|
-
}
|
627
|
-
EOF
|
628
|
-
|
629
|
-
klass = util_get_class content, 'foo'
|
630
|
-
assert_equal 2, klass.method_list.length
|
631
|
-
|
632
|
-
methods = klass.method_list.sort
|
633
|
-
|
634
|
-
bar = methods.first
|
635
|
-
assert_equal 'Foo#bar', bar.full_name
|
636
|
-
assert_equal "a comment for bar", bar.comment
|
637
|
-
|
638
|
-
baz = methods.last
|
639
|
-
assert_equal 'Foo#baz', baz.full_name
|
640
|
-
assert_equal "a comment for bar", bar.comment
|
641
|
-
end
|
642
|
-
|
643
|
-
def test_find_modifiers_call_seq
|
644
|
-
comment = <<-COMMENT
|
645
|
-
/* call-seq:
|
646
|
-
* commercial() -> Date <br />
|
647
|
-
* commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
|
648
|
-
* commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
|
649
|
-
*
|
650
|
-
* If no arguments are given:
|
651
|
-
* * ruby 1.8: returns a +Date+ for 1582-10-15 (the Day of Calendar Reform in
|
652
|
-
* Italy)
|
653
|
-
* * ruby 1.9: returns a +Date+ for julian day 0
|
654
|
-
*
|
655
|
-
* Otherwise, returns a +Date+ for the commercial week year, commercial week,
|
656
|
-
* and commercial week day given. Ignores the 4th argument.
|
657
|
-
*/
|
658
|
-
|
659
|
-
COMMENT
|
660
|
-
|
661
|
-
parser = util_parser ''
|
662
|
-
method_obj = RDoc::AnyMethod.new nil, 'blah'
|
663
|
-
|
664
|
-
parser.find_modifiers comment, method_obj
|
665
|
-
|
666
|
-
expected = <<-CALL_SEQ.chomp
|
667
|
-
commercial() -> Date <br />
|
668
|
-
commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
|
669
|
-
commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
|
670
|
-
|
671
|
-
CALL_SEQ
|
672
|
-
|
673
|
-
assert_equal expected, method_obj.call_seq
|
674
|
-
end
|
675
|
-
|
676
|
-
def test_find_modifiers_call_seq_no_blank
|
677
|
-
comment = <<-COMMENT
|
678
|
-
/* call-seq:
|
679
|
-
* commercial() -> Date <br />
|
680
|
-
* commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
|
681
|
-
* commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
|
682
|
-
*/
|
683
|
-
|
684
|
-
COMMENT
|
685
|
-
|
686
|
-
parser = util_parser ''
|
687
|
-
method_obj = RDoc::AnyMethod.new nil, 'blah'
|
688
|
-
|
689
|
-
parser.find_modifiers comment, method_obj
|
690
|
-
|
691
|
-
expected = <<-CALL_SEQ.chomp
|
692
|
-
commercial() -> Date <br />
|
693
|
-
commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
|
694
|
-
commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
|
695
|
-
|
696
|
-
CALL_SEQ
|
697
|
-
|
698
|
-
assert_equal expected, method_obj.call_seq
|
699
|
-
end
|
700
|
-
|
701
|
-
def test_find_modifiers_nodoc
|
702
|
-
comment = <<-COMMENT
|
703
|
-
/* :nodoc:
|
704
|
-
*
|
705
|
-
* Blah
|
706
|
-
*/
|
707
|
-
|
708
|
-
COMMENT
|
709
|
-
|
710
|
-
parser = util_parser ''
|
711
|
-
method_obj = RDoc::AnyMethod.new nil, 'blah'
|
712
|
-
|
713
|
-
parser.find_modifiers comment, method_obj
|
714
|
-
|
715
|
-
assert_equal nil, method_obj.document_self
|
716
|
-
end
|
717
|
-
|
718
|
-
def test_find_modifiers_yields
|
719
|
-
comment = <<-COMMENT
|
720
|
-
/* :yields: a, b
|
721
|
-
*
|
722
|
-
* Blah
|
723
|
-
*/
|
724
|
-
|
725
|
-
COMMENT
|
726
|
-
|
727
|
-
parser = util_parser ''
|
728
|
-
method_obj = RDoc::AnyMethod.new nil, 'blah'
|
729
|
-
|
730
|
-
parser.find_modifiers comment, method_obj
|
731
|
-
|
732
|
-
assert_equal 'a, b', method_obj.block_params
|
733
|
-
|
734
|
-
expected = <<-EXPECTED
|
735
|
-
/*
|
736
|
-
*
|
737
|
-
* Blah
|
738
|
-
*/
|
739
|
-
|
740
|
-
EXPECTED
|
741
|
-
|
742
|
-
assert_equal expected, comment
|
743
|
-
end
|
744
|
-
|
745
|
-
def test_handle_method
|
746
|
-
parser = util_parser "Document-method: BasicObject#==\n blah */"
|
747
|
-
|
748
|
-
parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 1
|
749
|
-
|
750
|
-
bo = @top_level.find_module_named 'BasicObject'
|
751
|
-
|
752
|
-
assert_equal 1, bo.method_list.length
|
753
|
-
|
754
|
-
equals2 = bo.method_list.first
|
755
|
-
|
756
|
-
assert_equal '==', equals2.name
|
757
|
-
end
|
758
|
-
|
759
|
-
def test_handle_method_initialize
|
760
|
-
parser = util_parser "Document-method: BasicObject::new\n blah */"
|
761
|
-
|
762
|
-
parser.handle_method('private_method', 'rb_cBasicObject',
|
763
|
-
'initialize', 'rb_obj_dummy', -1)
|
764
|
-
|
765
|
-
bo = @top_level.find_module_named 'BasicObject'
|
766
|
-
|
767
|
-
assert_equal 1, bo.method_list.length
|
768
|
-
|
769
|
-
new = bo.method_list.first
|
770
|
-
|
771
|
-
assert_equal 'new', new.name
|
772
|
-
assert_equal :public, new.visibility
|
773
|
-
end
|
774
|
-
|
775
|
-
def test_look_for_directives_in
|
776
|
-
parser = util_parser ''
|
777
|
-
|
778
|
-
comment = "# :markup: not_rdoc\n"
|
779
|
-
|
780
|
-
parser.look_for_directives_in @top_level, comment
|
781
|
-
|
782
|
-
assert_equal "# :markup: not_rdoc\n", comment
|
783
|
-
assert_equal 'not_rdoc', @top_level.metadata['markup']
|
784
|
-
end
|
785
|
-
|
786
|
-
def test_define_method
|
787
|
-
content = <<-EOF
|
788
|
-
/*Method Comment! */
|
789
|
-
static VALUE
|
790
|
-
rb_io_s_read(argc, argv, io)
|
791
|
-
int argc;
|
792
|
-
VALUE *argv;
|
793
|
-
VALUE io;
|
794
|
-
{
|
795
|
-
}
|
796
|
-
|
797
|
-
void
|
798
|
-
Init_IO(void) {
|
799
|
-
/*
|
800
|
-
* a comment for class Foo on rb_define_class
|
801
|
-
*/
|
802
|
-
VALUE rb_cIO = rb_define_class("IO", rb_cObject);
|
803
|
-
rb_define_singleton_method(rb_cIO, "read", rb_io_s_read, -1);
|
804
|
-
}
|
805
|
-
EOF
|
806
|
-
|
807
|
-
klass = util_get_class content, 'rb_cIO'
|
808
|
-
read_method = klass.method_list.first
|
809
|
-
assert_equal "read", read_method.name
|
810
|
-
assert_equal "Method Comment! ", read_method.comment
|
811
|
-
assert read_method.singleton
|
812
|
-
end
|
813
|
-
|
814
|
-
def test_define_method_private
|
815
|
-
content = <<-EOF
|
816
|
-
/*Method Comment! */
|
817
|
-
static VALUE
|
818
|
-
rb_io_s_read(argc, argv, io)
|
819
|
-
int argc;
|
820
|
-
VALUE *argv;
|
821
|
-
VALUE io;
|
822
|
-
{
|
823
|
-
}
|
824
|
-
|
825
|
-
void
|
826
|
-
Init_IO(void) {
|
827
|
-
/*
|
828
|
-
* a comment for class Foo on rb_define_class
|
829
|
-
*/
|
830
|
-
VALUE rb_cIO = rb_define_class("IO", rb_cObject);
|
831
|
-
rb_define_private_method(rb_cIO, "read", rb_io_s_read, -1);
|
832
|
-
}
|
833
|
-
EOF
|
834
|
-
|
835
|
-
klass = util_get_class content, 'rb_cIO'
|
836
|
-
read_method = klass.method_list.first
|
837
|
-
assert_equal 'IO#read', read_method.full_name
|
838
|
-
assert_equal :private, read_method.visibility
|
839
|
-
assert_equal "Method Comment! ", read_method.comment
|
840
|
-
end
|
841
|
-
|
842
|
-
def test_define_method_private_singleton
|
843
|
-
content = <<-EOF
|
844
|
-
/*Method Comment! */
|
845
|
-
static VALUE
|
846
|
-
rb_io_s_read(argc, argv, io)
|
847
|
-
int argc;
|
848
|
-
VALUE *argv;
|
849
|
-
VALUE io;
|
850
|
-
{
|
851
|
-
}
|
852
|
-
|
853
|
-
void
|
854
|
-
Init_IO(void) {
|
855
|
-
/*
|
856
|
-
* a comment for class Foo on rb_define_class
|
857
|
-
*/
|
858
|
-
VALUE rb_cIO = rb_define_class("IO", rb_cObject);
|
859
|
-
VALUE rb_cIO_s = rb_singleton_class(rb_cIO);
|
860
|
-
rb_define_private_method(rb_cIO_s, "read", rb_io_s_read, -1);
|
861
|
-
}
|
862
|
-
EOF
|
863
|
-
|
864
|
-
klass = util_get_class content, 'rb_cIO'
|
865
|
-
read_method = klass.method_list.first
|
866
|
-
assert_equal "read", read_method.name
|
867
|
-
assert_equal "Method Comment! ", read_method.comment
|
868
|
-
assert_equal :private, read_method.visibility
|
869
|
-
assert read_method.singleton
|
870
|
-
end
|
871
|
-
|
872
|
-
def test_define_method_singleton
|
873
|
-
content = <<-EOF
|
874
|
-
/*Method Comment! */
|
875
|
-
static VALUE
|
876
|
-
rb_io_s_read(argc, argv, io)
|
877
|
-
int argc;
|
878
|
-
VALUE *argv;
|
879
|
-
VALUE io;
|
880
|
-
{
|
881
|
-
}
|
882
|
-
|
883
|
-
void
|
884
|
-
Init_IO(void) {
|
885
|
-
/*
|
886
|
-
* a comment for class Foo on rb_define_class
|
887
|
-
*/
|
888
|
-
VALUE rb_cIO = rb_define_class("IO", rb_cObject);
|
889
|
-
VALUE rb_cIO_s = rb_singleton_class(rb_cIO);
|
890
|
-
rb_define_method(rb_cIO_s, "read", rb_io_s_read, -1);
|
891
|
-
}
|
892
|
-
EOF
|
893
|
-
|
894
|
-
klass = util_get_class content, 'rb_cIO'
|
895
|
-
read_method = klass.method_list.first
|
896
|
-
assert_equal "read", read_method.name
|
897
|
-
assert_equal "Method Comment! ", read_method.comment
|
898
|
-
assert read_method.singleton
|
899
|
-
end
|
900
|
-
|
901
|
-
def util_get_class(content, name)
|
902
|
-
@parser = util_parser content
|
903
|
-
@parser.scan
|
904
|
-
@parser.classes[name]
|
905
|
-
end
|
906
|
-
|
907
|
-
def util_parser(content)
|
908
|
-
RDoc::Parser::C.new @top_level, @fn, content, @options, @stats
|
909
|
-
end
|
910
|
-
|
911
|
-
end
|
912
|
-
|