Class: RDoc::Attr
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
MethodAttr,
CodeObject
|
|
Instance Chain:
|
|
Inherits: |
RDoc::MethodAttr
|
Defined in: | lib/rdoc/attr.rb |
Overview
An attribute created by #attr, #attr_reader, #attr_writer or #attr_accessor
Constant Summary
-
MARSHAL_VERSION =
Internal use only
- 3
-
RDoc 4
Added parent name and class Added section title
3
Text - Included
Class Attribute Summary
MethodAttr - Inherited
.add_line_numbers | Allows controlling whether |
Class Method Summary
-
.new(text, name, rw, comment, singleton = false) ⇒ Attr
constructor
Creates a new
Attr
with bodytext
,name
, read/write status #rw andcomment
.
MethodAttr - Inherited
.new | Creates a new MethodAttr from token stream |
CodeObject - Inherited
.new | Creates a new CodeObject that will document itself and its children. |
Instance Attribute Summary
-
#rw
rw
Is the attribute readable ('R'), writable ('W') or both ('RW')?
MethodAttr - Inherited
#aliases | Array of other names for this method/attribute. |
#arglists | The call_seq or the param_seq with method name, if there is no call_seq. |
#block_params | Parameters yielded by the called block. |
#block_params= | Attempts to sanitize the content passed by the Ruby parser: remove outer parentheses, etc. |
#call_seq | Different ways to call this method. |
#documented? | 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 |
#is_alias_for | The method/attribute we're aliasing. |
#name | Name of this method/attribute. |
#param_seq | Pretty parameter list for this method. |
#params | Parameters for this method. |
#singleton | Is this a singleton method/attribute? |
#store= | Sets the store for this class or module and its contained code objects. |
#text | Source file token stream. |
#visibility | public, protected, private. |
CodeObject - Inherited
#comment | Our comment. |
#comment= | Replaces our comment with |
#display? | Should this CodeObject be displayed in output? |
#document_children | Do we document our children? |
#document_children= | Enables or disables documentation of this CodeObject's children unless it has been turned off by :enddoc: |
#document_self | Do we document ourselves? |
#document_self= | Enables or disables documentation of this CodeObject unless it has been turned off by :enddoc:. |
#documented? | Does this object have a comment with content or is |
#done_documenting | Are we done documenting (ie, did we come across a :enddoc:)? |
#done_documenting= | Turns documentation on/off, and turns on/off |
#file | Which file this code object was defined in. |
#force_documentation | Force documentation of this CodeObject. |
#force_documentation= | Force the documentation of this object unless documentation has been turned off by :enddoc: |
#full_name= | Sets the full_name overriding any computed full name. |
#ignored? | Has this class been ignored? |
#line | Line in |
#metadata | Hash of arbitrary metadata for this CodeObject. |
#parent | Our parent CodeObject. |
#parent= | Sets the parent CodeObject. |
#received_nodoc | Did we ever receive a |
#section | The section this CodeObject is in. |
#section= | Set the section this CodeObject is in. |
#store | The Store for this object. |
#store= | Sets the |
#suppressed? | Has this class been suppressed? |
#viewer | We are the model of the code, but we know that at some point we will be worked on by viewers. |
Instance Method Summary
-
#==(other)
Attributes are equal when their names, singleton and rw are identical.
-
#add_alias(an_alias, context)
Add
an_alias
as an attribute incontext
. -
#aref_prefix
The
#aref
prefix for attributes. -
#definition
Returns attr_reader, attr_writer or attr_accessor as appropriate.
-
#marshal_dump
Dumps this
Attr
for use by ri. -
#marshal_load(array)
Loads this
Attr
fromarray
. -
#calls_super
Internal use only
Attributes never call super.
- #inspect Internal use only
- #pretty_print(q) Internal use only
- #to_s Internal use only
-
#token_stream
Internal use only
Attributes do not have token streams.
MethodAttr - Inherited
#<=> | Order by |
#add_alias | Abstract method. |
#add_line_numbers | Prepend |
#aref | HTML fragment reference for this method. |
#aref_prefix | Prefix for |
#full_name | Full method/attribute name including namespace. |
#html_name | HTML id-friendly method/attribute name. |
#markup_code | Turns the method's token stream into HTML. |
#name_prefix | '::' for a class method/attribute, '#' for an instance method. |
#output_name | Name for output to HTML. |
#parent_name | Name of our parent with special handling for un-marshaled methods. |
#path | Path to this method for use with HTML generator output. |
#pretty_name | Method/attribute name with class/instance indicator. |
#search_record | Used by Generator::JsonIndex to create a record for the search engine. |
#see | A method/attribute to look at, in particular if this method/attribute has no documentation. |
#type | Type of method/attribute (class or instance). |
#==, #find_method_or_attribute, #find_see, | |
#initialize_copy | Resets cached data for the object so it can be rebuilt by accessor methods. |
#initialize_visibility, #inspect, #pretty_print, #to_s |
CodeObject - Inherited
#each_parent | Yields each parent of this CodeObject. |
#file_name | File name where this CodeObject was found. |
#ignore | Use this to ignore a CodeObject and all its children until found again (#record_location is called). |
#options | The options instance from the store this CodeObject is attached to, or a default options instance if the CodeObject is not attached. |
#parent_file_name | File name of our parent. |
#parent_name | Name of our parent. |
#record_location | Records the TopLevel (file) where this code object was defined. |
#start_doc | Enable capture of documentation unless documentation has been turned off by :enddoc: |
#stop_doc | Disable capture of documentation. |
#suppress | Use this to suppress a CodeObject and all its children until the next file it is seen in or documentation is discovered. |
#initialize_visibility | Initializes state for visibility of this CodeObject and its children. |
Generator::Markup - Included
#aref_to | Generates a relative URL from this object's path to |
#as_href | Generates a relative URL from |
#cvs_url | Build a webcvs URL starting for the given |
#description | Handy wrapper for marking up this object's comment. |
#formatter | Creates an Markup::ToHtmlCrossref formatter. |
Text - Included
#expand_tabs | Expands tab characters in |
#flush_left | Flush |
#markup | Convert a string in markup format into HTML. |
#normalize_comment | Strips hashes, expands tabs then flushes |
#parse | Normalizes |
#snippet | The first |
#strip_hashes | Strips leading # characters from |
#strip_newlines | Strips leading and trailing n characters from |
#strip_stars | Strips /* */ style comments. |
#to_html | Converts ampersand, dashes, ellipsis, quotes, copyright and registered trademark symbols in |
#wrap | Wraps |
Constructor Details
.new(text, name, rw, comment, singleton = false) ⇒ Attr
Creates a new Attr
with body text
, name
, read/write status #rw and comment
. singleton
marks this as a class attribute.
Instance Attribute Details
#rw (rw)
Is the attribute readable ('R'), writable ('W') or both ('RW')?
# File 'lib/rdoc/attr.rb', line 19
attr_accessor :rw
Instance Method Details
#==(other)
Attributes are equal when their names, singleton and rw are identical
#add_alias(an_alias, context)
Add an_alias
as an attribute in context
.
# File 'lib/rdoc/attr.rb', line 46
def add_alias(an_alias, context) new_attr = self.class.new(self.text, an_alias.new_name, self.rw, self.comment, self.singleton) new_attr.record_location an_alias.file new_attr.visibility = self.visibility new_attr.is_alias_for = self @aliases << new_attr context.add_attribute new_attr new_attr end
#aref_prefix
The #aref
prefix for attributes
# File 'lib/rdoc/attr.rb', line 61
def aref_prefix 'attribute' end
#calls_super
Attributes never call super. See AnyMethod#calls_super
An Attr
can show up in the method list in some situations (see Gem::ConfigFile
)
# File 'lib/rdoc/attr.rb', line 71
def calls_super # :nodoc: false end
#definition
Returns attr_reader, attr_writer or attr_accessor as appropriate.
# File 'lib/rdoc/attr.rb', line 78
def definition case @rw when 'RW' then 'attr_accessor' when 'R' then 'attr_reader' when 'W' then 'attr_writer' end end
#inspect
# File 'lib/rdoc/attr.rb', line 86
def inspect # :nodoc: alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil visibility = self.visibility visibility = "forced #{visibility}" if force_documentation "#<%s:0x%x %s %s (%s)%s>" % [ self.class, object_id, full_name, rw, visibility, alias_for, ] end
#marshal_dump
Dumps this Attr
for use by ri. See also #marshal_load
# File 'lib/rdoc/attr.rb', line 102
def marshal_dump [ MARSHAL_VERSION, @name, full_name, @rw, @visibility, parse(@comment), singleton, @file.relative_name, @parent.full_name, @parent.class, @section.title ] end
#marshal_load(array)
Loads this Attr
from array
. For a loaded Attr
the following methods will return cached values:
-
#full_name
-
#parent_name
# File 'lib/rdoc/attr.rb', line 124
def marshal_load array initialize_visibility @aliases = [] @parent = nil @parent_name = nil @parent_class = nil @section = nil @file = nil version = array[0] @name = array[1] @full_name = array[2] @rw = array[3] @visibility = array[4] @comment = array[5] @singleton = array[6] || false # MARSHAL_VERSION == 0 # 7 handled below @parent_name = array[8] @parent_class = array[9] @section_title = array[10] @file = RDoc::TopLevel.new array[7] if version > 1 @parent_name ||= @full_name.split('#', 2).first end
#pretty_print(q)
# File 'lib/rdoc/attr.rb', line 151
def pretty_print q # :nodoc: q.group 2, "[#{self.class.name} #{full_name} #{rw} #{visibility}", "]" do unless comment.empty? then q.breakable q.text "comment:" q.breakable q.pp @comment end end end
#to_s
# File 'lib/rdoc/attr.rb', line 162
def to_s # :nodoc: "#{definition} #{name} in: #{parent}" end
#token_stream
Attributes do not have token streams.
An Attr
can show up in the method list in some situations (see Gem::ConfigFile
)
# File 'lib/rdoc/attr.rb', line 172
def token_stream # :nodoc: end