(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
This commit is contained in:
Eric Putnam 2018-02-22 11:04:59 -08:00
parent 7dff75642b
commit 5a283c2212
No known key found for this signature in database
GPG Key ID: 3FB595AA224A7751
9 changed files with 37 additions and 7 deletions

View File

@ -47,6 +47,9 @@ module PuppetStrings::Markdown
# ") inherits foo::bar {\n" + # ") inherits foo::bar {\n" +
# "}"} # "}"}
class Base class Base
DISPLAYED_TAGS = %w[summary see since version param raise option overload]
def initialize(registry, component_type) def initialize(registry, component_type)
@type = component_type @type = component_type
@registry = registry @registry = registry
@ -149,6 +152,14 @@ module PuppetStrings::Markdown
end end
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 # @return [String] full markdown rendering of a component
def render(template) def render(template)
file = File.join(File.dirname(__FILE__),"templates/#{template}") file = File.join(File.dirname(__FILE__),"templates/#{template}")

View File

@ -11,7 +11,8 @@ module PuppetStrings::Markdown
def self.render def self.render
final = in_dtypes.length > 0 ? "## Defined types\n\n" : "" final = in_dtypes.length > 0 ? "## Defined types\n\n" : ""
in_dtypes.each do |type| 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 end
final final
end end

View File

@ -11,7 +11,8 @@ module PuppetStrings::Markdown
def self.render def self.render
final = in_functions.length > 0 ? "## Functions\n\n" : "" final = in_functions.length > 0 ? "## Functions\n\n" : ""
in_functions.each do |func| 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 end
final final
end end

View File

@ -11,7 +11,8 @@ module PuppetStrings::Markdown
def self.render def self.render
final = in_classes.length > 0 ? "## Classes\n\n" : "" final = in_classes.length > 0 ? "## Classes\n\n" : ""
in_classes.each do |klass| 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 end
final final
end end

View File

@ -11,7 +11,8 @@ module PuppetStrings::Markdown
def self.render def self.render
final = in_rtypes.length > 0 ? "## Resource types\n\n" : "" final = in_rtypes.length > 0 ? "## Resource types\n\n" : ""
in_rtypes.each do |type| 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 end
final final
end end

View File

@ -1,5 +1,7 @@
### <%= name %> ### <%= name %>
<%= text || summary || "The #{name} class." %>
<% if since -%> <% if since -%>
* **Since** <%= since %> * **Since** <%= since %>

View File

@ -1,6 +1,8 @@
### <%= name %> ### <%= name %>
Type: <%= type %> Type: <%= type %>
<%= text || summary || "The #{name} function." %>
<% signatures.each do |sig| -%> <% signatures.each do |sig| -%>
#### `<%= sig.signature %>` #### `<%= sig.signature %>`

View File

@ -1,5 +1,7 @@
### <%= name %> ### <%= name %>
<%= text || summary || "The #{name} type." %>
<% if since -%> <% if since -%>
* **Since** <%= since %> * **Since** <%= since %>
@ -12,9 +14,6 @@
<% end -%> <% end -%>
<% end -%> <% end -%>
<% if text -%>
<%= text %>
<% end %>
<% if examples -%> <% if examples -%>
#### Examples #### Examples
<% examples.each do |eg| -%> <% examples.each do |eg| -%>

View File

@ -16,6 +16,8 @@
### klass ### klass
An overview for a simple class.
* **Since** 1.0.0 * **Since** 1.0.0
* **See also** * **See also**
@ -78,6 +80,8 @@ Default value: 'hi'
### klass::dt ### klass::dt
An overview for a simple defined type.
* **Since** 1.1.0 * **Since** 1.1.0
* **See also** * **See also**
@ -249,6 +253,8 @@ Default value: `false`
### func ### func
Type: Puppet Language Type: Puppet Language
A simple Puppet function.
#### `func(Integer $param1, Any $param2, String $param3 = hi)` #### `func(Integer $param1, Any $param2, String $param3 = hi)`
A simple Puppet function. A simple Puppet function.
@ -283,6 +289,8 @@ Options:
### func3x ### func3x
Type: Ruby 3.x API Type: Ruby 3.x API
Documentation for an example 3.x function.
#### `func3x(String $param1, Integer $param2)` #### `func3x(String $param1, Integer $param2)`
Documentation for an example 3.x function. Documentation for an example 3.x function.
@ -304,6 +312,8 @@ The second parameter.
### func4x ### func4x
Type: Ruby 4.x API Type: Ruby 4.x API
An example 4.x function.
#### `func4x(Integer $param1, Any $param2, Optional[Array[String]] $param3)` #### `func4x(Integer $param1, Any $param2, Optional[Array[String]] $param3)`
An overview for the first overload. An overview for the first overload.
@ -354,6 +364,8 @@ The block parameter.
### func4x_1 ### func4x_1
Type: Ruby 4.x API Type: Ruby 4.x API
An example 4.x function with only one signature.
#### `func4x_1(Integer $param1)` #### `func4x_1(Integer $param1)`
An example 4.x function with only one signature. An example 4.x function with only one signature.