puppet_readme_generator 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e785cee37db01e0ea247e8fee2f9c3bd28918864
4
- data.tar.gz: 925b80d0a901a692e194ba5c839c442269e250cf
3
+ metadata.gz: 11ba11909aa54848a0b43a9909400c631663993d
4
+ data.tar.gz: 92ed07c0a6134e264f188bae8d70d7dddc4ae517
5
5
  SHA512:
6
- metadata.gz: 7e11e592e70ca62e79e7b7603eb7ed350ca734c2cd9e12a1c1fe7d834a2b97c4ea0fe32f61e7b66b9f2594fe90cf0eaf1d5b29ab6deb8b759a8a9e1c2d506de1
7
- data.tar.gz: 67d437f96e5fbdc0cb7090c1642c7b65853eb0b9af0aad95558971a620a2129792c6e214f3c851be4739a7ac76668547ae599bf65fc3f95f53048d31223fd575
6
+ metadata.gz: 9a16d21bff53fa4a2e5af2840b817e254f1d0660d8e8b803278eb62bac34a5fa5a841e6870b5607b296de8d10782305e4b2d7aaca90c34a4720c9871a72e9efb
7
+ data.tar.gz: 53a750b20dfaf63ce7f3d47bacfbecb887252944f9e49a6c77fb90fee2d6721d3dde128c93d561ec5da4aeeb80bf6ddd61522e0a573d0a74620a47f719148c66
@@ -1,3 +1,3 @@
1
1
  module PuppetReadmeGenerator
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -15,24 +15,44 @@ module PuppetReadmeGenerator
15
15
  output = []
16
16
  output << "# #{puppet_module}\n"
17
17
  output << "#### Table of Contents\n"
18
- output << '1. [Description](#description)'
19
- output << '2. [Classes](#classes)'
20
- output << '3. [Defined Types](#defined-types)'
21
18
 
22
- output << '## Description'
23
- output << main_class.text
24
- output << ''
19
+ count = 1
25
20
 
26
- output << '## Classes'
27
- classes.each do |c|
28
- output << ''
29
- output << c.markdown
21
+ unless main_class.nil?
22
+ output << "#{count}. [Description](#description)"
23
+ count += 1
24
+ end
25
+
26
+ if classes.length > 0
27
+ output << "#{count}. [Classes](#classes)"
28
+ count += 1
30
29
  end
31
30
 
32
- output << '## DefinedTypes'
33
- defined_types.each do |dt|
31
+ if defined_types.length > 0
32
+ output << "#{count}. [Defined Types](#defined-types)"
33
+ count += 1
34
+ end
35
+
36
+ unless main_class.nil?
37
+ output << '## Description'
38
+ output << main_class.text
34
39
  output << ''
35
- output << dt.markdown
40
+ end
41
+
42
+ if classes.length > 0
43
+ output << '## Classes'
44
+ classes.each do |c|
45
+ output << ''
46
+ output << c.markdown
47
+ end
48
+ end
49
+
50
+ if defined_types.length > 0
51
+ output << '## DefinedTypes'
52
+ defined_types.each do |dt|
53
+ output << ''
54
+ output << dt.markdown
55
+ end
36
56
  end
37
57
 
38
58
  output.join("\n")
@@ -100,9 +120,12 @@ module PuppetReadmeGenerator
100
120
  def examples
101
121
  if @examples.nil?
102
122
  @examples = []
103
- @c['docstring']['tags'].each do |t|
104
- next unless t['tag_name'] == 'example'
105
- @examples << Example.new(t, self)
123
+ begin
124
+ @c['docstring']['tags'].each do |t|
125
+ next unless t['tag_name'] == 'example'
126
+ @examples << Example.new(t, self)
127
+ end
128
+ rescue NoMethodError
106
129
  end
107
130
  end
108
131
  @examples
@@ -111,9 +134,12 @@ module PuppetReadmeGenerator
111
134
  def params
112
135
  if @params.nil?
113
136
  @params = []
114
- @c['docstring']['tags'].each do |t|
115
- next unless t['tag_name'] == 'param'
116
- @params << Param.new(t, self)
137
+ begin
138
+ @c['docstring']['tags'].each do |t|
139
+ next unless t['tag_name'] == 'param'
140
+ @params << Param.new(t, self)
141
+ end
142
+ rescue NoMethodError
117
143
  end
118
144
  end
119
145
  @params
@@ -125,14 +151,18 @@ module PuppetReadmeGenerator
125
151
  output << text
126
152
  output << ''
127
153
 
128
- output << "#### Parameters\n"
129
- params.each do |p|
130
- output << p.markdown
154
+ if params.length > 0
155
+ output << "#### Parameters\n"
156
+ params.each do |p|
157
+ output << p.markdown
158
+ end
131
159
  end
132
160
 
133
- output << "#### Examples\n"
134
- examples.each do |e|
135
- output << e.markdown
161
+ if examples.length > 0
162
+ output << "#### Examples\n"
163
+ examples.each do |e|
164
+ output << e.markdown
165
+ end
136
166
  end
137
167
 
138
168
  output.join("\n")
@@ -158,8 +188,17 @@ module PuppetReadmeGenerator
158
188
  def markdown
159
189
  output = []
160
190
  output << "##### `#{@t['name']}`\n"
161
- output << "* #{@t['text']}"
162
- output << "* Type: `#{@t['types']}`"
191
+
192
+ if not @t['text'].nil? and @t['text'].length > 0
193
+ output << "* #{@t['text']}"
194
+ end
195
+
196
+ ptype = @t['types']
197
+ if not ptype.nil? and ptype.length > 1
198
+ output << "* Type: `#{ptype}`"
199
+ elsif not ptype.nil? and ptype.length == 1
200
+ output << "* Type: `#{ptype.first}`"
201
+ end
163
202
  default = @p.defaults[@t['name']]
164
203
  output << "* Default: `#{default}`" unless default.nil?
165
204
  output << ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_readme_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Simon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2017-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler