Skip to content

Commit 62dca7a

Browse files
committed
Record the location of everything in the C parser
1 parent 09ddb2b commit 62dca7a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

History.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
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.
1012
* Bug fixes
1113
* Darkfish now handles dots in call-seq allowing <tt>ary.insert(index,
1214
obj...)</tt> to display correctly. Patch #6 by KUBO Takehiro.

lib/rdoc/parser/c.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def do_aliases
156156
comment = strip_stars comment
157157
al.comment = comment
158158

159+
al.record_location @top_level
159160
class_obj.add_alias al
160161
@stats.add_alias al
161162
end
@@ -618,6 +619,7 @@ def handle_attr(var_name, attr_name, read, write)
618619

619620
attr = RDoc::Attr.new '', name, rw, comment
620621

622+
attr.record_location @top_level
621623
class_obj.add_attribute attr
622624
@stats.add_attribute attr
623625
end
@@ -732,6 +734,7 @@ def handle_constants(type, var_name, const_name, definition)
732734
con = RDoc::Constant.new const_name, definition, comment
733735
end
734736

737+
con.record_location @top_level
735738
@stats.add_constant con
736739
class_obj.add_constant con
737740
end
@@ -797,6 +800,7 @@ def handle_method(type, var_name, meth_name, meth_body, param_count,
797800

798801
if find_body(class_name, meth_body, meth_obj, body) and
799802
meth_obj.document_self then
803+
meth_obj.record_location @top_level
800804
class_obj.add_method meth_obj
801805
@stats.add_method meth_obj
802806
meth_obj.visibility = :private if 'private_method' == type

test/test_rdoc_parser_c.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def test_do_attr_rb_attr
101101
assert_equal 'accessor', accessor.name
102102
assert_equal 'RW', accessor.rw
103103
assert_equal 'This is an accessor', accessor.comment
104+
assert_equal @top_level, accessor.file
104105

105106
reader = attrs.shift
106107
assert_equal 'reader', reader.name
@@ -134,6 +135,7 @@ def test_do_attr_rb_define_attr
134135
assert_equal 'accessor', accessor.name
135136
assert_equal 'RW', accessor.rw
136137
assert_equal 'This is an accessor', accessor.comment
138+
assert_equal @top_level, accessor.file
137139
end
138140

139141
def test_do_aliases
@@ -159,6 +161,9 @@ def test_do_aliases
159161
assert_equal 2, methods.length
160162
assert_equal 'bleh', methods.last.name
161163
assert_equal 'blah', methods.last.is_alias_for.name
164+
165+
assert_equal @top_level, methods.last.is_alias_for.file
166+
assert_equal @top_level, methods.last.file
162167
end
163168

164169
def test_do_aliases_singleton
@@ -339,6 +344,8 @@ def test_do_constants
339344
constants = klass.constants
340345
assert !klass.constants.empty?
341346

347+
assert_equal @top_level, constants.first.file
348+
342349
constants = constants.map { |c| [c.name, c.value, c.comment] }
343350

344351
assert_equal ['PERFECT', '300', 'The highest possible score in bowling '],
@@ -754,6 +761,7 @@ def test_handle_method
754761
equals2 = bo.method_list.first
755762

756763
assert_equal '==', equals2.name
764+
assert_equal @top_level, equals2.file
757765
end
758766

759767
def test_handle_method_initialize

0 commit comments

Comments
 (0)