From c56bc426be2c6fe125c52c1c9bb89c56ce4fc2ba Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Thu, 22 May 2014 23:45:08 -0700 Subject: [PATCH] Add simple handlers Add a base handler class and a handler that processes `HostClassDefinition` instances. --- lib/puppetx/yardoc/yard/handlers.rb | 2 ++ lib/puppetx/yardoc/yard/handlers/base.rb | 14 ++++++++++++++ .../yardoc/yard/handlers/host_class_handler.rb | 11 +++++++++++ 3 files changed, 27 insertions(+) create mode 100644 lib/puppetx/yardoc/yard/handlers.rb create mode 100644 lib/puppetx/yardoc/yard/handlers/base.rb create mode 100644 lib/puppetx/yardoc/yard/handlers/host_class_handler.rb diff --git a/lib/puppetx/yardoc/yard/handlers.rb b/lib/puppetx/yardoc/yard/handlers.rb new file mode 100644 index 0000000..085dc55 --- /dev/null +++ b/lib/puppetx/yardoc/yard/handlers.rb @@ -0,0 +1,2 @@ +require_relative 'handlers/base' +require_relative 'handlers/host_class_handler' diff --git a/lib/puppetx/yardoc/yard/handlers/base.rb b/lib/puppetx/yardoc/yard/handlers/base.rb new file mode 100644 index 0000000..b23e58b --- /dev/null +++ b/lib/puppetx/yardoc/yard/handlers/base.rb @@ -0,0 +1,14 @@ +require 'puppetx/yardoc' +require 'yard' +require 'puppet/pops' + +module Puppetx::Yardoc::YARD::Handlers + class Base < YARD::Handlers::Base + include Puppet::Pops::Model # This allows handlers to match based on model classes. + + def self.handles?(statement) + handlers.any? {|h| h == statement.type} + end + + end +end diff --git a/lib/puppetx/yardoc/yard/handlers/host_class_handler.rb b/lib/puppetx/yardoc/yard/handlers/host_class_handler.rb new file mode 100644 index 0000000..6db7856 --- /dev/null +++ b/lib/puppetx/yardoc/yard/handlers/host_class_handler.rb @@ -0,0 +1,11 @@ +require_relative 'base' + +module Puppetx::Yardoc::YARD::Handlers + class HostClassHandler < Base + handles HostClassDefinition + + process do + register YARD::CodeObjects::ClassObject.new(:root, statement.pops_obj.name) + end + end +end