mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rdoc/parser.rb: Improved modeline support. Patch by nobu.
* test/rdoc/test_rdoc_parser.rb: Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
28f6b32e7e
commit
488fb86a1e
3 changed files with 30 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Dec 3 07:52:41 2012 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc/parser.rb: Improved modeline support. Patch by nobu.
|
||||
* test/rdoc/test_rdoc_parser.rb: Test for above.
|
||||
|
||||
Sun Dec 3 00:06:00 2012 Kenta Murata <mrkn@mrkn.jp>
|
||||
|
||||
* ext/bigdecimal/bigdecimal.c (BigDecimal_new): stop checking string
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: us-ascii -*-
|
||||
|
||||
##
|
||||
# A parser is simple a class that subclasses RDoc::Parser and implements #scan
|
||||
# to fill in an RDoc::TopLevel with parsed data.
|
||||
|
@ -157,11 +159,16 @@ class RDoc::Parser
|
|||
io.gets
|
||||
end
|
||||
|
||||
line =~ /-\*-(.*?)-\*-/
|
||||
/-\*-\s*(.*?\S)\s*-\*-/ =~ line
|
||||
|
||||
return nil unless type = $1
|
||||
|
||||
type.strip.downcase
|
||||
if /;/ =~ type then
|
||||
return nil unless /(?:\s|\A)mode:\s*([^\s;]+)/i =~ type
|
||||
type = $1
|
||||
end
|
||||
|
||||
type.downcase
|
||||
rescue ArgumentError # invalid byte sequence, etc.
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: us-ascii -*-
|
||||
|
||||
require 'rdoc/test_case'
|
||||
|
||||
class TestRDocParser < RDoc::TestCase
|
||||
|
@ -111,6 +113,20 @@ class TestRDocParser < RDoc::TestCase
|
|||
File.unlink readme_ext
|
||||
end
|
||||
|
||||
def test_check_modeline_with_other
|
||||
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
|
||||
|
||||
open readme_ext, 'w' do |io|
|
||||
io.puts "# README.EXT - -*- mode: RDoc; indent-tabs-mode: nil -*-"
|
||||
io.puts
|
||||
io.puts "This document explains how to make extension libraries for Ruby."
|
||||
end
|
||||
|
||||
assert_equal 'rdoc', @RP.check_modeline(readme_ext)
|
||||
ensure
|
||||
File.unlink readme_ext
|
||||
end
|
||||
|
||||
def test_check_modeline_no_modeline
|
||||
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
|
||||
|
||||
|
|
Loading…
Reference in a new issue