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

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:35:07 UTC 2010


The following commit has been merged in the upstream branch:
commit 3a44f0e4826b8677323d3c1be55263dfa94f3305
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Sun Jun 6 18:03:18 2010 +0200

    Fix #3932 - Add --charset to puppetdoc for RDoc mode
    
    This adds the --charset option to puppetdoc for RDoc mode.
    This allows to set the charset for the generated html.
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/bin/puppetdoc b/bin/puppetdoc
index 849b533..400a582 100755
--- a/bin/puppetdoc
+++ b/bin/puppetdoc
@@ -9,7 +9,7 @@
 # = Usage
 #
 #   puppet doc [-a|--all] [-h|--help] [-o|--outputdir <rdoc outputdir>] [-m|--mode <text|pdf|markdown|trac|rdoc>]
-#              [-r|--reference <[type]|configuration|..>] [manifest-file]
+#              [-r|--reference <[type]|configuration|..>] [--charset CHARSET] [manifest-file]
 #
 # = Description
 #
@@ -42,6 +42,9 @@
 # reference::
 #   Build a particular reference.  Get a list of references by running +puppet doc --list+.
 #
+# charset::
+#   Used only in 'rdoc' mode. It sets the charset used in the html files produced.
+#
 # = Example
 #
 #   $ puppet doc -r type > /tmp/type_reference.rst
diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb
index 5da7040..ba01002 100644
--- a/lib/puppet/application/doc.rb
+++ b/lib/puppet/application/doc.rb
@@ -19,6 +19,7 @@ class Puppet::Application::Doc < Puppet::Application
     option("--outputdir OUTPUTDIR","-o")
     option("--verbose","-v")
     option("--debug","-d")
+    option("--charset CHARSET")
 
     option("--format FORMAT", "-f") do |arg|
         method = "to_%s" % arg
@@ -79,7 +80,7 @@ class Puppet::Application::Doc < Puppet::Application
                 Puppet::Util::RDoc.manifestdoc(files)
             else
                 options[:outputdir] = "doc" unless options[:outputdir]
-                Puppet::Util::RDoc.rdoc(options[:outputdir], files)
+                Puppet::Util::RDoc.rdoc(options[:outputdir], files, options[:charset])
             end
         rescue => detail
             if Puppet[:trace]
diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb
index fc4e2c6..cb9610c 100644
--- a/lib/puppet/util/rdoc.rb
+++ b/lib/puppet/util/rdoc.rb
@@ -5,7 +5,7 @@ module Puppet::Util::RDoc
 
     # launch a rdoc documenation process
     # with the files/dir passed in +files+
-    def rdoc(outputdir, files)
+    def rdoc(outputdir, files, charset = nil)
         begin
             Puppet[:ignoreimport] = true
 
@@ -26,6 +26,7 @@ module Puppet::Util::RDoc
                         "--exclude", "/modules/[^/]*/files/.*\.pp$",
                         "--op", outputdir ]
 
+            options += [ "--charset", charset] if charset
             options += files
 
             # launch the documentation process
diff --git a/spec/unit/application/doc.rb b/spec/unit/application/doc.rb
index 960ef7a..db805fe 100755
--- a/spec/unit/application/doc.rb
+++ b/spec/unit/application/doc.rb
@@ -60,7 +60,7 @@ describe Puppet::Application::Doc do
     end
 
     describe "when handling options" do
-        [:all, :outputdir, :verbose, :debug].each do |option|
+        [:all, :outputdir, :verbose, :debug, :charset].each do |option|
             it "should declare handle_#{option} method" do
                 @doc.should respond_to("handle_#{option}".to_sym)
             end
@@ -299,6 +299,7 @@ describe Puppet::Application::Doc do
                 Puppet.stubs(:[]).with(:manifestdir).returns('manifests')
                 @doc.options.stubs(:[]).with(:all).returns(false)
                 @doc.options.stubs(:[]).with(:outputdir).returns('doc')
+                @doc.options.stubs(:[]).with(:charset).returns(nil)
                 Puppet.settings.stubs(:[]=).with(:document_all, false)
                 Puppet.settings.stubs(:setdefaults)
                 Puppet::Util::RDoc.stubs(:rdoc)
@@ -316,13 +317,19 @@ describe Puppet::Application::Doc do
             end
 
             it "should call Puppet::Util::RDoc.rdoc in full mode" do
-                Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'])
+                Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'], nil)
+                @doc.rdoc
+            end
+
+            it "should call Puppet::Util::RDoc.rdoc with a charset if --charset has been provided" do
+                @doc.options.expects(:[]).with(:charset).returns("utf-8")
+                Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'], "utf-8")
                 @doc.rdoc
             end
 
             it "should call Puppet::Util::RDoc.rdoc in full mode with outputdir set to doc if no --outputdir" do
                 @doc.options.expects(:[]).with(:outputdir).returns(false)
-                Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'])
+                Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'], nil)
                 @doc.rdoc
             end
 
@@ -336,7 +343,7 @@ describe Puppet::Application::Doc do
                 @env.expects(:modulepath).returns(['envmodules1','envmodules2'])
                 @env.expects(:[]).with(:manifest).returns('envmanifests/site.pp')
 
-                Puppet::Util::RDoc.expects(:rdoc).with('doc', ['envmodules1','envmodules2','envmanifests'])
+                Puppet::Util::RDoc.expects(:rdoc).with('doc', ['envmodules1','envmodules2','envmanifests'], nil)
 
                 @doc.rdoc
             end
diff --git a/spec/unit/util/rdoc.rb b/spec/unit/util/rdoc.rb
index 25c94a1..4417fca 100755
--- a/spec/unit/util/rdoc.rb
+++ b/spec/unit/util/rdoc.rb
@@ -37,6 +37,12 @@ describe Puppet::Util::RDoc do
             Puppet::Util::RDoc.rdoc("output", [])
         end
 
+        it "should pass charset to RDoc" do
+            @rdoc.expects(:document).with { |args| args.include?("--charset") and args.include?("utf-8") }
+
+            Puppet::Util::RDoc.rdoc("output", [], "utf-8")
+        end
+
         it "should tell RDoc to force updates of indices" do
             @rdoc.expects(:document).with { |args| args.include?("--force-update") }
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list