diff --git a/lib/puppet-strings/yard/code_objects/type.rb b/lib/puppet-strings/yard/code_objects/type.rb index 384ccf8..8bb1983 100644 --- a/lib/puppet-strings/yard/code_objects/type.rb +++ b/lib/puppet-strings/yard/code_objects/type.rb @@ -78,7 +78,7 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects: # @param [String] docstring The docstring of the feature. def initialize(name, docstring) @name = name - @docstring = docstring + @docstring = Puppet::Util::Docs.scrub(docstring).gsub("\n", ' ') end # Converts the feature to a hash representation. diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb index 945f136..c3578f1 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb @@ -62,6 +62,11 @@ SOURCE Puppet::Type.newtype(:database) do desc 'An example database server resource type.' feature :encryption, 'The provider supports encryption.', methods: [:encrypt] + + feature :magic, + 'The feature docstring should have + whitespace and newlines stripped out.' + ensurable do desc 'What state the database should be in.' defaultvalues @@ -167,9 +172,11 @@ SOURCE expect(object.parameters[4].isnamevar).to eq(false) expect(object.parameters[4].default).to eq('never') expect(object.parameters[4].values).to eq(%w(daily monthly never)) - expect(object.features.size).to eq(1) + expect(object.features.size).to eq(2) expect(object.features[0].name).to eq('encryption') expect(object.features[0].docstring).to eq('The provider supports encryption.') + expect(object.features[1].name).to eq('magic') + expect(object.features[1].docstring).to eq('The feature docstring should have whitespace and newlines stripped out.') end end