[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Max Martin max at puppetlabs.com
Tue May 10 08:05:56 UTC 2011


The following commit has been merged in the experimental branch:
commit 28ce355be0a16caa8e1cc0b6f531d2be070ca6f2
Author: Matt Robinson <matt at puppetlabs.com>
Date:   Mon Mar 7 16:48:09 2011 -0800

    maint: Fix rdoc when documenting manifest files
    
    The structure of the AST has changed from 2.6.x to master, so the code
    to generate documentation from the AST had to change.
    
    Generating documentation for resources other than classes, nodes and
    defines is still broken, see ticket #6634
    
    Paired-with: Daniel Pittman <daniel at puppetlabs.com>

diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb
index bdac579..16d1fa1 100644
--- a/lib/puppet/util/rdoc.rb
+++ b/lib/puppet/util/rdoc.rb
@@ -53,17 +53,10 @@ module Puppet::Util::RDoc
   # of a manifest
   def output(file, ast)
     astobj = []
-    ast.nodes.each do |name, k|
-      astobj << k if k.file == file
+    ast.instantiate('').each do |resource_type|
+      astobj << resource_type if resource_type.file == file
     end
 
-    ast.hostclasses.each do |name,k|
-      astobj << k if k.file == file
-    end
-
-    ast.definitions.each do |name, k|
-      astobj << k if k.file == file
-    end
     astobj.sort! {|a,b| a.line <=> b.line }.each do |k|
       output_astnode_doc(k)
     end
@@ -89,4 +82,4 @@ module Puppet::Util::RDoc
     end
   end
 
-end
\ No newline at end of file
+end
diff --git a/spec/fixtures/unit/util/rdoc/basic.pp b/spec/fixtures/unit/util/rdoc/basic.pp
new file mode 100644
index 0000000..5616503
--- /dev/null
+++ b/spec/fixtures/unit/util/rdoc/basic.pp
@@ -0,0 +1,16 @@
+# im a class
+class foo {
+  file { '/tmp/foo' :
+    ensure => present,
+  }
+}
+
+# im a node
+node gar {
+}
+
+# im a define
+define baz { }
+
+# im a resource
+host { 'cow' : }
diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb
index 41d4b9c..93c4f9b 100755
--- a/spec/unit/util/rdoc_spec.rb
+++ b/spec/unit/util/rdoc_spec.rb
@@ -123,63 +123,25 @@ describe Puppet::Util::RDoc do
     end
 
     describe "when outputing documentation" do
-      before :each do
-        @node = stub 'node', :file => "file", :line => 1, :doc => ""
-        @class = stub 'class', :file => "file", :line => 4, :doc => ""
-        @definition = stub 'definition', :file => "file", :line => 3, :doc => ""
-        @ast = stub 'ast', :nodes => { :node => @node }, :hostclasses => { :class => @class }, :definitions => { :definition => @definition }
-      end
-
-      it "should output doc for ast nodes" do
-        @node.expects(:doc)
-
-        Puppet::Util::RDoc.output("file", @ast)
-      end
-
-      it "should output doc for ast classes" do
-        @class.expects(:doc)
-
-        Puppet::Util::RDoc.output("file", @ast)
-      end
-
-      it "should output doc for ast definitions" do
-        @definition.expects(:doc)
-
-        Puppet::Util::RDoc.output("file", @ast)
-      end
-
-      it "should output doc in order of increasing line number" do
-        byline = sequence('byline')
-        @node.expects(:doc).in_sequence(byline)
-        @definition.expects(:doc).in_sequence(byline)
-        @class.expects(:doc).in_sequence(byline)
-
-        Puppet::Util::RDoc.output("file", @ast)
-      end
-
-      it "should not output documentation of ast object of another node" do
-        klass = stub 'otherclass', :file => "otherfile", :line => 12, :doc => ""
-        @ast.stubs(:hostclasses).returns({ :otherclass => klass })
-
-        klass.expects(:doc).never
-
-        Puppet::Util::RDoc.output("file", @ast)
+      it "should output doc for ast classes, nodes and definitions in order of increasing line number" do
+        byline = sequence('documentation outputs in line order')
+        Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline)
+        Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline)
+        Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline)
+        # any other output must fail
+        Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')])
       end
 
       it "should output resource documentation if needed" do
-        Puppet.settings.stubs(:[]).with(:document_all).returns(true)
-        [@node, at definition].each do |o|
-          o.stubs(:code).returns([])
-        end
-
-        resource = stub_everything 'resource', :line => 1
-        resource.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
-        resource.stubs(:is_a?).with(Puppet::Parser::AST::Resource).returns(true)
-        @class.stubs(:code).returns([resource])
-
-        resource.expects(:doc)
-
-        Puppet::Util::RDoc.output("file", @ast)
+        pending "#6634 being fixed"
+        Puppet.settings[:document_all] = true
+        byline = sequence('documentation outputs in line order')
+        Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline)
+        Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline)
+        Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline)
+        Puppet::Util::RDoc.expects(:puts).with("im a resource\n").in_sequence(byline)
+        # any other output must fail
+        Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')])
       end
     end
   end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list