5
# Base class for the RDoc code tree.
7
# We contain the common stuff for contexts (which are containers) and other
8
# elements (methods, attributes and so on)
10
# Here's the tree of the CodeObject subclasses:
17
# * RDoc::NormalModule
28
class RDoc::CodeObject
38
# Do we document our children?
40
attr_reader :document_children
43
# Do we document ourselves?
45
attr_reader :document_self
48
# Are we done documenting (ie, did we come across a :enddoc:)?
50
attr_accessor :done_documenting
53
# Force documentation of this CodeObject
55
attr_accessor :force_documentation
58
# Hash of arbitrary metadata for this CodeObject
63
# Our parent CodeObject
68
# Which section are we in
70
attr_accessor :section
73
# We are the model of the code, but we know that at some point we will be
74
# worked on by viewers. By implementing the Viewable protocol, viewers can
75
# associated themselves with these objects.
80
# Creates a new CodeObject that will document itself and its children
86
@document_children = true
88
@done_documenting = false
89
@force_documentation = false
95
# Replaces our comment with +comment+, unless it is empty.
98
@comment = case comment
100
when RDoc::Markup::Document then comment
102
if comment and not comment.empty? then
103
normalize_comment comment
111
# Enables or disables documentation of this CodeObject's children. Calls
112
# remove_classes_and_modules when disabling.
114
def document_children=(document_children)
115
@document_children = document_children
116
remove_classes_and_modules unless document_children
120
# Enables or disables documentation of this CodeObject. Calls
121
# remove_methods_etc when disabling.
123
def document_self=(document_self)
124
@document_self = document_self
125
remove_methods_etc unless document_self
129
# Does this class have a comment with content or is document_self false.
132
!(@document_self and @comment.empty?)
136
# File name of our parent
139
@parent ? @parent.base_name : '(unknown)'
146
@parent ? @parent.full_name : '(unknown)'
150
# Callback called upon disabling documentation of children. See
151
# #document_children=
153
def remove_classes_and_modules
157
# Callback called upon disabling documentation of ourself. See
160
def remove_methods_etc
164
# Enable capture of documentation
167
@document_self = true
168
@document_children = true
172
# Disable capture of documentation
175
@document_self = false
176
@document_children = false