Method: RDoc::PuppetParserCore#parse_puppet_plugin

Defined in:
lib/puppet/util/rdoc/parser/puppet_parser_core.rb

#parse_puppet_plugin(container) ⇒ Object

this is a poor man puppet plugin parser :-) it doesn’t extract doc nor desc :-(



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/puppet/util/rdoc/parser/puppet_parser_core.rb', line 179

def parse_puppet_plugin(container)
  comments = ""
  current_plugin = nil

  File.open(@input_file_name) do |of|
    of.each do |line|
      # fetch comments
      if line =~ /^[ \t]*# ?(.*)$/
        comments += $1 + "\n"
      elsif line =~ /^[ \t]*(?:Puppet::Parser::Functions::)?newfunction[ \t]*\([ \t]*:(.*?)[ \t]*,[ \t]*:type[ \t]*=>[ \t]*(:rvalue|:lvalue)/
        current_plugin = RDoc::Plugin.new($1, "function")
        look_for_directives_in(container, comments) unless comments.empty?
        current_plugin.comment = comments
        current_plugin.record_location(@top_level)
        container.add_plugin(current_plugin)
        comments = ""
        Puppet.debug "rdoc: found new function plugins #{current_plugin.name}"
      elsif line =~ /^[ \t]*Puppet::Type.newtype[ \t]*\([ \t]*:(.*?)\)/
        current_plugin = RDoc::Plugin.new($1, "type")
        look_for_directives_in(container, comments) unless comments.empty?
        current_plugin.comment = comments
        current_plugin.record_location(@top_level)
        container.add_plugin(current_plugin)
        comments = ""
        Puppet.debug "rdoc: found new type plugins #{current_plugin.name}"
      elsif line =~ /module Puppet::Parser::Functions/
        # skip
      else # unknown line type
        comments =""
      end
    end
  end
end