(maint) RuboCop fixes.
This commit fixes a few RuboCop related failures.
This commit is contained in:
parent
cf77ef1379
commit
7897c70a52
|
@ -2,17 +2,16 @@ require 'json'
|
||||||
|
|
||||||
# The module for JSON related functionality.
|
# The module for JSON related functionality.
|
||||||
module PuppetStrings::Json
|
module PuppetStrings::Json
|
||||||
|
|
||||||
# Renders the current YARD registry as JSON to the given file (or STDOUT if nil).
|
# Renders the current YARD registry as JSON to the given file (or STDOUT if nil).
|
||||||
# @param [String] file The path to the output file to render the registry to. If nil, output will be to STDOUT.
|
# @param [String] file The path to the output file to render the registry to. If nil, output will be to STDOUT.
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def self.render(file = nil)
|
def self.render(file = nil)
|
||||||
document = {
|
document = {
|
||||||
puppet_classes: YARD::Registry.all(:puppet_class).sort_by! { |c| c.name }.map! { |c| c.to_hash },
|
puppet_classes: YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash),
|
||||||
defined_types: YARD::Registry.all(:puppet_defined_type).sort_by! { |dt| dt.name }.map! { |dt| dt.to_hash },
|
defined_types: YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash),
|
||||||
resource_types: YARD::Registry.all(:puppet_type).sort_by! { |t| t.name }.map! { |t| t.to_hash },
|
resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash),
|
||||||
providers: YARD::Registry.all(:puppet_provider).sort_by! { |p| p.name }.map! { |p| p.to_hash },
|
providers: YARD::Registry.all(:puppet_provider).sort_by!(&:name).map!(&:to_hash),
|
||||||
puppet_functions: YARD::Registry.all(:puppet_function).sort_by! { |f| f.name }.map! { |f| f.to_hash },
|
puppet_functions: YARD::Registry.all(:puppet_function).sort_by!(&:name).map!(&:to_hash),
|
||||||
# TODO: Need Ruby documentation?
|
# TODO: Need Ruby documentation?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class YARD::CLI::Yardoc
|
||||||
:puppet_defined_type,
|
:puppet_defined_type,
|
||||||
:puppet_type,
|
:puppet_type,
|
||||||
:puppet_provider,
|
:puppet_provider,
|
||||||
:puppet_function,
|
:puppet_function
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -76,11 +76,12 @@ class YARD::CLI::Stats
|
||||||
# Monkey patch output to accommodate our larger header widths
|
# Monkey patch output to accommodate our larger header widths
|
||||||
@total += data if data.is_a?(Integer) && undoc
|
@total += data if data.is_a?(Integer) && undoc
|
||||||
@undocumented += undoc if undoc.is_a?(Integer)
|
@undocumented += undoc if undoc.is_a?(Integer)
|
||||||
if undoc
|
data =
|
||||||
data = ('%5s (% 5d undocumented)' % [data, undoc])
|
if undoc
|
||||||
else
|
('%5s (% 5d undocumented)' % [data, undoc])
|
||||||
data = '%5s' % data
|
else
|
||||||
end
|
'%5s' % data
|
||||||
|
end
|
||||||
log.puts('%-21s %s' % [name + ':', data])
|
log.puts('%-21s %s' % [name + ':', data])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -138,9 +138,9 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
|
||||||
hash[:file] = file
|
hash[:file] = file
|
||||||
hash[:line] = line
|
hash[:line] = line
|
||||||
hash[:docstring] = PuppetStrings::Json.docstring_to_hash(docstring)
|
hash[:docstring] = PuppetStrings::Json.docstring_to_hash(docstring)
|
||||||
hash[:properties] = properties.map { |p| p.to_hash } if properties && !properties.empty?
|
hash[:properties] = properties.map(&:to_hash) if properties && !properties.empty?
|
||||||
hash[:parameters] = parameters.map { |p| p.to_hash } if parameters && !parameters.empty?
|
hash[:parameters] = parameters.map(&:to_hash) if parameters && !parameters.empty?
|
||||||
hash[:features] = features.map { |f| f.to_hash } if features && !features.empty?
|
hash[:features] = features.map(&:to_hash) if features && !features.empty?
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,9 +57,10 @@ class PuppetStrings::Yard::Handlers::Ruby::ProviderHandler < PuppetStrings::Yard
|
||||||
return nil
|
return nil
|
||||||
elsif child.is_a?(YARD::Parser::Ruby::MethodCallNode)
|
elsif child.is_a?(YARD::Parser::Ruby::MethodCallNode)
|
||||||
# Look for a call to a dispatch method with a block
|
# Look for a call to a dispatch method with a block
|
||||||
next unless child.method_name &&
|
next unless
|
||||||
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
|
child.method_name &&
|
||||||
child.parameters(false).count == 1
|
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
|
||||||
|
child.parameters(false).count == 1
|
||||||
|
|
||||||
docstring = node_as_string(child.parameters[0])
|
docstring = node_as_string(child.parameters[0])
|
||||||
log.error "Failed to parse docstring for Puppet provider '#{object.name}' (resource type '#{object.type_name}') near #{child.file}:#{child.line}." and return nil unless docstring
|
log.error "Failed to parse docstring for Puppet provider '#{object.name}' (resource type '#{object.type_name}') near #{child.file}:#{child.line}." and return nil unless docstring
|
||||||
|
|
|
@ -80,7 +80,7 @@ Puppet::Face.define(:strings, '0.0.1') do
|
||||||
def check_required_features
|
def check_required_features
|
||||||
raise RuntimeError, "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard?
|
raise RuntimeError, "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard?
|
||||||
raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen?
|
raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen?
|
||||||
raise RuntimeError, 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION.match(/^1\.8/)
|
raise RuntimeError, 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION =~ /^1\.8/
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds the options to PuppetStrings.generate.
|
# Builds the options to PuppetStrings.generate.
|
||||||
|
|
|
@ -6,7 +6,6 @@ unless ENV['RS_PROVISION'] == 'no'
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
|
|
||||||
# Readable test descriptions
|
# Readable test descriptions
|
||||||
c.formatter = :documentation
|
c.formatter = :documentation
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue