summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-08-28 16:30:49 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-08-28 16:30:49 +0000
commitd45d22b7547a608c7821905024f530bbae1259d7 (patch)
tree018f311b26a7854271524beba90a778918bd7ee6 /lib/puppet/util
parente1aff4cd2f456bfc9567e9be5dd73b3c8ed14ec9 (diff)
downloadpuppet-d45d22b7547a608c7821905024f530bbae1259d7.tar.gz
puppet-d45d22b7547a608c7821905024f530bbae1259d7.tar.xz
puppet-d45d22b7547a608c7821905024f530bbae1259d7.zip
Adding a module specifically for making doc generation easier, and adding defaults info to provider docs.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1504 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/classgen.rb1
-rw-r--r--lib/puppet/util/docs.rb27
-rw-r--r--lib/puppet/util/metaid.rb7
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/puppet/util/classgen.rb b/lib/puppet/util/classgen.rb
index c09fe5ae0..d7622cf93 100644
--- a/lib/puppet/util/classgen.rb
+++ b/lib/puppet/util/classgen.rb
@@ -4,7 +4,6 @@ module Puppet
end
module Puppet::Util::ClassGen
- include Puppet::Util::MetaID
include Puppet::Util::MethodHelper
include Puppet::Util
diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb
new file mode 100644
index 000000000..2fccd4abc
--- /dev/null
+++ b/lib/puppet/util/docs.rb
@@ -0,0 +1,27 @@
+# Some simple methods for helping manage automatic documentation generation.
+module Puppet::Util::Docs
+ # Specify the actual doc string.
+ def desc(str)
+ @doc = str
+ end
+
+ # Add a new autodoc block. We have to define these as class methods,
+ # rather than just sticking them in a hash, because otherwise they're
+ # too difficult to do inheritance with.
+ def dochook(name, &block)
+ method = "dochook_" + name.to_s
+
+ meta_def method, &block
+ end
+
+ # Generate the full doc string.
+ def doc
+ extra = methods.find_all { |m| m.to_s =~ /^dochook_.+/ }.collect { |m|
+ self.send(m)
+ }.join(" ")
+
+ @doc + extra
+ end
+end
+
+# $Id$
diff --git a/lib/puppet/util/metaid.rb b/lib/puppet/util/metaid.rb
index 7054989db..0978e7b32 100644
--- a/lib/puppet/util/metaid.rb
+++ b/lib/puppet/util/metaid.rb
@@ -1,4 +1,4 @@
-module Puppet::Util::MetaID
+class Object
# The hidden singleton lurks behind everyone
def metaclass; class << self; self; end; end
def meta_eval(&blk); metaclass.instance_eval(&blk); end
@@ -8,6 +8,11 @@ module Puppet::Util::MetaID
meta_eval { define_method name, &blk }
end
+ # Remove metaclass methods.
+ def meta_undef(name, &blk)
+ meta_eval { remove_method name }
+ end
+
# Defines an instance method within a class
def class_def(name, &blk)
class_eval { define_method name, &blk }