Class: PuppetReadmeGenerator::ClassAbstract

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

Direct Known Subclasses

Class, DefinedType

Instance Method Summary collapse

Constructor Details

#initialize(c) ⇒ ClassAbstract

Returns a new instance of ClassAbstract.



88
89
90
# File 'lib/puppet_readme_generator.rb', line 88

def initialize(c)
  @c = c
end

Instance Method Details

#defaultsObject



141
142
143
# File 'lib/puppet_readme_generator.rb', line 141

def defaults
  @c['defaults']
end

#examplesObject



100
101
102
103
104
105
106
107
108
109
# File 'lib/puppet_readme_generator.rb', line 100

def examples
  if @examples.nil?
    @examples = []
    @c['docstring']['tags'].each do |t|
      next unless t['tag_name'] == 'example'
      @examples << Example.new(t, self)
    end
  end
  @examples
end

#markdownObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/puppet_readme_generator.rb', line 122

def markdown
  output = []
  output << "### `#{@c['name']}`\n"
  output << text
  output << ''

  output << "#### Parameters\n"
  params.each do |p|
    output << p.markdown
  end

  output << "#### Examples\n"
  examples.each do |e|
    output << e.markdown
  end

  output.join("\n")
end

#nameObject



92
93
94
# File 'lib/puppet_readme_generator.rb', line 92

def name
  @c['name']
end

#paramsObject



111
112
113
114
115
116
117
118
119
120
# File 'lib/puppet_readme_generator.rb', line 111

def params
  if @params.nil?
    @params = []
    @c['docstring']['tags'].each do |t|
      next unless t['tag_name'] == 'param'
      @params << Param.new(t, self)
    end
  end
  @params
end

#textObject



96
97
98
# File 'lib/puppet_readme_generator.rb', line 96

def text
  @c['docstring']['text']
end