@@ -13,25 +13,42 @@ module RDoc
1313
1414 class CodeObject
1515
16- attr_accessor :parent
16+ ##
17+ # Our comment
18+
19+ attr_reader :comment
1720
18- # We are the model of the code, but we know that at some point
19- # we will be worked on by viewers. By implementing the Viewable
20- # protocol, viewers can associated themselves with these objects.
21+ ##
22+ # Do we document our children?
2123
22- attr_accessor :viewer
24+ attr_reader :document_children
25+
26+ ##
27+ # Do we document ourselves?
28+
29+ attr_reader :document_self
2330
24- # are we done documenting (ie, did we come across a :enddoc:)?
31+ ##
32+ # Are we done documenting (ie, did we come across a :enddoc:)?
2533
2634 attr_accessor :done_documenting
2735
36+ ##
37+ # Our parent CodeObject
38+
39+ attr_accessor :parent
40+
41+ ##
2842 # Which section are we in
2943
3044 attr_accessor :section
3145
32- # do we document ourselves?
46+ ##
47+ # We are the model of the code, but we know that at some point we will be
48+ # worked on by viewers. By implementing the Viewable protocol, viewers can
49+ # associated themselves with these objects.
3350
34- attr_reader :document_self
51+ attr_accessor :viewer
3552
3653 def initialize
3754 @document_self = true
@@ -40,68 +57,86 @@ def initialize
4057 @done_documenting = false
4158 end
4259
43- def document_self = ( val )
44- @document_self = val
45- if !val
46- remove_methods_etc
47- end
60+ ##
61+ # Enables or disables documentation of this CodeObject. Calls
62+ # remove_methods_etc when disabling.
63+
64+ def document_self = ( document_self )
65+ @document_self = document_self
66+ remove_methods_etc unless document_self
4867 end
4968
50- # set and cleared by :startdoc: and :enddoc:, this is used to toggle
51- # the capturing of documentation
69+ ##
70+ # Enable capture of documentation
71+
5272 def start_doc
5373 @document_self = true
5474 @document_children = true
5575 end
5676
77+ ##
78+ # Disable capture of documentation
79+
5780 def stop_doc
5881 @document_self = false
5982 @document_children = false
6083 end
6184
62- # do we document ourselves and our children
63-
64- attr_reader :document_children
85+ ##
86+ # Enables or disables documentation of this CodeObject's children. Calls
87+ # remove_classes_and_modules when disabling.
6588
66- def document_children = ( val )
67- @document_children = val
68- if !val
69- remove_classes_and_modules
70- end
89+ def document_children = ( document_children )
90+ @document_children = document_children
91+ remove_classes_and_modules unless document_children
7192 end
7293
73- # Do we _force_ documentation, even is we wouldn't normally show the entity
94+ ##
95+ # Force documentation of this CodeObject
96+
7497 attr_accessor :force_documentation
7598
99+ ##
100+ # File name of our parent
101+
76102 def parent_file_name
77103 @parent ? @parent . file_base_name : '(unknown)'
78104 end
79105
106+ ##
107+ # Name of our parent
108+
80109 def parent_name
81110 @parent ? @parent . name : '(unknown)'
82111 end
83112
84- # Default callbacks to nothing, but this is overridden for classes
85- # and modules
113+ ##
114+ # Callback called upon disabling documentation of children. See
115+ # #document_children=
116+
86117 def remove_classes_and_modules
87118 end
88119
120+ ##
121+ # Callback called upon disabling documentation of ourself. See
122+ # #document_self=
123+
89124 def remove_methods_etc
90125 end
91126
92- # Access the code object's comment
93- attr_reader : comment
127+ ##
128+ # Replaces our comment with +comment+, unless it is empty.
94129
95- # Update the comment, but don't overwrite a real comment with an empty one
96130 def comment = ( comment )
97131 @comment = comment unless comment . empty?
98132 end
99133
134+ ##
100135 # There's a wee trick we pull. Comment blocks can have directives that
101136 # override the stuff we extract during the parse. So, we have a special
102- # class method, attr_overridable, that lets code objects list
103- # those directives. Wehn a comment is assigned, we then extract
104- # out any matching directives and update our object
137+ # class method, attr_overridable, that lets code objects list those
138+ # directives. When a comment is assigned, we then extract out any matching
139+ # directives and update our object
105140
106141 def self . attr_overridable ( name , *aliases )
107142 @overridables ||= { }
0 commit comments