Base class for the RDoc code tree.
We contain the common stuff for contexts (which are containers) and other elements (methods, attributes and so on)
Here's the tree of the CodeObject subclasses:
- C
- D
- E
- F
- I
- N
- P
- R
- S
[R] | comment | Our comment |
[R] | document_children | Do we document our children? |
[R] | document_self | Do we document ourselves? |
[R] | done_documenting | Are we done documenting (ie, did we come across a :enddoc:)? |
[R] | file | Which file this code object was defined in |
[R] | force_documentation | Force documentation of this CodeObject |
[RW] | line | Line in file where this CodeObject was defined |
[R] | metadata | Hash of arbitrary metadata for this CodeObject |
[RW] | offset | Offset in file where this CodeObject was defined |
[W] | parent | Sets the parent CodeObject |
[R] | received_nodoc | Did we ever receive a |
[W] | section | Set the section this CodeObject is in |
[RW] | store | The RDoc::Store for this object. |
[RW] | viewer | We are the model of the code, but we know that at some point we will be worked on by viewers. By implementing the Viewable protocol, viewers can associated themselves with these objects. |
Creates a new CodeObject that will document itself and its children
# File lib/rdoc/code_object.rb, line 107 def initialize @metadata = {} @comment = '' @parent = nil @parent_name = nil # for loading @parent_class = nil # for loading @section = nil @section_title = nil # for loading @file = nil @full_name = nil @store = nil initialize_visibility end
Replaces our comment with comment
, unless it is empty.
# File lib/rdoc/code_object.rb, line 137 def comment=(comment) @comment = case comment when NilClass then '' when RDoc::Markup::Document then comment when RDoc::Comment then comment.normalize else if comment and not comment.empty? then normalize_comment comment else # HACK correct fix is to have #initialize create @comment # with the correct encoding if String === @comment and Object.const_defined? :Encoding and @comment.empty? then @comment.force_encoding comment.encoding end @comment end end end
Should this CodeObject be shown in documentation?
Enables or disables documentation of this CodeObject's children unless it has been turned off by :enddoc:
Enables or disables documentation of this CodeObject unless it has been turned off by
:enddoc:. If the argument is nil
it means the documentation
is turned off by :nodoc:
.
Does this object have a comment with content or is received_nodoc true?
Turns documentation on/off, and turns on/off document_self and document_children.
Once documentation has been turned off (by :enddoc:
), the
object will refuse to turn document_self or document_children
on, so :doc:
and :start_doc:
directives will have
no effect in the current file.
Yields each parent of this CodeObject. See also RDoc::ClassModule#each_ancestor
File name where this CodeObject was found.
See also RDoc::Context#in_files
Force the documentation of this object unless documentation has been turned off by :enddoc:
Sets the full_name overriding any computed full name.
Set to nil
to clear RDoc's
cached value
Use this to ignore a CodeObject and all its children until found again (#record_location is called). An ignored item will not be shown in documentation.
See github issue #55
The ignored status is temporary in order to allow implementation details to be hidden. At the end of processing a file RDoc allows all classes and modules to add new documentation to previously created classes.
If a class was ignored (via stopdoc) then reopened later with additional documentation it should be shown. If a class was ignored and never reopened it should not be shown. The ignore flag allows this to occur.
Has this class been ignored?
Our parent CodeObject. The parent may be missing for classes loaded from legacy RI data stores.
# File lib/rdoc/code_object.rb, line 282 def parent return @parent if @parent return nil unless @parent_name if @parent_class == RDoc::TopLevel then @parent = @store.add_file @parent_name else @parent = @store.find_class_or_module @parent_name return @parent if @parent begin @parent = @store.load_class @parent_name rescue RDoc::Store::MissingFileError nil end end end
Name of our parent
Records the RDoc::TopLevel (file) where this code object was defined
The section this CodeObject is in. Sections allow grouping of constants, attributes and methods inside a class or module.
Enable capture of documentation unless documentation has been turned off by :enddoc: