[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Brice Figureau brice-puppet at daysofwonder.com
Thu Mar 17 10:46:12 UTC 2011


The following commit has been merged in the upstream branch:
commit 90905073a6e1136c80cd59dca1a9594f4a859126
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Sat Feb 12 13:32:24 2011 +0100

    Fix #6267 - puppetdoc embedded links to puppet entities are not hyperlinked
    
    Puppetdoc was relying on RDoc to provide the puppet entity (class, definition
    node, etc...) hyperlinking in comments.
    Unfortunately, RDoc was assuming namespaces are capitalized like Ruby
    namespaces and that definition would use the # or . separator.
    
    This change adds on top of RDoc puppet namespace format for classes and
    definition.
    
    This will make sure the comment hyperlinking will work as intented.
    
    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 3854fbc..3c789a0 100644
--- a/lib/puppet/util/rdoc/code_objects.rb
+++ b/lib/puppet/util/rdoc/code_objects.rb
@@ -124,6 +124,45 @@ module RDoc
     def add_child(child)
       @childs << child
     end
+
+    # Look up the given symbol. RDoc only looks for class1::class2.method
+    # or class1::class2#method. Since our definitions are mapped to RDoc methods
+    # but are written class1::class2::define we need to perform the lookup by
+    # ourselves.
+    def find_symbol(symbol, method=nil)
+      result = super
+      if not result and symbol =~ /::/
+        modules = symbol.split(/::/)
+        unless modules.empty?
+          module_name = modules.shift
+          result = find_module_named(module_name)
+          if result
+            last_name = ""
+            previous = nil
+            modules.each do |module_name|
+              previous = result
+              last_name = module_name
+              result = result.find_module_named(module_name)
+              break unless result
+            end
+            unless result
+              result = previous
+              method = last_name
+            end
+          end
+        end
+        if result && method
+          if !result.respond_to?(:find_local_symbol)
+            p result.name
+            p method
+            fail
+          end
+          result = result.find_local_symbol(method)
+        end
+      end
+      result
+    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 e6bbb2e..249c9a8 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -31,6 +31,24 @@ module Generators
   NODE_DIR = "nodes"
   PLUGIN_DIR = "plugins"
 
+  # We're monkey patching RDoc markup to allow
+  # lowercase class1::class2::class3 crossref hyperlinking
+  module MarkUp
+    alias :old_markup :markup
+
+    def new_markup(str, remove_para=false)
+      first = @markup.nil?
+      res = old_markup(str, remove_para)
+      if first and not @markup.nil?
+        @markup.add_special(/\b([a-z]\w+(::\w+)*)/,:CROSSREF)
+        # we need to call it again, since we added a rule
+        res = old_markup(str, remove_para)
+      end
+      res
+    end
+    alias :markup :new_markup
+  end
+
   # This is a specialized HTMLGenerator tailored to Puppet manifests
   class PuppetGenerator < HTMLGenerator
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list