summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
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 }