From ebc642b2141cfed7d10a64ff0bb67a417f5f37be Mon Sep 17 00:00:00 2001 From: nfagerlund Date: Thu, 19 May 2011 12:04:59 -0700 Subject: (#6962) Add "arguments" method to help API Since some actions take arguments and some do not, action synopses were incomplete and ambiguous. This commit adds a method for explicitly declaring what argument(s) an action takes, and places the arguments at the appropriate spot in the action's synopsis. By convention, individual arguments should be wrapped in angle brackets. --- lib/puppet/interface/action.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 3c377a49f..748888c2e 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -46,6 +46,7 @@ class Puppet::Interface::Action ######################################################################## # Documentation... attr_doc :returns + attr_doc :arguments def synopsis output = PrettyPrint.format do |s| s.text("puppet #{@face.name}") @@ -67,6 +68,7 @@ class Puppet::Interface::Action end end end + s.text(" #{arguments}") if arguments end end -- cgit From 069a6b8e645255530abf308cfeeed1d7650211db Mon Sep 17 00:00:00 2001 From: nfagerlund Date: Mon, 23 May 2011 17:26:59 -0700 Subject: Maint: Add ellipsis to generated short_descriptions. Auto-generated short descriptions cut off at five lines with no indication that they are truncated. This commit adds ellipsis in brackets to indicate incompleteness. --- lib/puppet/interface/documentation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index 48e9a8b1a..aedcc1c24 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -78,7 +78,7 @@ class Puppet::Interface return nil if @description.nil? lines = @description.split("\n") grab = [5, lines.index('') || 5].min - @short_description = lines[0, grab].join("\n") + @short_description = lines[0, grab].join("\n") + ' [...]' end @short_description end -- cgit From 149a12f882252150ef9d642c6cf0345306f772ee Mon Sep 17 00:00:00 2001 From: nfagerlund Date: Thu, 26 May 2011 10:32:22 -0700 Subject: Maint: Fix ellipses for short descriptions Previously, we were adding ellipsis to any short_description, which was misleading; they were only necessary when we were truncating in the _middle_ of a paragraph. This commit changes the behavior, and updates the tests to show when we expect ellipsis. Paired-with: Matt Robinson --- lib/puppet/interface/documentation.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index 48e9a8b1a..fcaec2568 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -77,8 +77,10 @@ class Puppet::Interface if @short_description.nil? then return nil if @description.nil? lines = @description.split("\n") - grab = [5, lines.index('') || 5].min + first_paragraph_break = lines.index('') || 5 + grab = [5, first_paragraph_break].min @short_description = lines[0, grab].join("\n") + @short_description += ' [...]' if (grab < lines.length and first_paragraph_break >= 5) end @short_description end -- cgit From 796900b04e234b61a77fe4b64c006f24e15a7360 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Wed, 1 Jun 2011 11:53:40 -0700 Subject: (#7699) Don't duplicate inherited action names on faces. We earlier moved to duplicating Action objects in the Faces subsystem to ensure they had the correct binding context during execution and introspection. This was correct, but introduced a bug where we would report both the parent and child binding as separate entries with duplicate names, in the list of actions. This flowed on to the help output, where it would cause every inherited action to be listed twice: once on the parent, once on the child. (This was actually worse if the inheritance was deeper: we would duplicate once for every level between the instance and the origin of the action.) --- lib/puppet/interface/action_manager.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/action_manager.rb b/lib/puppet/interface/action_manager.rb index c5eb8e08a..fbf588d7d 100644 --- a/lib/puppet/interface/action_manager.rb +++ b/lib/puppet/interface/action_manager.rb @@ -34,7 +34,10 @@ module Puppet::Interface::ActionManager elsif self.class.respond_to?(:actions) result += self.class.actions end - result.sort + # We need to uniq the result, because we duplicate actions when they are + # fetched to ensure that they have the correct bindings; they shadow the + # parent, and uniq implements that. --daniel 2011-06-01 + result.uniq.sort end def get_action(name) -- cgit