summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/application')
-rw-r--r--lib/puppet/application/puppetdoc.rb30
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/puppet/application/puppetdoc.rb b/lib/puppet/application/puppetdoc.rb
index 99e46cfd1..45aba42ea 100644
--- a/lib/puppet/application/puppetdoc.rb
+++ b/lib/puppet/application/puppetdoc.rb
@@ -58,8 +58,7 @@ Puppet::Application.new(:puppetdoc) do
end
dispatch do
- return :rdoc if options[:mode] == :rdoc
- return :trac if options[:mode] == :trac
+ return options[:mode] if [:rdoc, :trac, :markdown].include?(options[:mode])
return :other
end
@@ -101,6 +100,31 @@ Puppet::Application.new(:puppetdoc) do
end
end
+ command(:markdown) do
+ text = ""
+ with_contents = false
+ exit_code = 0
+ options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name|
+ raise "Could not find reference %s" % name unless section = Puppet::Util::Reference.reference(name)
+
+ begin
+ # Add the per-section text, but with no ToC
+ text += section.send(options[:format], with_contents)
+ text += Puppet::Util::Reference.footer
+ text.gsub!(/`\w+\s+([^`]+)`:trac:/) { |m| $1 }
+ Puppet::Util::Reference.markdown(name, text)
+ text = ""
+ rescue => detail
+ puts detail.backtrace
+ $stderr.puts "Could not generate reference %s: %s" % [name, detail]
+ exit_code = 1
+ next
+ end
+ end
+
+ exit exit_code
+ end
+
command(:other) do
text = ""
if options[:references].length > 1
@@ -132,7 +156,7 @@ Puppet::Application.new(:puppetdoc) do
if options[:mode] == :pdf
Puppet::Util::Reference.pdf(text)
- else
+ else
puts text
end