aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/any_method.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-10 06:36:13 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-10 06:36:13 +0000
commit1325437297539bf433904b64db63a3186e62177e (patch)
tree01608a107ec3939b1013152d961b6407a5ba9c25 /lib/rdoc/any_method.rb
parentce2b574017cacc2c3f2b0e92f82a7f250639fc34 (diff)
downloadruby-1325437297539bf433904b64db63a3186e62177e.tar.gz
* lib/rdoc: Import RDoc 2.5.2
* lib/rdoc/parser/ruby.rb (RDoc::Parser::Ruby): Don't parse rdoc files, reverts r24976 in favor of include directive support in C parser. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/any_method.rb')
-rw-r--r--lib/rdoc/any_method.rb32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb
index 5d291e82c8..f3f83363cd 100644
--- a/lib/rdoc/any_method.rb
+++ b/lib/rdoc/any_method.rb
@@ -6,7 +6,7 @@ require 'rdoc/tokenstream'
class RDoc::AnyMethod < RDoc::CodeObject
- MARSHAL_VERSION = 0 # :nodoc:
+ MARSHAL_VERSION = 1 # :nodoc:
include Comparable
@@ -58,7 +58,7 @@ class RDoc::AnyMethod < RDoc::CodeObject
##
# Parameters for this method
- attr_overridable :params, :param, :parameters, :parameter
+ attr_accessor :params
##
# Different ways to call this method
@@ -87,6 +87,7 @@ class RDoc::AnyMethod < RDoc::CodeObject
@call_seq = nil
@dont_rename_initialize = false
@is_alias_for = nil
+ @params = nil
@parent_name = nil
@singleton = nil
@token_stream = nil
@@ -111,6 +112,19 @@ class RDoc::AnyMethod < RDoc::CodeObject
end
##
+ # The call_seq or the param_seq with method name, if there is no call_seq.
+ #
+ # Use this for displaying a method's argument lists.
+
+ def arglists
+ if @call_seq then
+ @call_seq
+ elsif @params then
+ "#{name}#{param_seq}"
+ end
+ end
+
+ ##
# HTML id-friendly method name
def html_name
@@ -151,6 +165,7 @@ class RDoc::AnyMethod < RDoc::CodeObject
@call_seq,
@block_params,
aliases,
+ @params,
]
end
@@ -162,7 +177,6 @@ class RDoc::AnyMethod < RDoc::CodeObject
# * #parent_name
def marshal_load(array)
- @aliases = []
@dont_rename_initialize = nil
@is_alias_for = nil
@token_stream = nil
@@ -174,6 +188,8 @@ class RDoc::AnyMethod < RDoc::CodeObject
@comment = array[5]
@call_seq = array[6]
@block_params = array[7]
+ @aliases = array[8]
+ @params = array[9]
@parent_name = if @full_name =~ /#/ then
$`
@@ -201,16 +217,16 @@ class RDoc::AnyMethod < RDoc::CodeObject
# Pretty parameter list for this method
def param_seq
- params = params.gsub(/\s*\#.*/, '')
+ params = @params.gsub(/\s*\#.*/, '')
params = params.tr("\n", " ").squeeze(" ")
- params = "(#{params})" unless p[0] == ?(
+ params = "(#{params})" unless params[0] == ?(
- if block = block_params then # yes, =
+ if @block_params then
# If this method has explicit block parameters, remove any explicit
# &block
- params.sub!(/,?\s*&\w+/)
+ params.sub!(/,?\s*&\w+/, '')
- block.gsub!(/\s*\#.*/, '')
+ block = @block_params.gsub(/\s*\#.*/, '')
block = block.tr("\n", " ").squeeze(" ")
if block[0] == ?(
block.sub!(/^\(/, '').sub!(/\)/, '')