summaryrefslogtreecommitdiff
path: root/lib/rdoc/text.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-07 07:07:12 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-07 07:07:12 +0000
commit60f2c9cf5bea6dd99fac50c460eab4809cc30b01 (patch)
treeab40b4f7be3ff6d9fc8aede6b90e1aa9dded0aff /lib/rdoc/text.rb
parentca9f7009db8aea70af3dd58cb6c7de0010844d22 (diff)
Upgrade to RDoc 3.5.3. Fixes [Bug #4376]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/text.rb')
-rw-r--r--lib/rdoc/text.rb26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb
index 501871c8df..adbc630cf1 100644
--- a/lib/rdoc/text.rb
+++ b/lib/rdoc/text.rb
@@ -46,7 +46,9 @@ module RDoc::Text
text.each_line do |line|
line.gsub!(/^(.{8}*?)([^\t\r\n]{0,7})\t/) do
- "#{$1}#{$2}#{' ' * (8 - $2.size)}"
+ r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
+ r.force_encoding text.encoding if Object.const_defined? :Encoding
+ r
end until line !~ /\t/
expanded << line
@@ -69,8 +71,11 @@ module RDoc::Text
flush = []
+ empty = ''
+ empty.force_encoding text.encoding if Object.const_defined? :Encoding
+
text.each_line do |line|
- line[/^ {0,#{indent}}/] = ''
+ line[/^ {0,#{indent}}/] = empty
flush << line
end
@@ -158,11 +163,20 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
# Strips /* */ style comments
def strip_stars text
+ encoding = text.encoding if Object.const_defined? :Encoding
+
text = text.gsub %r%Document-method:\s+[\w:.#]+%, ''
- text.sub! %r%/\*+% do " " * $&.length end
- text.sub! %r%\*+/% do " " * $&.length end
- text.gsub! %r%^[ \t]*\*%m do " " * $&.length end
- text.gsub(/^\s+$/, '')
+
+ space = ' '
+ space.force_encoding encoding if encoding
+
+ text.sub! %r%/\*+% do space * $&.length end
+ text.sub! %r%\*+/% do space * $&.length end
+ text.gsub! %r%^[ \t]*\*%m do space * $&.length end
+
+ empty = ''
+ empty.force_encoding encoding if encoding
+ text.gsub(/^\s+$/, empty)
end
##