diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2010-06-06 18:03:18 +0200 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 3a44f0e4826b8677323d3c1be55263dfa94f3305 (patch) | |
| tree | c39e30693935c73a46381316031ab5b7615332a9 | |
| parent | fb5c1d7bbe629df6214af9b47e522fb282983beb (diff) | |
| download | puppet-3a44f0e4826b8677323d3c1be55263dfa94f3305.tar.gz puppet-3a44f0e4826b8677323d3c1be55263dfa94f3305.tar.xz puppet-3a44f0e4826b8677323d3c1be55263dfa94f3305.zip | |
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@daysofwonder.com>
| -rwxr-xr-x | bin/puppetdoc | 5 | ||||
| -rw-r--r-- | lib/puppet/application/doc.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/util/rdoc.rb | 3 | ||||
| -rwxr-xr-x | spec/unit/application/doc.rb | 15 | ||||
| -rwxr-xr-x | spec/unit/util/rdoc.rb | 6 |
5 files changed, 25 insertions, 7 deletions
diff --git a/bin/puppetdoc b/bin/puppetdoc index 849b5338b..400a58251 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 5da7040ae..ba010022d 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 fc4e2c6cd..cb9610c0a 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 960ef7ac6..db805fe7e 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 25c94a1c7..4417fca00 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") } |
