summaryrefslogtreecommitdiffstats
path: root/bin/puppetdoc
diff options
context:
space:
mode:
Diffstat (limited to 'bin/puppetdoc')
-rwxr-xr-xbin/puppetdoc129
1 files changed, 129 insertions, 0 deletions
diff --git a/bin/puppetdoc b/bin/puppetdoc
new file mode 100755
index 000000000..e64ca0624
--- /dev/null
+++ b/bin/puppetdoc
@@ -0,0 +1,129 @@
+#!/usr/local/bin/ruby
+#!/usr/bin/ruby -w
+
+#--------------------
+# produce documentation on all of the puppet types
+#
+# $Id$
+
+
+$:.unshift '../lib'
+
+require 'puppet'
+require 'getoptlong'
+
+def tab(num)
+ return $tab * num
+end
+
+result = GetoptLong.new(
+ [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
+
+debug = false
+logfile = false
+
+$tab = " "
+
+result.each { |opt,arg|
+ case opt
+ when "--help"
+ puts "There is no help yet"
+ exit
+ when "--debug"
+ debug = true
+ when "--logfile"
+ logfile = arg
+ else
+ raise "Invalid option '#{opt}'"
+ 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