File tree Expand file tree Collapse file tree 3 files changed +62
-3
lines changed Expand file tree Collapse file tree 3 files changed +62
-3
lines changed Original file line number Diff line number Diff line change 1111 * Locations of module aliases are now recorded.
1212 * RDoc::Parser::C finds method bodies better now.
1313 * Fixed further locations where output encoding was not preserved. Bug #11
14- by Vít Ondruch.
14+ by Vít Ondruch, RubyForge bug #28791 by Dzmitry Prakapenka .
1515 * Fixed display of numeric lists on the index page and file pages. Bug #12
1616 by tobijk.
1717
Original file line number Diff line number Diff line change @@ -1641,8 +1641,11 @@ def read_documentation_modifiers(context, allow)
16411641 # Removes private comments from +comment+
16421642
16431643 def remove_private_comments ( comment )
1644- comment . gsub! ( /^#--\n .*?^#\+ \+ \n ?/m , '' )
1645- comment . sub! ( /^#--\n .*\n ?/m , '' )
1644+ empty = ''
1645+ empty . force_encoding comment . encoding if Object . const_defined? :Encoding
1646+
1647+ comment . gsub! ( /^#--\n .*?^#\+ \+ \n ?/m , empty )
1648+ comment . sub! ( /^#--\n .*\n ?/m , empty )
16461649 end
16471650
16481651 ##
Original file line number Diff line number Diff line change @@ -186,6 +186,23 @@ def test_remove_private_comments
186186 assert_equal expected , comment
187187 end
188188
189+ def test_remove_private_comments_encoding
190+ skip "Encoding not implemented" unless Object . const_defined? :Encoding
191+
192+ util_parser ''
193+
194+ comment = <<-EOS
195+ # This is text
196+ #--
197+ # this is private
198+ EOS
199+ comment . force_encoding Encoding ::IBM437
200+
201+ @parser . remove_private_comments comment
202+
203+ assert_equal Encoding ::IBM437 , comment . encoding
204+ end
205+
189206 def test_remove_private_comments_rule
190207 util_parser ''
191208
@@ -223,6 +240,45 @@ def test_remove_private_comments_toggle
223240 assert_equal expected , comment
224241 end
225242
243+ def test_remove_private_comments_toggle_encoding
244+ skip "Encoding not implemented" unless Object . const_defined? :Encoding
245+
246+ util_parser ''
247+
248+ comment = <<-EOS
249+ # This is text
250+ #--
251+ # this is private
252+ #++
253+ # This is text again.
254+ EOS
255+
256+ comment . force_encoding Encoding ::IBM437
257+
258+ @parser . remove_private_comments comment
259+
260+ assert_equal Encoding ::IBM437 , comment . encoding
261+ end
262+
263+ def test_remove_private_comments_toggle_encoding_ruby_bug?
264+ skip "Encoding not implemented" unless Object . const_defined? :Encoding
265+
266+ util_parser ''
267+
268+ comment = <<-EOS
269+ #--
270+ # this is private
271+ #++
272+ # This is text again.
273+ EOS
274+
275+ comment . force_encoding Encoding ::IBM437
276+
277+ @parser . remove_private_comments comment
278+
279+ assert_equal Encoding ::IBM437 , comment . encoding
280+ end
281+
226282 def test_look_for_directives_in_commented
227283 util_parser ""
228284
You can’t perform that action at this time.
0 commit comments