[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

James Turnbull james at lovedthanlost.net
Wed Jul 14 10:29:26 UTC 2010


The following commit has been merged in the upstream branch:
commit ced5a7887836d1491273b5d6728589f494f8a337
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Tue Oct 13 23:47:06 2009 +0200

    Fix #2376 - Display class/node inheritance in puppetdoc
    
    While we were keeping track of superclass/nodes during RDoc generation
    we weren't doing the reverse.
    This patch enhance Puppetdoc RDoc mode by tracking inheritance and
    for each base/super class/nodes displays the list of inherited classes
    /nodes.
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb
index 056f376..be5e468 100644
--- a/lib/puppet/util/rdoc/code_objects.rb
+++ b/lib/puppet/util/rdoc/code_objects.rb
@@ -88,12 +88,13 @@ module RDoc
     # It is mapped to a HTMLPuppetClass for display
     # It leverages RDoc (ruby) Class
     class PuppetClass < ClassModule
-        attr_accessor :resource_list, :requires
+        attr_accessor :resource_list, :requires, :childs
 
         def initialize(name, superclass)
             super(name,superclass)
             @resource_list = []
             @requires = []
+            @childs = []
         end
 
         def add_resource(resource)
@@ -114,6 +115,10 @@ module RDoc
         def add_require(required)
             add_to(@requires, required)
         end
+
+        def add_child(child)
+            @childs << child
+        end
     end
 
     # PuppetNode holds a puppet node
diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb
index b7055e7..f06879f 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -136,6 +136,15 @@ module Generators
                 @allfiles << { "file" => file, "modules" => modules, "classes" => classes, "methods" => methods, "nodes" => nodes }
             end
 
+            # scan all classes to create the childs references
+            @allclasses.values.each do |klass|
+                if superklass = klass.context.superclass
+                    if superklass = AllReferences[superklass] and (superklass.is_a?(HTMLPuppetClass) or superklass.is_a?(HTMLPuppetNode))
+                        superklass.context.add_child(klass.context)
+                    end
+                end
+            end
+
             @classes = @allclasses.values
         end
 
@@ -400,12 +409,19 @@ module Generators
             rl = build_require_list(@context)
             @values["requires"] = rl unless rl.empty?
 
+            cl = build_child_list(@context)
+            @values["childs"] = cl unless cl.empty?
+
             @values
         end
 
         def build_require_list(context)
             build_referenced_list(context.requires)
         end
+
+        def build_child_list(context)
+            build_referenced_list(context.childs)
+        end
     end
 
     class HTMLPuppetNode < ContextUser
@@ -483,6 +499,9 @@ module Generators
             rl = build_require_list(@context)
             @values["requires"] = rl unless rl.empty?
 
+            cl = build_child_list(@context)
+            @values["childs"] = cl unless cl.empty?
+
             @values["sections"] = @context.sections.map do |section|
 
                 secdata = {
@@ -589,6 +608,10 @@ module Generators
             build_referenced_list(context.requires)
         end
 
+        def build_child_list(context)
+            build_referenced_list(context.childs)
+        end
+
         def <=>(other)
             self.name <=> other.name
         end
diff --git a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb
index c8f1e7d..bae9fc7 100644
--- a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb
+++ b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb
@@ -538,6 +538,7 @@ IF:description
     </div>
 ENDIF:description
 
+
 IF:toc
     <div id="contents-list">
       <h3 class="section-bar">Contents</h3>
@@ -549,6 +550,18 @@ END:toc
 ENDIF:toc
    </div>
 
+<!-- if childs -->
+IF:childs
+       <div id="childs">
+         <h3 class="section-bar">Inherited by</h3>
+         <div id="childs-list">
+START:childs
+           <span class="child-name">HREF:aref:name:</span>
+END:childs
+         </div>
+       </div>
+ENDIF:childs
+
 IF:methods
     <div id="method-list">
       <h3 class="section-bar">Defines</h3>

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list