diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-20 06:23:28 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-20 06:23:28 +0000 |
commit | a6ed298df738b21b21ed2073bd89bb65565848f7 (patch) | |
tree | 25acf6653e5f4ac71aa8d917aadef40dbf3db140 /lib/rdoc/parser/ruby.rb | |
parent | d3d00ab8fe750551219655ab5cce0aee77efbe44 (diff) | |
download | ruby-a6ed298df738b21b21ed2073bd89bb65565848f7.tar.gz |
* lib/rdoc/parser/ruby.rb: Ignore methods defined on constants to
prevent modules with the names of constants from appearing in the
documentation.
* test/rdoc/test_rdoc_parser_ruby.rb: Test for the above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/parser/ruby.rb')
-rw-r--r-- | lib/rdoc/parser/ruby.rb | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index d42b70b516..bfddd53270 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -1116,6 +1116,18 @@ class RDoc::Parser::Ruby < RDoc::Parser name = name_t2.name prev_container = container container = container.find_module_named(name_t.name) + + unless container then + constant = prev_container.constants.find do |const| + const.name == name_t.name + end + + if constant then + parse_method_dummy prev_container + return + end + end + unless container then added_container = true obj = name_t.name.split("::").inject(Object) do |state, item| @@ -1138,10 +1150,7 @@ class RDoc::Parser::Ruby < RDoc::Parser container.record_location @top_level end when TkIDENTIFIER, TkIVAR, TkGVAR then - dummy = RDoc::Context.new - dummy.parent = container - dummy.store = container.store - skip_method dummy + parse_method_dummy container return when TkTRUE, TkFALSE, TkNIL then klass_name = "#{name_t.name.capitalize}Class" @@ -1229,6 +1238,16 @@ class RDoc::Parser::Ruby < RDoc::Parser end ## + # Parses a method that needs to be ignored. + + def parse_method_dummy container + dummy = RDoc::Context.new + dummy.parent = container + dummy.store = container.store + skip_method dummy + end + + ## # Extracts +yield+ parameters from +method+ def parse_method_or_yield_parameters(method = nil, |