Class: RDoc::CodeObject
- Inherits:
-
Object
- Object
- RDoc::CodeObject
- Includes:
- Text
- Defined in:
- lib/rdoc/code_object.rb
Overview
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:
-
RDoc::Context
-
RDoc::TopLevel
-
RDoc::ClassModule
-
RDoc::AnonClass (never used so far)
-
RDoc::NormalClass
-
RDoc::NormalModule
-
RDoc::SingleClass
-
-
-
RDoc::MethodAttr
-
RDoc::Attr
-
RDoc::AnyMethod
-
RDoc::GhostMethod
-
RDoc::MetaMethod
-
-
-
RDoc::Alias
-
RDoc::Constant
-
RDoc::Require
-
RDoc::Include
Constant Summary
Constant Summary
Constants included from Text
Instance Attribute Summary (collapse)
-
- (Object) comment
Our comment.
-
- (Object) document_children
Do we document our children?.
-
- (Object) document_self
Do we document ourselves?.
-
- (Object) done_documenting
Are we done documenting (ie, did we come across a :enddoc:)?.
-
- (Object) file
readonly
Which file this code object was defined in.
-
- (Object) force_documentation
Force documentation of this CodeObject.
-
- (Object) line
Line in #file where this CodeObject was defined.
-
- (Object) metadata
readonly
Hash of arbitrary metadata for this CodeObject.
-
- (Object) offset
Offset in #file where this CodeObject was defined -- TODO character or byte?.
-
- (Object) parent
Our parent CodeObject.
-
- (Object) received_nodoc
readonly
Did we ever receive a :nodoc: directive?.
-
- (Object) section
Which section are we in.
-
- (Object) 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 (collapse)
-
- (Boolean) documented?
Does this object have a comment with content or is #received_nodoc true?.
-
- (Object) full_name=(full_name)
Sets the full_name overriding any computed full name.
-
- (CodeObject) initialize
constructor
Creates a new CodeObject that will document itself and its children.
-
- (Object) parent_file_name
File name of our parent.
-
- (Object) parent_name
Name of our parent.
-
- (Object) record_location(top_level)
Records the RDoc::TopLevel (file) where this code object was defined.
-
- (Object) start_doc
Enable capture of documentation unless documentation has been turned off by :endoc:.
-
- (Object) stop_doc
Disable capture of documentation.
Methods included from Text
encode_fallback, #expand_tabs, #flush_left, #markup, #normalize_comment, #parse, #strip_hashes, #strip_newlines, #strip_stars, #to_html, #wrap
Constructor Details
- (CodeObject) initialize
Creates a new CodeObject that will document itself and its children
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/rdoc/code_object.rb', line 105 def initialize @metadata = {} @comment = '' @parent = nil @file = nil @full_name = nil @document_children = true @document_self = true @done_documenting = false @force_documentation = false @received_nodoc = false end |
Instance Attribute Details
- (Object) comment
Our comment
36 37 38 |
# File 'lib/rdoc/code_object.rb', line 36 def comment @comment end |
- (Object) document_children
Do we document our children?
41 42 43 |
# File 'lib/rdoc/code_object.rb', line 41 def document_children @document_children end |
- (Object) document_self
Do we document ourselves?
46 47 48 |
# File 'lib/rdoc/code_object.rb', line 46 def document_self @document_self end |
- (Object) done_documenting
Are we done documenting (ie, did we come across a :enddoc:)?
51 52 53 |
# File 'lib/rdoc/code_object.rb', line 51 def done_documenting @done_documenting end |
- (Object) file (readonly)
Which file this code object was defined in
56 57 58 |
# File 'lib/rdoc/code_object.rb', line 56 def file @file end |
- (Object) force_documentation
Force documentation of this CodeObject
61 62 63 |
# File 'lib/rdoc/code_object.rb', line 61 def force_documentation @force_documentation end |
- (Object) line
Line in #file where this CodeObject was defined
66 67 68 |
# File 'lib/rdoc/code_object.rb', line 66 def line @line end |
- (Object) metadata (readonly)
Hash of arbitrary metadata for this CodeObject
71 72 73 |
# File 'lib/rdoc/code_object.rb', line 71 def @metadata end |
- (Object) offset
Offset in #file where this CodeObject was defined -- TODO character or byte?
78 79 80 |
# File 'lib/rdoc/code_object.rb', line 78 def offset @offset end |
- (Object) parent
Our parent CodeObject
83 84 85 |
# File 'lib/rdoc/code_object.rb', line 83 def parent @parent end |
- (Object) received_nodoc (readonly)
Did we ever receive a :nodoc: directive?
88 89 90 |
# File 'lib/rdoc/code_object.rb', line 88 def received_nodoc @received_nodoc end |
- (Object) section
Which section are we in
93 94 95 |
# File 'lib/rdoc/code_object.rb', line 93 def section @section end |
- (Object) 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.
100 101 102 |
# File 'lib/rdoc/code_object.rb', line 100 def viewer @viewer end |
Instance Method Details
- (Boolean) documented?
Does this object have a comment with content or is #received_nodoc true?
164 165 166 |
# File 'lib/rdoc/code_object.rb', line 164 def documented? @received_nodoc or !@comment.empty? end |
- (Object) full_name=(full_name)
Sets the full_name overriding any computed full name.
Set to nil to clear RDoc's cached value
198 199 200 |
# File 'lib/rdoc/code_object.rb', line 198 def full_name= full_name @full_name = full_name end |
- (Object) parent_file_name
File name of our parent
205 206 207 |
# File 'lib/rdoc/code_object.rb', line 205 def parent_file_name @parent ? @parent.base_name : '(unknown)' end |
- (Object) parent_name
Name of our parent
212 213 214 |
# File 'lib/rdoc/code_object.rb', line 212 def parent_name @parent ? @parent.full_name : '(unknown)' end |
- (Object) record_location(top_level)
Records the RDoc::TopLevel (file) where this code object was defined
219 220 221 |
# File 'lib/rdoc/code_object.rb', line 219 def record_location top_level @file = top_level end |
- (Object) start_doc
Enable capture of documentation unless documentation has been turned off by :endoc:
227 228 229 230 231 232 |
# File 'lib/rdoc/code_object.rb', line 227 def start_doc return if @done_documenting @document_self = true @document_children = true end |
- (Object) stop_doc
Disable capture of documentation
237 238 239 240 |
# File 'lib/rdoc/code_object.rb', line 237 def stop_doc @document_self = false @document_children = false end |