aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/any_method.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-02 00:32:30 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-02 00:32:30 +0000
commitcc2a16d94d744d14d4a5eb06eca22137f8a9b79e (patch)
tree2907a20e2d9ae3a2831707056bb3fe2d384b066d /lib/rdoc/any_method.rb
parent918f625a5eeba35b9b191cb39c1d634b4cc7efee (diff)
downloadruby-cc2a16d94d744d14d4a5eb06eca22137f8a9b79e.tar.gz
Import RDoc 3.5.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/any_method.rb')
-rw-r--r--lib/rdoc/any_method.rb45
1 files changed, 40 insertions, 5 deletions
diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb
index f993621f8b..5877ec9662 100644
--- a/lib/rdoc/any_method.rb
+++ b/lib/rdoc/any_method.rb
@@ -14,6 +14,11 @@ class RDoc::AnyMethod < RDoc::MethodAttr
attr_accessor :dont_rename_initialize
##
+ # The C function that implements this method (if it was defined in a C file)
+
+ attr_accessor :c_function
+
+ ##
# Different ways to call this method
attr_accessor :call_seq
@@ -31,8 +36,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
def initialize text, name
super
+ @c_function = nil
@dont_rename_initialize = false
- @token_stream = nil
+ @token_stream = nil
end
##
@@ -140,12 +146,41 @@ class RDoc::AnyMethod < RDoc::MethodAttr
end
##
- # Pretty parameter list for this method
+ # A list of this method's method and yield parameters. +call-seq+ params
+ # are preferred over parsed method and block params.
+
+ def param_list
+ if @call_seq then
+ params = @call_seq.split("\n").last
+ params = params.sub(/.*?\((.*)\)/, '\1')
+ params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2')
+ elsif @params then
+ params = @params.sub(/\((.*)\)/, '\1')
+
+ params << ",#{@block_params}" if @block_params
+ elsif @block_params then
+ params = @block_params
+ else
+ return []
+ end
+
+ params.gsub(/\s+/, '').split ','
+ end
+
+ ##
+ # Pretty parameter list for this method. If the method's parameters were
+ # given by +call-seq+ it is preferred over the parsed values.
def param_seq
- params = @params.gsub(/\s*\#.*/, '')
- params = params.tr("\n", " ").squeeze(" ")
- params = "(#{params})" unless params[0] == ?(
+ if @call_seq then
+ params = @call_seq.split("\n").last
+ params = params.sub(/[^( ]+/, '')
+ params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
+ else
+ params = @params.gsub(/\s*\#.*/, '')
+ params = params.tr("\n", " ").squeeze(" ")
+ params = "(#{params})" unless params[0] == ?(
+ end
if @block_params then
# If this method has explicit block parameters, remove any explicit