Class: RDoc::CodeObject

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/code_objects.rb

Overview

We contain the common stuff for contexts (which are containers) and other elements (methods, attributes and so on)

Direct Known Subclasses

Alias, AnyMethod, Attr, Constant, Context, Include, Require

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCodeObject

Returns a new instance of CodeObject.



75
76
77
78
79
80
# File 'lib/rdoc/code_objects.rb', line 75

def initialize
  @document_self = true
  @document_children = true
  @force_documentation = false
  @done_documenting = false
end

Instance Attribute Details

#commentObject

Access the code object's comment



83
84
85
# File 'lib/rdoc/code_objects.rb', line 83

def comment
  @comment
end

#document_childrenObject

do we document ourselves and our children



55
56
57
# File 'lib/rdoc/code_objects.rb', line 55

def document_children
  @document_children
end

#document_selfObject

do we document ourselves?



32
33
34
# File 'lib/rdoc/code_objects.rb', line 32

def document_self
  @document_self
end

#done_documentingObject

are we done documenting (ie, did we come across a :enddoc:)?



24
25
26
# File 'lib/rdoc/code_objects.rb', line 24

def done_documenting
  @done_documenting
end

#force_documentationObject

Do we force documentation, even is we wouldn't normally show the entity



65
66
67
# File 'lib/rdoc/code_objects.rb', line 65

def force_documentation
  @force_documentation
end

#parentObject

Returns the value of attribute parent



14
15
16
# File 'lib/rdoc/code_objects.rb', line 14

def parent
  @parent
end

#sectionObject

Which section are we in



28
29
30
# File 'lib/rdoc/code_objects.rb', line 28

def section
  @section
end

#viewerObject

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.



20
21
22
# File 'lib/rdoc/code_objects.rb', line 20

def viewer
  @viewer
end

Class Method Details

.attr_overridable(name, *aliases) ⇒ Object

There's a wee trick we pull. Comment blocks can have directives that override the stuff we extract during the parse. So, we have a special class method, attr_overridable, that lets code objects list those directives. Wehn a comment is assigned, we then extract out any matching directives and update our object



97
98
99
100
101
102
103
104
105
106
# File 'lib/rdoc/code_objects.rb', line 97

def CodeObject.attr_overridable(name, *aliases)
  @overridables ||= {}

  attr_accessor name

  aliases.unshift name
  aliases.each do |directive_name|
    @overridables[directive_name.to_s] = name
  end
end

Instance Method Details

#remove_classes_and_modulesObject

Default callbacks to nothing, but this is overridden for classes and modules



69
70
# File 'lib/rdoc/code_objects.rb', line 69

def remove_classes_and_modules
end

#remove_methods_etcObject



72
73
# File 'lib/rdoc/code_objects.rb', line 72

def remove_methods_etc
end

#start_docObject

set and cleared by :startdoc: and :enddoc:, this is used to toggle the capturing of documentation



43
44
45
46
# File 'lib/rdoc/code_objects.rb', line 43

def start_doc
  @document_self = true
  @document_children = true
end

#stop_docObject



48
49
50
51
# File 'lib/rdoc/code_objects.rb', line 48

def stop_doc
  @document_self = false
  @document_children = false
end