From 5a283c2212fc1fc0d414257b86c2ac94fe1ce300 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Thu, 22 Feb 2018 11:04:59 -0800 Subject: [PATCH 1/4] (maint) do not display name if there is nothing to display If there is a class, type, or function with no information documented but is pulled in by some fluke or tag we don't support, do not give it its own section --- lib/puppet-strings/markdown/base.rb | 11 +++++++++++ lib/puppet-strings/markdown/defined_types.rb | 3 ++- lib/puppet-strings/markdown/functions.rb | 3 ++- lib/puppet-strings/markdown/puppet_classes.rb | 3 ++- lib/puppet-strings/markdown/resource_types.rb | 3 ++- .../markdown/templates/classes_and_defines.erb | 2 ++ lib/puppet-strings/markdown/templates/function.erb | 2 ++ .../markdown/templates/resource_type.erb | 5 ++--- spec/fixtures/unit/markdown/output.md | 12 ++++++++++++ 9 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lib/puppet-strings/markdown/base.rb b/lib/puppet-strings/markdown/base.rb index 8e9792a..ff3cedd 100644 --- a/lib/puppet-strings/markdown/base.rb +++ b/lib/puppet-strings/markdown/base.rb @@ -47,6 +47,9 @@ module PuppetStrings::Markdown # ") inherits foo::bar {\n" + # "}"} class Base + + DISPLAYED_TAGS = %w[summary see since version param raise option overload] + def initialize(registry, component_type) @type = component_type @registry = registry @@ -149,6 +152,14 @@ module PuppetStrings::Markdown end end + def contains_displayed_tags? + result = @registry[:docstring][:text] ? true : false + @tags.each do |tag| + result = true if DISPLAYED_TAGS.include? tag[:tag_name] + end + result + end + # @return [String] full markdown rendering of a component def render(template) file = File.join(File.dirname(__FILE__),"templates/#{template}") diff --git a/lib/puppet-strings/markdown/defined_types.rb b/lib/puppet-strings/markdown/defined_types.rb index e23c6a3..fc26eb4 100644 --- a/lib/puppet-strings/markdown/defined_types.rb +++ b/lib/puppet-strings/markdown/defined_types.rb @@ -11,7 +11,8 @@ module PuppetStrings::Markdown def self.render final = in_dtypes.length > 0 ? "## Defined types\n\n" : "" in_dtypes.each do |type| - final << PuppetStrings::Markdown::DefinedType.new(type).render + to_render = PuppetStrings::Markdown::DefinedType.new(type) + final << to_render.render if to_render.contains_displayed_tags? end final end diff --git a/lib/puppet-strings/markdown/functions.rb b/lib/puppet-strings/markdown/functions.rb index 1996938..c348318 100644 --- a/lib/puppet-strings/markdown/functions.rb +++ b/lib/puppet-strings/markdown/functions.rb @@ -11,7 +11,8 @@ module PuppetStrings::Markdown def self.render final = in_functions.length > 0 ? "## Functions\n\n" : "" in_functions.each do |func| - final << PuppetStrings::Markdown::Function.new(func).render + to_render = PuppetStrings::Markdown::Function.new(func) + final << to_render.render if to_render.contains_displayed_tags? end final end diff --git a/lib/puppet-strings/markdown/puppet_classes.rb b/lib/puppet-strings/markdown/puppet_classes.rb index 0818f9f..dbef9af 100644 --- a/lib/puppet-strings/markdown/puppet_classes.rb +++ b/lib/puppet-strings/markdown/puppet_classes.rb @@ -11,7 +11,8 @@ module PuppetStrings::Markdown def self.render final = in_classes.length > 0 ? "## Classes\n\n" : "" in_classes.each do |klass| - final << PuppetStrings::Markdown::PuppetClass.new(klass).render + to_render = PuppetStrings::Markdown::PuppetClass.new(klass) + final << to_render.render if to_render.contains_displayed_tags? end final end diff --git a/lib/puppet-strings/markdown/resource_types.rb b/lib/puppet-strings/markdown/resource_types.rb index 214a885..76e7777 100644 --- a/lib/puppet-strings/markdown/resource_types.rb +++ b/lib/puppet-strings/markdown/resource_types.rb @@ -11,7 +11,8 @@ module PuppetStrings::Markdown def self.render final = in_rtypes.length > 0 ? "## Resource types\n\n" : "" in_rtypes.each do |type| - final << PuppetStrings::Markdown::ResourceType.new(type).render + to_render = PuppetStrings::Markdown::ResourceType.new(type) + final << to_render.render if to_render.contains_displayed_tags? end final end diff --git a/lib/puppet-strings/markdown/templates/classes_and_defines.erb b/lib/puppet-strings/markdown/templates/classes_and_defines.erb index 8cf528c..580156a 100644 --- a/lib/puppet-strings/markdown/templates/classes_and_defines.erb +++ b/lib/puppet-strings/markdown/templates/classes_and_defines.erb @@ -1,5 +1,7 @@ ### <%= name %> +<%= text || summary || "The #{name} class." %> + <% if since -%> * **Since** <%= since %> diff --git a/lib/puppet-strings/markdown/templates/function.erb b/lib/puppet-strings/markdown/templates/function.erb index 40a6ca8..e1e3d22 100644 --- a/lib/puppet-strings/markdown/templates/function.erb +++ b/lib/puppet-strings/markdown/templates/function.erb @@ -1,6 +1,8 @@ ### <%= name %> Type: <%= type %> +<%= text || summary || "The #{name} function." %> + <% signatures.each do |sig| -%> #### `<%= sig.signature %>` diff --git a/lib/puppet-strings/markdown/templates/resource_type.erb b/lib/puppet-strings/markdown/templates/resource_type.erb index 12cff6f..8cf9487 100644 --- a/lib/puppet-strings/markdown/templates/resource_type.erb +++ b/lib/puppet-strings/markdown/templates/resource_type.erb @@ -1,5 +1,7 @@ ### <%= name %> +<%= text || summary || "The #{name} type." %> + <% if since -%> * **Since** <%= since %> @@ -12,9 +14,6 @@ <% end -%> <% end -%> -<% if text -%> -<%= text %> -<% end %> <% if examples -%> #### Examples <% examples.each do |eg| -%> diff --git a/spec/fixtures/unit/markdown/output.md b/spec/fixtures/unit/markdown/output.md index 005277d..e6bfc35 100644 --- a/spec/fixtures/unit/markdown/output.md +++ b/spec/fixtures/unit/markdown/output.md @@ -16,6 +16,8 @@ ### klass +An overview for a simple class. + * **Since** 1.0.0 * **See also** @@ -78,6 +80,8 @@ Default value: 'hi' ### klass::dt +An overview for a simple defined type. + * **Since** 1.1.0 * **See also** @@ -249,6 +253,8 @@ Default value: `false` ### func Type: Puppet Language +A simple Puppet function. + #### `func(Integer $param1, Any $param2, String $param3 = hi)` A simple Puppet function. @@ -283,6 +289,8 @@ Options: ### func3x Type: Ruby 3.x API +Documentation for an example 3.x function. + #### `func3x(String $param1, Integer $param2)` Documentation for an example 3.x function. @@ -304,6 +312,8 @@ The second parameter. ### func4x Type: Ruby 4.x API +An example 4.x function. + #### `func4x(Integer $param1, Any $param2, Optional[Array[String]] $param3)` An overview for the first overload. @@ -354,6 +364,8 @@ The block parameter. ### func4x_1 Type: Ruby 4.x API +An example 4.x function with only one signature. + #### `func4x_1(Integer $param1)` An example 4.x function with only one signature. From 09a5d3e4fffa0fc0eb5bb75b7ce63f6c57ee52a0 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Thu, 22 Feb 2018 16:07:39 -0800 Subject: [PATCH 2/4] (maint) change template logic and add test --- .../markdown/templates/classes_and_defines.erb | 10 +++++++++- lib/puppet-strings/markdown/templates/function.erb | 10 +++++++++- .../markdown/templates/resource_type.erb | 10 +++++++++- spec/fixtures/unit/markdown/output.md | 12 ++++++++++++ spec/unit/puppet-strings/markdown_spec.rb | 5 +++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/lib/puppet-strings/markdown/templates/classes_and_defines.erb b/lib/puppet-strings/markdown/templates/classes_and_defines.erb index 580156a..afacde4 100644 --- a/lib/puppet-strings/markdown/templates/classes_and_defines.erb +++ b/lib/puppet-strings/markdown/templates/classes_and_defines.erb @@ -1,7 +1,15 @@ ### <%= name %> -<%= text || summary || "The #{name} class." %> +<% if text -%> +<%= text %> +<% elsif summary -%> +<%= summary %> + +<% else -%> +<%= "The #{name} class." %> + +<% end -%> <% if since -%> * **Since** <%= since %> diff --git a/lib/puppet-strings/markdown/templates/function.erb b/lib/puppet-strings/markdown/templates/function.erb index e1e3d22..6f6a15b 100644 --- a/lib/puppet-strings/markdown/templates/function.erb +++ b/lib/puppet-strings/markdown/templates/function.erb @@ -1,8 +1,16 @@ ### <%= name %> Type: <%= type %> -<%= text || summary || "The #{name} function." %> +<% if text -%> +<%= text %> +<% elsif summary -%> +<%= summary %> + +<% else -%> +<%= "The #{name} class." %> + +<% end -%> <% signatures.each do |sig| -%> #### `<%= sig.signature %>` diff --git a/lib/puppet-strings/markdown/templates/resource_type.erb b/lib/puppet-strings/markdown/templates/resource_type.erb index 8cf9487..f517f40 100644 --- a/lib/puppet-strings/markdown/templates/resource_type.erb +++ b/lib/puppet-strings/markdown/templates/resource_type.erb @@ -1,7 +1,15 @@ ### <%= name %> -<%= text || summary || "The #{name} type." %> +<% if text -%> +<%= text %> +<% elsif summary -%> +<%= summary %> + +<% else -%> +<%= "The #{name} type." %> + +<% end -%> <% if since -%> * **Since** <%= since %> diff --git a/spec/fixtures/unit/markdown/output.md b/spec/fixtures/unit/markdown/output.md index e6bfc35..594f149 100644 --- a/spec/fixtures/unit/markdown/output.md +++ b/spec/fixtures/unit/markdown/output.md @@ -2,6 +2,8 @@ ## Classes * [`klass`](#klass): A simple class. +* [`noparams`](#noparams): Overview for class noparams +* [`noparams_desc`](#noparams_desc): ## Defined types * [`klass::dt`](#klassdt): A simple defined type. ## Resource types @@ -76,6 +78,16 @@ Third param. Default value: 'hi' +### noparams + +Overview for class noparams + + +### noparams_desc + +The noparams_desc class. + + ## Defined types ### klass::dt diff --git a/spec/unit/puppet-strings/markdown_spec.rb b/spec/unit/puppet-strings/markdown_spec.rb index 6eab938..98d0ab1 100644 --- a/spec/unit/puppet-strings/markdown_spec.rb +++ b/spec/unit/puppet-strings/markdown_spec.rb @@ -35,6 +35,11 @@ class klass ( ) inherits foo::bar { } +# Overview for class noparams +class noparams () {} + +class noparams_desc () {} + # An overview for a simple defined type. # @summary A simple defined type. # @since 1.1.0 From 6923d9e18cdb52c77c8d9378509b9889472c26a5 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Mon, 26 Feb 2018 13:06:13 -0800 Subject: [PATCH 3/4] (maint) update table of contents The table_of_contents template was already too bulky and redundant and recognizing public and private components was only going to make it worse. This refactors the toc template and the toc class to use a generic outline for all components. --- lib/puppet-strings/markdown/base.rb | 12 ++++++- lib/puppet-strings/markdown/defined_types.rb | 17 +++++++--- lib/puppet-strings/markdown/functions.rb | 17 +++++++--- lib/puppet-strings/markdown/puppet_classes.rb | 17 +++++++--- lib/puppet-strings/markdown/resource_types.rb | 17 +++++++--- .../markdown/table_of_contents.rb | 20 ++++++++---- .../markdown/templates/table_of_contents.erb | 31 +++++++++---------- spec/fixtures/unit/markdown/output.md | 15 ++------- .../unit/puppet-strings/markdown/base_spec.rb | 6 ++++ spec/unit/puppet-strings/markdown_spec.rb | 3 +- 10 files changed, 97 insertions(+), 58 deletions(-) diff --git a/lib/puppet-strings/markdown/base.rb b/lib/puppet-strings/markdown/base.rb index ff3cedd..cb43c6b 100644 --- a/lib/puppet-strings/markdown/base.rb +++ b/lib/puppet-strings/markdown/base.rb @@ -130,7 +130,8 @@ module PuppetStrings::Markdown { name: name.to_s, link: link, - desc: summary || @registry[:docstring][:text].gsub("\n", ". ") + desc: summary || @registry[:docstring][:text].gsub("\n", ". "), + private: private? } end @@ -152,6 +153,15 @@ module PuppetStrings::Markdown end end + def private? + result = false + api = @tags.find { |tag| tag[:tag_name] == 'api' } + unless api.nil? + result = api[:text] == 'private' ? true : false + end + result + end + def contains_displayed_tags? result = @registry[:docstring][:text] ? true : false @tags.each do |tag| diff --git a/lib/puppet-strings/markdown/defined_types.rb b/lib/puppet-strings/markdown/defined_types.rb index fc26eb4..c10517f 100644 --- a/lib/puppet-strings/markdown/defined_types.rb +++ b/lib/puppet-strings/markdown/defined_types.rb @@ -5,23 +5,30 @@ module PuppetStrings::Markdown # @return [Array] list of defined types def self.in_dtypes - YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash) + arr = YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash) + arr.map! { |a| PuppetStrings::Markdown::DefinedType.new(a) } + end + + def self.contains_private? + result = false + unless in_dtypes.nil? + in_dtypes.find { |type| type.private? }.nil? ? false : true + end end def self.render final = in_dtypes.length > 0 ? "## Defined types\n\n" : "" in_dtypes.each do |type| - to_render = PuppetStrings::Markdown::DefinedType.new(type) - final << to_render.render if to_render.contains_displayed_tags? + final << type.render unless type.private? end final end def self.toc_info - final = [] + final = ["Defined types"] in_dtypes.each do |type| - final.push(PuppetStrings::Markdown::DefinedType.new(type).toc_info) + final.push(type.toc_info) end final diff --git a/lib/puppet-strings/markdown/functions.rb b/lib/puppet-strings/markdown/functions.rb index c348318..f1cfb26 100644 --- a/lib/puppet-strings/markdown/functions.rb +++ b/lib/puppet-strings/markdown/functions.rb @@ -5,23 +5,30 @@ module PuppetStrings::Markdown # @return [Array] list of functions def self.in_functions - YARD::Registry.all(:puppet_function).sort_by!(&:name).map!(&:to_hash) + arr = YARD::Registry.all(:puppet_function).sort_by!(&:name).map!(&:to_hash) + arr.map! { |a| PuppetStrings::Markdown::Function.new(a) } + end + + def self.contains_private? + result = false + unless in_functions.nil? + in_functions.find { |func| func.private? }.nil? ? false : true + end end def self.render final = in_functions.length > 0 ? "## Functions\n\n" : "" in_functions.each do |func| - to_render = PuppetStrings::Markdown::Function.new(func) - final << to_render.render if to_render.contains_displayed_tags? + final << func.render unless func.private? end final end def self.toc_info - final = [] + final = ["Functions"] in_functions.each do |func| - final.push(PuppetStrings::Markdown::Function.new(func).toc_info) + final.push(func.toc_info) end final diff --git a/lib/puppet-strings/markdown/puppet_classes.rb b/lib/puppet-strings/markdown/puppet_classes.rb index dbef9af..625e7e2 100644 --- a/lib/puppet-strings/markdown/puppet_classes.rb +++ b/lib/puppet-strings/markdown/puppet_classes.rb @@ -5,23 +5,30 @@ module PuppetStrings::Markdown # @return [Array] list of classes def self.in_classes - YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash) + arr = YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash) + arr.map! { |a| PuppetStrings::Markdown::PuppetClass.new(a) } + end + + def self.contains_private? + result = false + unless in_classes.nil? + in_classes.find { |klass| klass.private? }.nil? ? false : true + end end def self.render final = in_classes.length > 0 ? "## Classes\n\n" : "" in_classes.each do |klass| - to_render = PuppetStrings::Markdown::PuppetClass.new(klass) - final << to_render.render if to_render.contains_displayed_tags? + final << klass.render unless klass.private? end final end def self.toc_info - final = [] + final = ["Classes"] in_classes.each do |klass| - final.push(PuppetStrings::Markdown::PuppetClass.new(klass).toc_info) + final.push(klass.toc_info) end final diff --git a/lib/puppet-strings/markdown/resource_types.rb b/lib/puppet-strings/markdown/resource_types.rb index 76e7777..3f48765 100644 --- a/lib/puppet-strings/markdown/resource_types.rb +++ b/lib/puppet-strings/markdown/resource_types.rb @@ -5,23 +5,30 @@ module PuppetStrings::Markdown # @return [Array] list of resource types def self.in_rtypes - YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash) + arr = YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash) + arr.map! { |a| PuppetStrings::Markdown::ResourceType.new(a) } + end + + def self.contains_private? + result = false + unless in_rtypes.nil? + in_rtypes.find { |type| type.private? }.nil? ? false : true + end end def self.render final = in_rtypes.length > 0 ? "## Resource types\n\n" : "" in_rtypes.each do |type| - to_render = PuppetStrings::Markdown::ResourceType.new(type) - final << to_render.render if to_render.contains_displayed_tags? + final << type.render unless type.private? end final end def self.toc_info - final = [] + final = ["Resource types"] in_rtypes.each do |type| - final.push(PuppetStrings::Markdown::ResourceType.new(type).toc_info) + final.push(type.toc_info) end final diff --git a/lib/puppet-strings/markdown/table_of_contents.rb b/lib/puppet-strings/markdown/table_of_contents.rb index 3afa119..ed230ac 100644 --- a/lib/puppet-strings/markdown/table_of_contents.rb +++ b/lib/puppet-strings/markdown/table_of_contents.rb @@ -1,13 +1,21 @@ module PuppetStrings::Markdown module TableOfContents def self.render - puppet_classes = PuppetStrings::Markdown::PuppetClasses.toc_info - puppet_defined_types = PuppetStrings::Markdown::DefinedTypes.toc_info - puppet_resource_types = PuppetStrings::Markdown::ResourceTypes.toc_info - puppet_functions = PuppetStrings::Markdown::Functions.toc_info + final = "" - template = File.join(File.dirname(__FILE__),"templates/table_of_contents.erb") - ERB.new(File.read(template), nil, '-').result(binding) + [PuppetStrings::Markdown::PuppetClasses, + PuppetStrings::Markdown::DefinedTypes, + PuppetStrings::Markdown::ResourceTypes, + PuppetStrings::Markdown::Functions].each do |r| + toc = r.toc_info + group_name = toc.shift + group = toc + priv = r.contains_private? + + template = File.join(File.dirname(__FILE__),"templates/table_of_contents.erb") + final << ERB.new(File.read(template), nil, '-').result(binding) + end + final end end end diff --git a/lib/puppet-strings/markdown/templates/table_of_contents.erb b/lib/puppet-strings/markdown/templates/table_of_contents.erb index d726b5e..c2b4e18 100644 --- a/lib/puppet-strings/markdown/templates/table_of_contents.erb +++ b/lib/puppet-strings/markdown/templates/table_of_contents.erb @@ -1,24 +1,21 @@ -<% if puppet_classes.length > 0 -%> -## Classes -<% puppet_classes.each do |klassy| -%> -* [`<%= klassy[:name] %>`](#<%= klassy[:link] %>): <%= klassy[:desc] %> +<% if group.length > 0 -%> +## <%= group_name %> +<% if priv -%> +### Public <%= group_name %> +<% group.each do |item| -%> +<% unless item[:private] -%> +* [`<%= item[:name] %>`](#<%= item[:link] %>): <%= item[:desc] %> <% end -%> <% end -%> -<% if puppet_defined_types.length > 0 -%> -## Defined types -<% puppet_defined_types.each do |dtype| -%> -* [`<%= dtype[:name] %>`](#<%= dtype[:link] %>): <%= dtype[:desc] %> +### Private <%= group_name %> +<% group.each do |item| -%> +<% if item[:private] -%> +* `<%= item[:name] %>`: <%= item[:desc] %> <% end -%> <% end -%> -<% if puppet_resource_types.length > 0 -%> -## Resource types -<% puppet_resource_types.each do |rtype| -%> -* [`<%= rtype[:name] %>`](#<%= rtype[:link] %>): <%= rtype[:desc] %> +<% else -%> +<% group.each do |item| -%> +* [`<%= item[:name] %>`](#<%= item[:link] %>): <%= item[:desc] %> <% end -%> <% end -%> -<% if puppet_functions.length > 0 -%> -## Functions -<% puppet_functions.each do |func| -%> -* [`<%= func[:name] %>`](#<%= func[:link] %>): <%= func[:desc] %> -<% end -%> <% end -%> diff --git a/spec/fixtures/unit/markdown/output.md b/spec/fixtures/unit/markdown/output.md index 594f149..9d225c8 100644 --- a/spec/fixtures/unit/markdown/output.md +++ b/spec/fixtures/unit/markdown/output.md @@ -1,9 +1,10 @@ # Reference ## Classes +### Public Classes * [`klass`](#klass): A simple class. -* [`noparams`](#noparams): Overview for class noparams -* [`noparams_desc`](#noparams_desc): +### Private Classes +* `noparams`: Overview for class noparams ## Defined types * [`klass::dt`](#klassdt): A simple defined type. ## Resource types @@ -78,16 +79,6 @@ Third param. Default value: 'hi' -### noparams - -Overview for class noparams - - -### noparams_desc - -The noparams_desc class. - - ## Defined types ### klass::dt diff --git a/spec/unit/puppet-strings/markdown/base_spec.rb b/spec/unit/puppet-strings/markdown/base_spec.rb index 6713f2a..fa254eb 100644 --- a/spec/unit/puppet-strings/markdown/base_spec.rb +++ b/spec/unit/puppet-strings/markdown/base_spec.rb @@ -114,6 +114,12 @@ SOURCE end end + describe '#private?' do + it do + expect(component.private?).to be false + end + end + describe '#toc_info' do let(:toc) { component.toc_info } it 'returns a hash' do diff --git a/spec/unit/puppet-strings/markdown_spec.rb b/spec/unit/puppet-strings/markdown_spec.rb index 98d0ab1..8c0c052 100644 --- a/spec/unit/puppet-strings/markdown_spec.rb +++ b/spec/unit/puppet-strings/markdown_spec.rb @@ -36,10 +36,9 @@ class klass ( } # Overview for class noparams +# @api private class noparams () {} -class noparams_desc () {} - # An overview for a simple defined type. # @summary A simple defined type. # @since 1.1.0 From 65bfdaf1de15c66ee3b02e9522c2965f76550458 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Mon, 26 Feb 2018 13:24:06 -0800 Subject: [PATCH 4/4] remove displayed tag business --- lib/puppet-strings/markdown/base.rb | 13 +------------ spec/unit/puppet-strings/markdown/base_spec.rb | 9 ++++++++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/puppet-strings/markdown/base.rb b/lib/puppet-strings/markdown/base.rb index cb43c6b..c35202b 100644 --- a/lib/puppet-strings/markdown/base.rb +++ b/lib/puppet-strings/markdown/base.rb @@ -47,9 +47,6 @@ module PuppetStrings::Markdown # ") inherits foo::bar {\n" + # "}"} class Base - - DISPLAYED_TAGS = %w[summary see since version param raise option overload] - def initialize(registry, component_type) @type = component_type @registry = registry @@ -130,7 +127,7 @@ module PuppetStrings::Markdown { name: name.to_s, link: link, - desc: summary || @registry[:docstring][:text].gsub("\n", ". "), + desc: summary || @registry[:docstring][:text][0..140].gsub("\n",' '), private: private? } end @@ -162,14 +159,6 @@ module PuppetStrings::Markdown result end - def contains_displayed_tags? - result = @registry[:docstring][:text] ? true : false - @tags.each do |tag| - result = true if DISPLAYED_TAGS.include? tag[:tag_name] - end - result - end - # @return [String] full markdown rendering of a component def render(template) file = File.join(File.dirname(__FILE__),"templates/#{template}") diff --git a/spec/unit/puppet-strings/markdown/base_spec.rb b/spec/unit/puppet-strings/markdown/base_spec.rb index fa254eb..c1e2716 100644 --- a/spec/unit/puppet-strings/markdown/base_spec.rb +++ b/spec/unit/puppet-strings/markdown/base_spec.rb @@ -5,6 +5,7 @@ describe PuppetStrings::Markdown::Base do before :each do YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) # An overview +# @api private # @summary A simple class. # @param param1 First param. # @param param2 Second param. @@ -36,6 +37,12 @@ SOURCE end + describe '#private?' do + it do + expect(component.private?).to be true + end + end + describe '#params' do it 'returns the expected params' do expect(component.params.size).to eq 3 @@ -126,7 +133,7 @@ SOURCE expect(toc).to be_instance_of Hash end it 'uses overview for :desc in absence of summary' do - expect(toc[:desc]).to eq 'An overview. It\'s a longer overview. Ya know?' + expect(toc[:desc]).to eq 'An overview It\'s a longer overview Ya know?' end end