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.



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

def initialize(c)
  @c = c
end

Instance Method Details

#defaultsObject



175
176
177
# File 'lib/puppet_readme_generator.rb', line 175

def defaults
  @c['defaults']
end

#examplesObject



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

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



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/puppet_readme_generator.rb', line 152

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



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

def name
  @c['name']
end

#paramsObject



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/puppet_readme_generator.rb', line 138

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



120
121
122
# File 'lib/puppet_readme_generator.rb', line 120

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