diff options
author | James Turnbull <james@lovedthanlost.net> | 2009-05-20 18:27:02 +1000 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-05-20 18:27:02 +1000 |
commit | 6a413d21a71da2b330f9b147532f3256fc29be3c (patch) | |
tree | 479b84665f8d6ba714aae47026e8601abe012f76 /lib/puppet/util/docs.rb | |
parent | 469604f33645e136725e34b57ce270b4397d3536 (diff) | |
download | puppet-6a413d21a71da2b330f9b147532f3256fc29be3c.tar.gz puppet-6a413d21a71da2b330f9b147532f3256fc29be3c.tar.xz puppet-6a413d21a71da2b330f9b147532f3256fc29be3c.zip |
Fixed #2666 - Broken docstring formatting
Diffstat (limited to 'lib/puppet/util/docs.rb')
-rw-r--r-- | lib/puppet/util/docs.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb index 54d1052f3..860a5453c 100644 --- a/lib/puppet/util/docs.rb +++ b/lib/puppet/util/docs.rb @@ -90,9 +90,15 @@ module Puppet::Util::Docs indent = nil # If we can match an indentation, then just remove that same level of - # indent from every line. - if text =~ /^(\s+)/ - indent = $1 + # indent from every line. However, ignore any indentation on the + # first line, since that can be inconsistent. + text = text.lstrip() + text.gsub!(/^([\t]+)/) { |s| " "*8*s.length(); } # Expand leading tabs + # Find first non-empty line after the first line: + line2start = (text =~ /(\n?\s*\n)/) + line2start += $1.length + if (text[line2start..-1] =~ /^([ ]+)\S/) == 0 + indent = Regexp.quote($1) begin return text.gsub(/^#{indent}/,'') rescue => detail |