From 0ae4732fd9058c2ae67f664c545dbd1846cef2df Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 7 Jun 2011 16:52:39 -0700 Subject: (#7828) Fix whitespace in synopsis generator. We accidentally omitted whitespace between multiple options while building the synopsis. This fixes that, by introducing a breakable space in the right location. Additionally, we extract the code that was 99 percent identical from the face and action synopsis generators, push it down into the documentation module, and then invoke it from both places. This eliminates the duplicate code, allowing me to fix that bug once and have it apply to both parts of the code; this is pretty much assured to be true any time we change the synopsis generation. Reviewed-By: Nick Fagerlund --- lib/puppet/interface/documentation.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/puppet/interface/documentation.rb') diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index fcaec2568..47e478a44 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -61,6 +61,37 @@ class Puppet::Interface end attr_doc :description + + def build_synopsis(face, action = nil, arguments = nil) + output = PrettyPrint.format do |s| + s.text("puppet #{face}") + s.text(" #{action}") unless action.nil? + s.text(" ") + + options.each do |option| + option = get_option(option) + wrap = option.required? ? %w{ < > } : %w{ [ ] } + + s.group(0, *wrap) do + option.optparse.each do |item| + unless s.current_group.first? + s.breakable + s.text '|' + s.breakable + end + s.text item + end + end + + s.breakable + end + + if arguments then + s.text arguments.to_s + end + end + end + end module FullDocs -- cgit