(PDOC-54) Providers & Types w/same name conflict

If a provider and a type with the same name conflict strings will overwrite the
documentation of one of them with the other. That is if both a provider and a
type are named apt_key, strings will write the type to doc/apt_key.html and the
provider to doc/apt_key.html. The fix is to write the provider to
doc/apt_key_provider.html and the type to doc/apt_key_type.html.
This commit is contained in:
Ian Kronquist 2015-09-16 15:14:03 -07:00
parent 8aab1ea0a3
commit 7814eeaf3c
6 changed files with 24 additions and 4 deletions

View File

@ -26,7 +26,7 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::PuppetProviderHandler < YARD
provider_name = statement[i+1].jump(:ident).source provider_name = statement[i+1].jump(:ident).source
type_name = statement.jump(:symbol).first.source type_name = statement.jump(:symbol).first.source
obj = ProviderObject.new(:root, provider_name) obj = ProviderObject.new(:root, "#{provider_name}_provider")
docstring = nil docstring = nil
features = [] features = []
@ -83,6 +83,7 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::PuppetProviderHandler < YARD
obj.confines = confines obj.confines = confines
obj.defaults = defaults obj.defaults = defaults
obj.type_name = type_name obj.type_name = type_name
obj.header_name = provider_name
register_docstring(obj, docstring, nil) register_docstring(obj, docstring, nil)
register obj register obj

View File

@ -78,7 +78,7 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::PuppetTypeHandler < YARD::Ha
parameter_details = [] parameter_details = []
property_details = [] property_details = []
features = [] features = []
obj = TypeObject.new(:root, name) do |o| obj = TypeObject.new(:root, "#{name}_type") do |o|
# FIXME: This block gets yielded twice for whatever reason # FIXME: This block gets yielded twice for whatever reason
parameter_details = [] parameter_details = []
property_details = [] property_details = []
@ -137,6 +137,7 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::PuppetTypeHandler < YARD::Ha
obj.parameter_details = parameter_details obj.parameter_details = parameter_details
obj.property_details = property_details obj.property_details = property_details
obj.features = features obj.features = features
obj.header_name = name
register obj register obj
# Register docstring after the object. If the object already has a # Register docstring after the object. If the object already has a

View File

@ -59,7 +59,13 @@ def namespace_list(opts = {})
end end
children.reject {|c| c.nil? }.sort_by {|child| child.path }.map do |child| children.reject {|c| c.nil? }.sort_by {|child| child.path }.map do |child|
if namespace_types.include? child.type if namespace_types.include? child.type
name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name if child.namespace.is_a?(CodeObjects::Proxy)
name = child.path
elsif child.is_a?(PuppetX::PuppetLabs::Strings::YARD::CodeObjects::TypeObject) || child.is_a?(PuppetX::PuppetLabs::Strings::YARD::CodeObjects::ProviderObject)
name = child.header_name
else
name = child.name
end
has_children = child.respond_to?(:children) && run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) } has_children = child.respond_to?(:children) && run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
out << "<li>" out << "<li>"
out << "<a class='toggle'></a> " if has_children out << "<a class='toggle'></a> " if has_children

View File

@ -10,6 +10,12 @@ def init
@html_helper = HTMLHelper.new @html_helper = HTMLHelper.new
end end
def header
@header_text = object.header_name
erb(:header)
end
def command_details def command_details
@command_details = object.commands @command_details = object.commands
erb(:command_details) erb(:command_details)

View File

@ -10,6 +10,12 @@ def init
@html_helper = HTMLHelper.new @html_helper = HTMLHelper.new
end end
def header
@header_text = object.header_name
erb(:header)
end
def provider_details def provider_details
type_name = object.name.to_s type_name = object.name.to_s
@providers = YARD::Registry.all(:provider).select { |t| t.type_name == type_name } @providers = YARD::Registry.all(:provider).select { |t| t.type_name == type_name }

View File

@ -7,7 +7,7 @@ describe PuppetX::PuppetLabs::Strings::YARD::Handlers::PuppetTypeHandler do
include StringsSpec::Parsing include StringsSpec::Parsing
def the_type() def the_type()
YARD::Registry.at("file") YARD::Registry.at("file_type")
end end
it "should have the proper docstring" do it "should have the proper docstring" do