1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#!/usr/bin/ruby
#
# = Synopsis
#
# Generate a reference for all Puppet types. Largely meant for internal Reductive
# Labs use.
#
# = Usage
#
# puppetdoc [-h|--help]
#
# = Description
#
# This command generates a restructured-text document describing all installed
# Puppet types. It is largely meant for internal use and is used to generate
# the reference document available on the Reductive Labs web site.
#
# = Options
#
# help::
# Print this help message
#
# = Example
#
# $ puppetdoc > /tmp/reference.rst
#
# = Author
#
# Luke Kanies
#
# = Copyright
#
# Copyright (c) 2005 Reductive Labs, LLC
# Licensed under the GNU Public License
require 'puppet'
require 'getoptlong'
$haveusage = true
begin
require 'rdoc/usage'
rescue
$haveusage = false
end
def tab(num)
return $tab * num
end
result = GetoptLong.new(
[ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
debug = false
$tab = " "
begin
result.each { |opt,arg|
case opt
when "--help"
if $haveusage
RDoc::usage && exit
else
puts "No help available unless you have RDoc::usage installed"
exit
end
end
}
rescue GetoptLong::InvalidOption => detail
$stderr.puts "Try '#{$0} --help'"
#if $haveusage
# RDoc::usage_no_exit('usage')
#end
exit(1)
end
puts %{
==============
Type Reference
==============
}
types = {}
Puppet::Type.eachtype { |type|
types[type.name] = type
}
puts %{
---------------
Meta-Parameters
---------------
}
Puppet::Type.eachmetaparam { |param|
puts "- **" + param.to_s + "**"
puts tab(1) + Puppet::Type.metaparamdoc(param).gsub(/\n\s*/,' ')
}
puts %{
-----
Types
-----
- *namevar* is the parameter used to uniquely identify a type instance.
This is the parameter that gets assigned when a string is provided before
the colon in a type declaration.
- *states* are the aspects of a type that can be changed.
- *params* control how a type implements the state changes.
}
types.sort { |a,b|
a.to_s <=> b.to_s
}.each { |name,type|
next if name == :puppet
next if name == :component
puts "
----------------
"
puts "
%s
%s" % [name, "=" * (name.to_s.length + 4)]
#String.new('n%s\n') % name.to_s
#puts "**" + type.doc.gsub(/\n\s*/, ' ') + "**\n\n"
puts type.doc.gsub(/\n\s*/, ' ') + "\n\n"
type.buildstatehash
#puts tab(1) + "* namevar: %s" % type.namevar
puts "%s States\n'''''''''''''''''''''''''''''''" % name.to_s.capitalize
type.validstates.sort { |a,b|
a.to_s <=> b.to_s
}.each { |sname,state|
puts "- **%s**" % sname
puts tab(1) + state.doc.gsub(/\n\s*/,' ')
}
puts "\n%s Parameters\n''''''''''''''''''''''''''''''" % name.to_s.capitalize
type.parameters.sort { |a,b|
a.to_s <=> b.to_s
}.each { |name,param|
print "- **%s**" % name
if type.namevar == name and name != :name
puts " (*namevar*)"
else
puts ""
end
puts tab(1) + type.paramdoc(name).gsub(/\n\s*/,' ')
}
puts "\n"
}
puts "
----------------
"
puts "\n*This page autogenerated on %s*" % Time.now
# $Id$
|