Skip to content
Browse files

Parse :method: comments ahead of define_method

Fixes #133

I'm not yet sure why I don't process all comments at nest == 1, but I'm
going to remain conservative.
  • Loading branch information...
1 parent db3f217 commit 1b2a8711a21904903d4d724a1a2686b1d7b097e3 @drbrain drbrain committed Jun 29, 2012
Showing with 22 additions and 2 deletions.
  1. +3 −1 History.rdoc
  2. +3 −1 lib/rdoc/parser/ruby.rb
  3. +16 −0 test/test_rdoc_parser_ruby.rb
View
4 History.rdoc
@@ -14,7 +14,7 @@
* RDoc markup format merges adjacent labels in a label or note list into a
single definition list item for output.
* RDoc now tracks use of extend. Pull request #118 by Michael Granger.
- * RDoc now tracks methods that use super. Pull request #130 by Erik
+ * RDoc now tracks methods that use super. Pull request #116 by Erik
Hollensbe.
* Bug fixes
@@ -36,6 +36,8 @@
toplevel methods. Pull Request #128 by Zachary Scott.
* Fixed test_gen_url test name in TestRDocMarkupToHtml. Pull Request #130
by Zachary Scott.
+ * Comment-defined methods ahead of define_method are now discovered. Issue
+ #133 by eclectic923
=== 3.12 / 2011-12-15
View
4 lib/rdoc/parser/ruby.rb
@@ -1364,7 +1364,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
non_comment_seen = true
end
- unget_tk tk # TODO peek instead of get then unget
+ unget_tk tk
keep_comment = true
when TkCLASS then
@@ -1426,6 +1426,8 @@ def parse_statements(container, single = NORMAL, current_method = nil,
parse_alias container, single, tk, comment
when 'require', 'include' then
# ignore
+ when 'define_method' then
+ try_parse_comment = true
else
if comment.text =~ /\A#\#$/ then
case comment.text
View
16 test/test_rdoc_parser_ruby.rb
@@ -1816,6 +1816,22 @@ def test_parse_statements_identifier_attr_accessor
assert_equal 'RW', foo.rw
end
+ def test_parse_statements_identifier_define_method
+ util_parser <<-RUBY
+class C
+ # :method: a
+ define_method :a do end
+ # :method: b
+ define_method :b do end
+end
+ RUBY
+
+ @parser.parse_statements @top_level
+ c = @top_level.classes.first
+
+ assert_equal %w[a b], c.method_list.map { |m| m.name }
+ end
+
def test_parse_statements_identifier_include
content = "class Foo\ninclude Bar\nend"

0 comments on commit 1b2a871

Please sign in to comment.
Something went wrong with that request. Please try again.