Skip to content

Commit 5ed8ded

Browse files
committed
Use *args instead of ... for unknown args
1 parent 62dca7a commit 5ed8ded

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

History.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
<kbd>rdoc -C</kbd> gives a standard report, <kbd>rdoc -C1</kbd> includes
88
method parameters. Method parameters are considered documented if they're
99
marked-up with <tt>+</tt>, <tt><code></tt> or <code><tt></code>.
10-
* The C parser now records the file location of aliases, attributes,
11-
constants and methods.
10+
* The C parser now uses <tt>*args</tt> instead of <tt>...</tt> if no
11+
<tt>call-seq</tt> was provided to give names to the arguments.
1212
* Bug fixes
13+
* The C parser now records the file location of aliases, attributes,
14+
constants and methods allowing -C to work on C files.
1315
* Darkfish now handles dots in call-seq allowing <tt>ary.insert(index,
1416
obj...)</tt> to display correctly. Patch #6 by KUBO Takehiro.
1517
* Improved processing of meta-programmed methods when followed by unparseable

lib/rdoc/parser/c.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,12 @@ def handle_method(type, var_name, meth_name, meth_body, param_count,
779779
p_count = Integer(param_count) rescue -1
780780

781781
if p_count < 0 then
782-
meth_obj.params = "(...)"
782+
meth_obj.params = "(*args)"
783783
elsif p_count == 0
784784
meth_obj.params = "()"
785785
else
786-
meth_obj.params = "(" + (1..p_count).map{|i| "p#{i}"}.join(", ") + ")"
786+
params = (1..p_count).map { |i| "p#{i}" }.join(', ')
787+
meth_obj.params = "(#{params})"
787788
end
788789

789790
if source_file then

test/test_rdoc_parser_c.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,18 +750,29 @@ def test_find_modifiers_yields
750750
end
751751

752752
def test_handle_method
753+
parser = util_parser "Document-method: Object#m\n blah */"
754+
755+
parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', 2
756+
757+
m = @top_level.find_module_named('Object').method_list.first
758+
759+
assert_equal 'm', m.name
760+
assert_equal '(p1, p2)', m.params
761+
assert_equal @top_level, m.file
762+
end
763+
764+
def test_handle_method_args
753765
parser = util_parser "Document-method: BasicObject#==\n blah */"
754766

755-
parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 1
767+
parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 2
756768

757769
bo = @top_level.find_module_named 'BasicObject'
758770

759771
assert_equal 1, bo.method_list.length
760772

761773
equals2 = bo.method_list.first
762774

763-
assert_equal '==', equals2.name
764-
assert_equal @top_level, equals2.file
775+
assert_equal '(p1, p2)', equals2.params
765776
end
766777

767778
def test_handle_method_initialize
@@ -780,6 +791,16 @@ def test_handle_method_initialize
780791
assert_equal :public, new.visibility
781792
end
782793

794+
def test_handle_method_star_args
795+
parser = util_parser "Document-method: Object#m\n blah */"
796+
797+
parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', -1
798+
799+
m = @top_level.find_module_named('Object').method_list.first
800+
801+
assert_equal '(*args)', m.params
802+
end
803+
783804
def test_look_for_directives_in
784805
parser = util_parser ''
785806

0 commit comments

Comments
 (0)