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.



108
109
110
# File 'lib/puppet_readme_generator.rb', line 108

def initialize(c)
  @c = c
end

Instance Method Details

#defaultsObject



171
172
173
# File 'lib/puppet_readme_generator.rb', line 171

def defaults
  @c['defaults']
end

#examplesObject



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/puppet_readme_generator.rb', line 120

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

#markdownObject



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/puppet_readme_generator.rb', line 148

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

  if params.length > 0
    output << "#### Parameters\n"
    params.each do |p|
      output << p.markdown
    end
  end

  if examples.length > 0
    output << "#### Examples\n"
    examples.each do |e|
      output << e.markdown
    end
  end

  output.join("\n")
end

#nameObject



112
113
114
# File 'lib/puppet_readme_generator.rb', line 112

def name
  @c['name']
end

#paramsObject



134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/puppet_readme_generator.rb', line 134

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

#textObject



116
117
118
# File 'lib/puppet_readme_generator.rb', line 116

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