2014-05-23 04:02:35 +00:00
|
|
|
require 'yard'
|
|
|
|
require 'puppet/pops'
|
2014-05-24 19:54:22 +00:00
|
|
|
|
|
|
|
require_relative '../../yardoc'
|
|
|
|
require_relative '../pops/yard_transformer'
|
2014-05-23 04:02:35 +00:00
|
|
|
|
|
|
|
module Puppetx::Yardoc::YARD
|
|
|
|
class PuppetParser < YARD::Parser::Base
|
|
|
|
attr_reader :file, :source
|
|
|
|
|
|
|
|
def initialize(source, filename)
|
|
|
|
@source = source
|
|
|
|
@file = filename
|
|
|
|
|
|
|
|
@parser = Puppet::Pops::Parser::Parser.new()
|
|
|
|
@transformer = Puppetx::Yardoc::Pops::YARDTransformer.new()
|
|
|
|
end
|
|
|
|
|
|
|
|
def parse
|
|
|
|
@parse_result ||= @parser.parse_string(source)
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def enumerator
|
2014-06-03 02:04:19 +00:00
|
|
|
statements = @transformer.transform(@parse_result)
|
|
|
|
|
|
|
|
# Ensure an array is returned and prune any nil values.
|
|
|
|
Array(statements).compact
|
2014-05-23 04:02:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|