Abstract class representing either a method or an attribute.
- #
- A
- B
- D
- F
- H
- N
- O
- P
- S
- T
Attributes
[R] | aliases |
|
[R] | arglists | The |
[R] | block_params | Parameters yielded by the called block |
[RW] | call_seq | Different ways to call this method |
[RW] | is_alias_for | The method/attribute we’re aliasing |
[RW] | name | Name of this method/attribute. |
[R] | param_seq | Pretty parameter list for this method |
[RW] | params | Parameters for this method |
[RW] | singleton | Is this a singleton method/attribute? |
[R] | text | Source file token stream |
[RW] | visibility | public, protected, private |
Class Public methods
new(text, name) Link
Creates a new MethodAttr
from token stream text
and method or attribute name name
.
Usually this is called by super from a subclass.
# File ruby/lib/rdoc/method_attr.rb, line 78 def initialize text, name super() @text = text @name = name @aliases = [] @is_alias_for = nil @parent_name = nil @singleton = nil @visibility = :public @see = false @arglists = nil @block_params = nil @call_seq = nil @param_seq = nil @params = nil end
Instance Public methods
<=>(other) Link
add_alias(an_alias, context) Link
Abstract method. Contexts in their building phase call this to register a new alias for this known method/attribute.
-
creates a new AnyMethod/Attribute named
an_alias.new_name
; -
adds
self
as an alias for the new method or attribute -
adds the method or attribute to
aliases
-
adds the method or attribute to
context
.
aref() Link
HTML fragment reference for this method
aref_prefix() Link
Prefix for aref
, defined by subclasses.
block_params=(value) Link
Attempts to sanitize the content passed by the Ruby parser: remove outer parentheses, etc.
# File ruby/lib/rdoc/method_attr.rb, line 233 def block_params=(value) # 'yield.to_s' or 'assert yield, msg' return @block_params = '' if value =~ /^[\.,]/ # remove trailing 'if/unless ...' return @block_params = '' if value =~ /^(if|unless)\s/ value = $1.strip if value =~ /^(.+)\s(if|unless)\s/ # outer parentheses value = $1 if value =~ /^\s*\((.*)\)\s*$/ value = value.strip # proc/lambda return @block_params = $1 if value =~ /^(proc|lambda)(\s*\{|\sdo)/ # surrounding +...+ or [...] value = $1.strip if value =~ /^\+(.*)\+$/ value = $1.strip if value =~ /^\[(.*)\]$/ return @block_params = '' if value.empty? # global variable return @block_params = 'str' if value =~ /^\$[&0-9]$/ # wipe out array/hash indices value.gsub!(/(\w)\[[^\[]+\]/, '\1') # remove @ from class/instance variables value.gsub!(/@@?([a-z0-9_]+)/, '\1') # method calls => method name value.gsub!(/([A-Z:a-z0-9_]+)\.([a-z0-9_]+)(\s*\(\s*[a-z0-9_.,\s]*\s*\)\s*)?/) do case $2 when 'to_s' then $1 when 'const_get' then 'const' when 'new' then $1.split('::').last. # ClassName => class_name gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). downcase else $2 end end # class prefixes value.gsub!(/[A-Za-z0-9_:]+::/, '') # simple expressions value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/ @block_params = value.strip end
documented?() Link
A method/attribute is documented if any of the following is true:
-
it was marked with :nodoc:;
-
it has a comment;
-
it is an alias for a documented method;
-
it has a
#see
method that is documented.
full_name() Link
Full method/attribute name including namespace
html_name() Link
HTML id-friendly method/attribute name
name_prefix() Link
‘::’ for a class method/attribute, ‘#’ for an instance method.
output_name(context) Link
Name for output to HTML. For class methods the full name with a “.” is used like SomeClass.method_name
. For instance methods the class name is used if context
does not match the parent.
- This is to help prevent people from using
-
to call class methods.
parent_name() Link
Name of our parent with special handling for un-marshaled methods
path() Link
Path to this method for use with HTML generator output.
pretty_name() Link
Method/attribute name with class/instance indicator
search_record() Link
Used by RDoc::Generator::JsonIndex to create a record for the search engine.
see() Link
A method/attribute to look at, in particular if this method/attribute has no documentation.
It can be a method/attribute of the superclass or of an included module, including the Kernel
module, which is always appended to the included modules.
Returns nil
if there is no such method/attribute. The #is_alias_for
method/attribute, if any, is not included.
Templates may generate a “see also …” if this method/attribute has documentation, and “see …” if it does not.
store=(store) Link
Sets the store for this class or module and its contained code objects.