File tree Expand file tree Collapse file tree 13 files changed +150
-44
lines changed
lib/puppet-strings/markdown Expand file tree Collapse file tree 13 files changed +150
-44
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,8 @@ def toc_info
127
127
{
128
128
name : name . to_s ,
129
129
link : link ,
130
- desc : summary || @registry [ :docstring ] [ :text ] . gsub ( "\n " , ". " )
130
+ desc : summary || @registry [ :docstring ] [ :text ] [ 0 ..140 ] . gsub ( "\n " , ' ' ) ,
131
+ private : private?
131
132
}
132
133
end
133
134
@@ -149,6 +150,15 @@ def value_string(value)
149
150
end
150
151
end
151
152
153
+ def private?
154
+ result = false
155
+ api = @tags . find { |tag | tag [ :tag_name ] == 'api' }
156
+ unless api . nil?
157
+ result = api [ :text ] == 'private' ? true : false
158
+ end
159
+ result
160
+ end
161
+
152
162
# @return [String] full markdown rendering of a component
153
163
def render ( template )
154
164
file = File . join ( File . dirname ( __FILE__ ) , "templates/#{ template } " )
Original file line number Diff line number Diff line change @@ -5,22 +5,30 @@ module DefinedTypes
5
5
6
6
# @return [Array] list of defined types
7
7
def self . in_dtypes
8
- YARD ::Registry . all ( :puppet_defined_type ) . sort_by! ( &:name ) . map! ( &:to_hash )
8
+ arr = YARD ::Registry . all ( :puppet_defined_type ) . sort_by! ( &:name ) . map! ( &:to_hash )
9
+ arr . map! { |a | PuppetStrings ::Markdown ::DefinedType . new ( a ) }
10
+ end
11
+
12
+ def self . contains_private?
13
+ result = false
14
+ unless in_dtypes . nil?
15
+ in_dtypes . find { |type | type . private? } . nil? ? false : true
16
+ end
9
17
end
10
18
11
19
def self . render
12
20
final = in_dtypes . length > 0 ? "## Defined types\n \n " : ""
13
21
in_dtypes . each do |type |
14
- final << PuppetStrings :: Markdown :: DefinedType . new ( type ) . render
22
+ final << type . render unless type . private?
15
23
end
16
24
final
17
25
end
18
26
19
27
def self . toc_info
20
- final = [ ]
28
+ final = [ "Defined types" ]
21
29
22
30
in_dtypes . each do |type |
23
- final . push ( PuppetStrings :: Markdown :: DefinedType . new ( type ) . toc_info )
31
+ final . push ( type . toc_info )
24
32
end
25
33
26
34
final
Original file line number Diff line number Diff line change @@ -5,22 +5,30 @@ module Functions
5
5
6
6
# @return [Array] list of functions
7
7
def self . in_functions
8
- YARD ::Registry . all ( :puppet_function ) . sort_by! ( &:name ) . map! ( &:to_hash )
8
+ arr = YARD ::Registry . all ( :puppet_function ) . sort_by! ( &:name ) . map! ( &:to_hash )
9
+ arr . map! { |a | PuppetStrings ::Markdown ::Function . new ( a ) }
10
+ end
11
+
12
+ def self . contains_private?
13
+ result = false
14
+ unless in_functions . nil?
15
+ in_functions . find { |func | func . private? } . nil? ? false : true
16
+ end
9
17
end
10
18
11
19
def self . render
12
20
final = in_functions . length > 0 ? "## Functions\n \n " : ""
13
21
in_functions . each do |func |
14
- final << PuppetStrings :: Markdown :: Function . new ( func ) . render
22
+ final << func . render unless func . private?
15
23
end
16
24
final
17
25
end
18
26
19
27
def self . toc_info
20
- final = [ ]
28
+ final = [ "Functions" ]
21
29
22
30
in_functions . each do |func |
23
- final . push ( PuppetStrings :: Markdown :: Function . new ( func ) . toc_info )
31
+ final . push ( func . toc_info )
24
32
end
25
33
26
34
final
Original file line number Diff line number Diff line change @@ -5,22 +5,30 @@ module PuppetClasses
5
5
6
6
# @return [Array] list of classes
7
7
def self . in_classes
8
- YARD ::Registry . all ( :puppet_class ) . sort_by! ( &:name ) . map! ( &:to_hash )
8
+ arr = YARD ::Registry . all ( :puppet_class ) . sort_by! ( &:name ) . map! ( &:to_hash )
9
+ arr . map! { |a | PuppetStrings ::Markdown ::PuppetClass . new ( a ) }
10
+ end
11
+
12
+ def self . contains_private?
13
+ result = false
14
+ unless in_classes . nil?
15
+ in_classes . find { |klass | klass . private? } . nil? ? false : true
16
+ end
9
17
end
10
18
11
19
def self . render
12
20
final = in_classes . length > 0 ? "## Classes\n \n " : ""
13
21
in_classes . each do |klass |
14
- final << PuppetStrings :: Markdown :: PuppetClass . new ( klass ) . render
22
+ final << klass . render unless klass . private?
15
23
end
16
24
final
17
25
end
18
26
19
27
def self . toc_info
20
- final = [ ]
28
+ final = [ "Classes" ]
21
29
22
30
in_classes . each do |klass |
23
- final . push ( PuppetStrings :: Markdown :: PuppetClass . new ( klass ) . toc_info )
31
+ final . push ( klass . toc_info )
24
32
end
25
33
26
34
final
Original file line number Diff line number Diff line change @@ -5,22 +5,30 @@ module ResourceTypes
5
5
6
6
# @return [Array] list of resource types
7
7
def self . in_rtypes
8
- YARD ::Registry . all ( :puppet_type ) . sort_by! ( &:name ) . map! ( &:to_hash )
8
+ arr = YARD ::Registry . all ( :puppet_type ) . sort_by! ( &:name ) . map! ( &:to_hash )
9
+ arr . map! { |a | PuppetStrings ::Markdown ::ResourceType . new ( a ) }
10
+ end
11
+
12
+ def self . contains_private?
13
+ result = false
14
+ unless in_rtypes . nil?
15
+ in_rtypes . find { |type | type . private? } . nil? ? false : true
16
+ end
9
17
end
10
18
11
19
def self . render
12
20
final = in_rtypes . length > 0 ? "## Resource types\n \n " : ""
13
21
in_rtypes . each do |type |
14
- final << PuppetStrings :: Markdown :: ResourceType . new ( type ) . render
22
+ final << type . render unless type . private?
15
23
end
16
24
final
17
25
end
18
26
19
27
def self . toc_info
20
- final = [ ]
28
+ final = [ "Resource types" ]
21
29
22
30
in_rtypes . each do |type |
23
- final . push ( PuppetStrings :: Markdown :: ResourceType . new ( type ) . toc_info )
31
+ final . push ( type . toc_info )
24
32
end
25
33
26
34
final
Original file line number Diff line number Diff line change 1
1
module PuppetStrings ::Markdown
2
2
module TableOfContents
3
3
def self . render
4
- puppet_classes = PuppetStrings ::Markdown ::PuppetClasses . toc_info
5
- puppet_defined_types = PuppetStrings ::Markdown ::DefinedTypes . toc_info
6
- puppet_resource_types = PuppetStrings ::Markdown ::ResourceTypes . toc_info
7
- puppet_functions = PuppetStrings ::Markdown ::Functions . toc_info
4
+ final = ""
8
5
9
- template = File . join ( File . dirname ( __FILE__ ) , "templates/table_of_contents.erb" )
10
- ERB . new ( File . read ( template ) , nil , '-' ) . result ( binding )
6
+ [ PuppetStrings ::Markdown ::PuppetClasses ,
7
+ PuppetStrings ::Markdown ::DefinedTypes ,
8
+ PuppetStrings ::Markdown ::ResourceTypes ,
9
+ PuppetStrings ::Markdown ::Functions ] . each do |r |
10
+ toc = r . toc_info
11
+ group_name = toc . shift
12
+ group = toc
13
+ priv = r . contains_private?
14
+
15
+ template = File . join ( File . dirname ( __FILE__ ) , "templates/table_of_contents.erb" )
16
+ final << ERB . new ( File . read ( template ) , nil , '-' ) . result ( binding )
17
+ end
18
+ final
11
19
end
12
20
end
13
21
end
Original file line number Diff line number Diff line change 1
1
### <%= name %>
2
2
3
+ <% if text -%>
4
+ <%= text %>
5
+
6
+ <% elsif summary -%>
7
+ <%= summary %>
8
+
9
+ <% else -%>
10
+ <%= "The #{name} class." %>
11
+
12
+ <% end -%>
3
13
<% if since -%>
4
14
* **Since** <%= since %>
5
15
Original file line number Diff line number Diff line change 1
1
### <%= name %>
2
2
Type: <%= type %>
3
3
4
+ <% if text -%>
5
+ <%= text %>
6
+
7
+ <% elsif summary -%>
8
+ <%= summary %>
9
+
10
+ <% else -%>
11
+ <%= "The #{name} class." %>
12
+
13
+ <% end -%>
4
14
<% signatures.each do |sig| -%>
5
15
#### `<%= sig.signature %> `
6
16
Original file line number Diff line number Diff line change 1
1
### <%= name %>
2
2
3
+ <% if text -%>
4
+ <%= text %>
5
+
6
+ <% elsif summary -%>
7
+ <%= summary %>
8
+
9
+ <% else -%>
10
+ <%= "The #{name} type." %>
11
+
12
+ <% end -%>
3
13
<% if since -%>
4
14
* **Since** <%= since %>
5
15
12
22
<% end -%>
13
23
14
24
<% end -%>
15
- <% if text -%>
16
- <%= text %>
17
- <% end %>
18
25
<% if examples -%>
19
26
#### Examples
20
27
<% examples.each do |eg| -%>
Original file line number Diff line number Diff line change 1
- <% if puppet_classes.length > 0 -%>
2
- ## Classes
3
- <% puppet_classes.each do |klassy| -%>
4
- * [`<%= klassy[:name] %> `](#<%= klassy[:link] %> ): <%= klassy[:desc] %>
1
+ <% if group.length > 0 -%>
2
+ ## <%= group_name %>
3
+ <% if priv -%>
4
+ ### Public <%= group_name %>
5
+ <% group.each do |item| -%>
6
+ <% unless item[:private] -%>
7
+ * [`<%= item[:name] %> `](#<%= item[:link] %> ): <%= item[:desc] %>
5
8
<% end -%>
6
9
<% end -%>
7
- <% if puppet_defined_types.length > 0 - %>
8
- ## Defined types
9
- <% puppet_defined_types.each do |dtype| -%>
10
- * [ `<%= dtype [:name] %> `](# <%= dtype[:link] %> ): <%= dtype [:desc] %>
10
+ ### Private <%= group_name %>
11
+ <% group.each do |item| -%>
12
+ <% if item[:private] -%>
13
+ * `<%= item [:name] %> `: <%= item [:desc] %>
11
14
<% end -%>
12
15
<% end -%>
13
- <% if puppet_resource_types.length > 0 -%>
14
- ## Resource types
15
- <% puppet_resource_types.each do |rtype| -%>
16
- * [`<%= rtype[:name] %> `](#<%= rtype[:link] %> ): <%= rtype[:desc] %>
16
+ <% else -%>
17
+ <% group.each do |item| -%>
18
+ * [`<%= item[:name] %> `](#<%= item[:link] %> ): <%= item[:desc] %>
17
19
<% end -%>
18
20
<% end -%>
19
- <% if puppet_functions.length > 0 -%>
20
- ## Functions
21
- <% puppet_functions.each do |func| -%>
22
- * [`<%= func[:name] %> `](#<%= func[:link] %> ): <%= func[:desc] %>
23
- <% end -%>
24
21
<% end -%>
You can’t perform that action at this time.
0 commit comments