(PDOC-35) Add a directive for puppet parameters
* Print yard documentation statistics for providers * Define a directive which takes a type and a name
This commit is contained in:
parent
676364bd17
commit
798cd5b816
|
@ -1,4 +1,5 @@
|
||||||
require 'puppet/face'
|
require 'puppet/face'
|
||||||
|
require 'puppet_x/puppetlabs/strings/yard/tags/directives'
|
||||||
|
|
||||||
Puppet::Face.define(:strings, '0.0.1') do
|
Puppet::Face.define(:strings, '0.0.1') do
|
||||||
summary "Generate Puppet documentation with YARD."
|
summary "Generate Puppet documentation with YARD."
|
||||||
|
@ -55,6 +56,9 @@ Puppet::Face.define(:strings, '0.0.1') do
|
||||||
# all over the terminal. This should definitely not be in real code, but
|
# all over the terminal. This should definitely not be in real code, but
|
||||||
# it's very handy for debugging with pry
|
# it's very handy for debugging with pry
|
||||||
#class YARD::Logger; def progress(*args); end; end
|
#class YARD::Logger; def progress(*args); end; end
|
||||||
|
YARD::Tags::Library.define_directive("puppet.provider.param",
|
||||||
|
:with_types_and_name,
|
||||||
|
PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetProviderParameterDirective)
|
||||||
|
|
||||||
yardoc_actions.generate_documentation(*yard_args)
|
yardoc_actions.generate_documentation(*yard_args)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,10 @@ module PuppetX::PuppetLabs
|
||||||
require 'puppet_x/puppetlabs/strings/yard/monkey_patches'
|
require 'puppet_x/puppetlabs/strings/yard/monkey_patches'
|
||||||
require 'puppet_x/puppetlabs/strings/yard/parser'
|
require 'puppet_x/puppetlabs/strings/yard/parser'
|
||||||
|
|
||||||
|
module Tags
|
||||||
|
require 'puppet_x/puppetlabs/strings/yard/tags/directives'
|
||||||
|
end
|
||||||
|
|
||||||
# This submodule contains code objects which are used to represent relevant
|
# This submodule contains code objects which are used to represent relevant
|
||||||
# aspects of puppet code in YARD's Registry
|
# aspects of puppet code in YARD's Registry
|
||||||
module CodeObjects
|
module CodeObjects
|
||||||
|
|
|
@ -18,6 +18,10 @@ class YARD::CLI::Stats
|
||||||
def stats_for_definedtypes
|
def stats_for_definedtypes
|
||||||
output 'Puppet Types', *type_statistics(:definedtype)
|
output 'Puppet Types', *type_statistics(:definedtype)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stats_for_providers
|
||||||
|
output 'Puppet Providers', *type_statistics(:provider)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class YARD::Logger
|
class YARD::Logger
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
require 'puppet_x/puppetlabs/strings/yard/core_ext/yard'
|
||||||
|
# Creates a new code object based on the directive
|
||||||
|
class PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetProviderParameterDirective < YARD::Tags::Directive
|
||||||
|
def call
|
||||||
|
return if object.nil?
|
||||||
|
object.parameters << ([tag.text] + tag.types)
|
||||||
|
object.parameter_details << {:name => tag.name, :desc => tag.text, :exists? => true, :provider => true}
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,11 +11,8 @@ def init
|
||||||
end
|
end
|
||||||
|
|
||||||
def parameter_details
|
def parameter_details
|
||||||
|
|
||||||
params = object.parameter_details.map { |h| h[:name] }
|
params = object.parameter_details.map { |h| h[:name] }
|
||||||
|
@param_details = object.parameter_details.each { |h| h[:desc] = htmlify(h[:desc]) }
|
||||||
@param_details = []
|
|
||||||
@param_details = object.parameter_details
|
|
||||||
@template_helper.check_parameters_match_docs object
|
@template_helper.check_parameters_match_docs object
|
||||||
|
|
||||||
erb(:parameter_details)
|
erb(:parameter_details)
|
||||||
|
|
Loading…
Reference in New Issue