diff options
| author | James Turnbull <james@lovedthanlost.net> | 2009-07-02 14:01:39 +1000 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-07-10 14:55:41 +1000 |
| commit | 44f127f738f6427bdf2adbe1d06d57b7b62e715e (patch) | |
| tree | 6165256ca9d30f70d409113c5b612fdf07fed843 /lib/puppet/util | |
| parent | 8a8ce9d40fd97b26906301b0587395c9fb9fddf6 (diff) | |
| download | puppet-44f127f738f6427bdf2adbe1d06d57b7b62e715e.tar.gz puppet-44f127f738f6427bdf2adbe1d06d57b7b62e715e.tar.xz puppet-44f127f738f6427bdf2adbe1d06d57b7b62e715e.zip | |
Added Markdown mode to puppetdoc to output Markdown.
Requires the pandoc binary to function (http://johnmacfarlane.net/pandoc/).
Diffstat (limited to 'lib/puppet/util')
| -rw-r--r-- | lib/puppet/util/reference.rb | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb index 40e49f45f..7526e6566 100644 --- a/lib/puppet/util/reference.rb +++ b/lib/puppet/util/reference.rb @@ -14,7 +14,7 @@ class Puppet::Util::Reference end def self.modes - %w{pdf trac text} + %w{pdf trac text markdown} end def self.newreference(name, options = {}, &block) @@ -57,14 +57,36 @@ class Puppet::Util::Reference $stderr.puts output # Now convert to pdf - puts "handling pdf" Dir.chdir("/tmp") do %x{texi2pdf puppetdoc.tex >/dev/null 2>/dev/null} end - #if FileTest.exists?("/tmp/puppetdoc.pdf") - # FileUtils.mv("/tmp/puppetdoc.pdf", "/export/apache/docroots/reductivelabs.com/htdocs/downloads/puppet/reference.pdf") - #end + end + + def self.markdown(name, text) + puts "Creating markdown for #{name} reference." + dir = "/tmp/" + Puppet::PUPPETVERSION + FileUtils.mkdir(dir) unless File.directory?(dir) + File.open(dir + "/" + "#{name}.rst", "w") do |f| + f.puts text + end + pandoc = %x{which pandoc} + if $? != 0 or pandoc =~ /no / + pandoc = %x{which pandoc} + end + if $? != 0 or pandoc =~ /no / + raise "Could not find pandoc" + end + pandoc.chomp! + cmd = %{#{pandoc} -s -r rst -w markdown #{dir}/#{name}.rst -o #{dir}/#{name}.mdwn} + output = %x{#{cmd}} + unless $? == 0 + $stderr.puts "Pandoc failed to create #{name} reference." + $stderr.puts output + exit(1) + end + + File.unlink(dir + "/" + "#{name}.rst") end def self.references |
