Class: RDoc::PuppetModule

Inherits:
NormalModule
  • Object
show all
Includes:
AddClassModuleComment
Defined in:
lib/puppet/util/rdoc/code_objects.rb

Overview

PuppetModule holds a Puppet Module This is mapped to an HTMLPuppetModule it leverage the RDoc (ruby) module infrastructure

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AddClassModuleComment

#add_comment

Constructor Details

#initialize(name, superclass = nil) ⇒ PuppetModule

Returns a new instance of PuppetModule.



33
34
35
36
37
38
# File 'lib/puppet/util/rdoc/code_objects.rb', line 33

def initialize(name, superclass = nil)
  @facts = []
  @plugins = []
  @nodes = {}
  super(name, superclass)
end

Instance Attribute Details

#factsObject

Returns the value of attribute facts.



31
32
33
# File 'lib/puppet/util/rdoc/code_objects.rb', line 31

def facts
  @facts
end

#pluginsObject

Returns the value of attribute plugins.



31
32
33
# File 'lib/puppet/util/rdoc/code_objects.rb', line 31

def plugins
  @plugins
end

Instance Method Details

#add_fact(fact) ⇒ Object



59
60
61
62
63
64
# File 'lib/puppet/util/rdoc/code_objects.rb', line 59

def add_fact(fact)
  @fact_container ||= add_module(NormalModule, "__facts__")
  confine_str = fact.confine.empty? ? '' : fact.confine.to_s
  const = Constant.new(fact.name, confine_str, fact.comment)
  @fact_container.add_constant(const)
end

#add_node(name, superclass) ⇒ Object

Adds a module called __nodes__ and adds nodes to it as classes



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/puppet/util/rdoc/code_objects.rb', line 68

def add_node(name, superclass)
  cls = @nodes[name]
  if cls
    return cls
  end

  @node_container ||= add_module(NormalModule, "__nodes__")
  cls = @node_container.add_class(PuppetNode, name, superclass)
  @nodes[name] = cls unless @done_documenting
  cls
end

#add_plugin(plugin) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/puppet/util/rdoc/code_objects.rb', line 40

def add_plugin(plugin)
  name = plugin.name
  type = plugin.type
  meth = AnyMethod.new("*args", name)
  meth.params = "(*args)"
  meth.visibility = :public
  meth.document_self = true
  meth.singleton = false
  meth.comment = plugin.comment
  case type
  when 'function'
    @function_container ||= add_module(NormalModule, "__functions__")
    @function_container.add_method(meth)
  when 'type'
    @type_container ||= add_module(NormalModule, "__types__")
    @type_container.add_method(meth)
  end
end

#each_factObject



80
81
82
# File 'lib/puppet/util/rdoc/code_objects.rb', line 80

def each_fact
  @facts.each { |c| yield c }
end

#each_nodeObject



88
89
90
# File 'lib/puppet/util/rdoc/code_objects.rb', line 88

def each_node
  @nodes.each { |c| yield c }
end

#each_pluginObject



84
85
86
# File 'lib/puppet/util/rdoc/code_objects.rb', line 84

def each_plugin
  @plugins.each { |c| yield c }
end

#nodesObject



92
93
94
# File 'lib/puppet/util/rdoc/code_objects.rb', line 92

def nodes
  @nodes.values
end