From: nfagerlund <nick.fagerl...@gmail.com>

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 <m...@puppetlabs.com>
Signed-off-by: Matt Robinson <m...@puppetlabs.com>
---
Local-branch: ticket/2.7rc/maint-faces_docs_spec_fixes
 lib/puppet/interface/documentation.rb            |    4 +++-
 spec/shared_behaviours/documentation_on_faces.rb |   11 +++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/interface/documentation.rb 
b/lib/puppet/interface/documentation.rb
index 48e9a8b..fcaec25 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
diff --git a/spec/shared_behaviours/documentation_on_faces.rb 
b/spec/shared_behaviours/documentation_on_faces.rb
index 3cfb178..204b173 100644
--- a/spec/shared_behaviours/documentation_on_faces.rb
+++ b/spec/shared_behaviours/documentation_on_faces.rb
@@ -109,11 +109,18 @@ shared_examples_for "documentation on faces" do
       subject.short_description.should == "hello\ngoodbye"
     end
 
-    it "should trim a very, very long first paragraph" do
+    it "should trim a very, very long first paragraph and add ellipsis" do
       line = "this is a very, very, very long long line full of text\n"
       subject.description = line * 20 + "\n\nwhatever, dude."
 
-      subject.short_description.should == (line * 5).chomp
+      subject.short_description.should == (line * 5).chomp + ' [...]'
+    end
+
+    it "should trim a very very long only paragraph even if it is followed by 
a new paragraph" do
+      line = "this is a very, very, very long long line full of text\n"
+      subject.description = line * 20
+
+      subject.short_description.should == (line * 5).chomp + ' [...]'
     end
   end
 
-- 
1.7.3.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to