aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--lib/rdoc/generator/darkfish.rb5
-rw-r--r--lib/rdoc/markup/parser.rb13
-rw-r--r--lib/rdoc/parser/ruby.rb2
-rw-r--r--lib/rdoc/rubygems_hook.rb7
-rw-r--r--lib/rdoc/servlet.rb2
-rw-r--r--lib/rdoc/test_case.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_parser.rb10
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb10
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb4
-rw-r--r--test/rdoc/test_rdoc_rubygems_hook.rb14
11 files changed, 71 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d2dbb1326..618d7c4283 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+Fri Nov 30 08:34:03 2012 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rdoc/generator/darkfish.rb: Silenced warning
+ * test/rdoc/test_rdoc_rdoc.rb: ditto
+
+ * lib/rdoc/markup/parser.rb: Use byteslice when available for
+ performance
+ * test/rdoc/test_rdoc_markup_parser.rb: Test for above
+ * lib/rdoc/test_case.rb: ditto
+
+ * lib/rdoc/parser/ruby.rb: Fixed bug parsing yield({})
+ * test/rdoc/test_rdoc_parser_ruby.rb (end):
+
+ * lib/rdoc/rubygems_hook.rb: Skip default gems. Display generator
+ name properly.
+ * test/rdoc/test_rdoc_rubygems_hook.rb: Test for above
+
+ * lib/rdoc/servlet.rb: Fixed typo.
+
Fri Nov 30 08:09:56 2012 Narihiro Nakamura <authornari@gmail.com>
* gc.c : remove a unused function.
diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb
index b69d14855a..103a244a25 100644
--- a/lib/rdoc/generator/darkfish.rb
+++ b/lib/rdoc/generator/darkfish.rb
@@ -484,8 +484,9 @@ class RDoc::Generator::Darkfish
debug_msg 'Rendering the servlet root page...'
- rel_prefix = asset_rel_prefix = '.'
- search_index_rel_prefix = rel_prefix
+ rel_prefix = '.'
+ asset_rel_prefix = rel_prefix
+ search_index_rel_prefix = asset_rel_prefix
search_index_rel_prefix += @asset_rel_path if @file_output
@title = 'Local RDoc Documentation'
diff --git a/lib/rdoc/markup/parser.rb b/lib/rdoc/markup/parser.rb
index ca384d0639..3fce2b4c3b 100644
--- a/lib/rdoc/markup/parser.rb
+++ b/lib/rdoc/markup/parser.rb
@@ -79,6 +79,8 @@ class RDoc::Markup::Parser
@current_token = nil
@debug = false
@have_encoding = Object.const_defined? :Encoding
+ @have_byteslice = ''.respond_to? :byteslice
+ @input = nil
@input_encoding = nil
@line = 0
@line_pos = 0
@@ -321,7 +323,9 @@ class RDoc::Markup::Parser
# The character offset for the input string at the given +byte_offset+
def char_pos byte_offset
- if @have_encoding then
+ if @have_byteslice then
+ @input.byteslice(0, byte_offset).length
+ elsif @have_encoding then
matched = @binary_input[0, byte_offset]
matched.force_encoding @input_encoding
matched.length
@@ -416,10 +420,11 @@ class RDoc::Markup::Parser
def setup_scanner input
@line = 0
@line_pos = 0
+ @input = input.dup
- if @have_encoding then
- @input_encoding = input.encoding
- @binary_input = input.dup.force_encoding Encoding::BINARY
+ if @have_encoding and not @have_byteslice then
+ @input_encoding = @input.encoding
+ @binary_input = @input.force_encoding Encoding::BINARY
end
@s = StringScanner.new input
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index 0e1e012650..fe461ff389 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -1250,7 +1250,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
when end_token then
if end_token == TkRPAREN
nest -= 1
- break if @scanner.lex_state == EXPR_END and nest <= 0
+ break if nest <= 0
else
break unless @scanner.continue
end
diff --git a/lib/rdoc/rubygems_hook.rb b/lib/rdoc/rubygems_hook.rb
index 51c564ea46..9fcb783425 100644
--- a/lib/rdoc/rubygems_hook.rb
+++ b/lib/rdoc/rubygems_hook.rb
@@ -103,6 +103,8 @@ class RDoc::RubygemsHook
# Documentation will be generated into +destination+
def document generator, options, destination
+ generator_name = generator
+
options = options.dup
options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
options.setup_generator generator
@@ -114,7 +116,7 @@ class RDoc::RubygemsHook
@rdoc.options = options
@rdoc.generator = generator
- say "Installing #{generator} documentation for #{@spec.full_name}"
+ say "Installing #{generator_name} documentation for #{@spec.full_name}"
FileUtils.mkdir_p options.op_dir
@@ -132,6 +134,7 @@ class RDoc::RubygemsHook
# Generates RDoc and ri data
def generate
+ return if @spec.default_gem?
return unless @generate_ri or @generate_rdoc
setup
@@ -166,6 +169,8 @@ class RDoc::RubygemsHook
@rdoc.store = RDoc::Store.new
+ say "Parsing documentation for #{@spec.full_name}"
+
Dir.chdir @spec.full_gem_path do
@rdoc.parse_files options.files
end
diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb
index d308288029..3df366b967 100644
--- a/lib/rdoc/servlet.rb
+++ b/lib/rdoc/servlet.rb
@@ -132,7 +132,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
<title>Error - #{ERB::Util.html_escape e.class}</title>
-<link type="text/css" media="screen" href="#{@mouth_path}/rdoc.css" rel="stylesheet">
+<link type="text/css" media="screen" href="#{@mount_path}/rdoc.css" rel="stylesheet">
</head>
<body>
<h1>Error</h1>
diff --git a/lib/rdoc/test_case.rb b/lib/rdoc/test_case.rb
index e5b7288e5a..c69e3c7cc6 100644
--- a/lib/rdoc/test_case.rb
+++ b/lib/rdoc/test_case.rb
@@ -33,6 +33,8 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
@top_level = nil
+ @have_encoding = Object.const_defined? :Encoding
+
@RM = RDoc::Markup
RDoc::Markup::PreProcess.reset
diff --git a/test/rdoc/test_rdoc_markup_parser.rb b/test/rdoc/test_rdoc_markup_parser.rb
index 45f911acd1..b367b23bcc 100644
--- a/test/rdoc/test_rdoc_markup_parser.rb
+++ b/test/rdoc/test_rdoc_markup_parser.rb
@@ -7,13 +7,15 @@ class TestRDocMarkupParser < RDoc::TestCase
def setup
super
+ @have_byteslice = ''.respond_to? :byteslice
+
@RMP = @RM::Parser
end
def mu_pp(obj)
s = ''
s = PP.pp obj, s
- s = s.force_encoding(Encoding.default_external) if defined? Encoding
+ s = s.force_encoding(Encoding.default_external) if @have_encoding
s.chomp
end
@@ -34,7 +36,7 @@ class TestRDocMarkupParser < RDoc::TestCase
s.scan(/\S+/)
- if Object.const_defined? :Encoding then
+ if @have_byteslice or @have_encoding then
assert_equal 3, parser.char_pos(s.pos)
else
assert_equal 4, parser.char_pos(s.pos)
@@ -1364,7 +1366,7 @@ cat::
end
def test_tokenize_note_utf_8
- skip 'Encoding not implemented' unless Object.const_defined? :Encoding
+ skip 'Encoding not implemented' unless @have_encoding
str = <<-STR
cät:: l1a
@@ -1630,7 +1632,7 @@ Example heading:
s.scan(/\S+/)
- if Object.const_defined? :Encoding then
+ if @have_encoding or @have_byteslice then
assert_equal [3, 0], parser.token_pos(s.pos)
else
assert_equal [4, 0], parser.token_pos(s.pos)
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 8168cd3f45..41b58f6615 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -1684,6 +1684,16 @@ end
assert_equal "def \317\211", omega.text
end
+ def test_parse_method_or_yield_parameters_hash
+ util_parser "({})\n"
+
+ m = RDoc::AnyMethod.new nil, 'm'
+
+ result = @parser.parse_method_or_yield_parameters m
+
+ assert_equal '({})', result
+ end
+
def test_parse_statements_class_if
util_parser <<-CODE
module Foo
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb
index 5519ed36ac..643f1eff77 100644
--- a/test/rdoc/test_rdoc_rdoc.rb
+++ b/test/rdoc/test_rdoc_rdoc.rb
@@ -142,8 +142,6 @@ class TestRDocRDoc < RDoc::TestCase
end
def test_parse_file
- pwd = Dir.pwd
-
@rdoc.store = RDoc::Store.new
temp_dir do |dir|
@@ -153,8 +151,6 @@ class TestRDocRDoc < RDoc::TestCase
io.puts 'hi'
end
- test_txt = File.join dir, 'test.txt'
-
top_level = @rdoc.parse_file 'test.txt'
assert_equal 'test.txt', top_level.absolute_name
diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb
index 63f44d3148..ceea0dfe12 100644
--- a/test/rdoc/test_rdoc_rubygems_hook.rb
+++ b/test/rdoc/test_rdoc_rubygems_hook.rb
@@ -100,6 +100,20 @@ class TestRDocRubygemsHook < Gem::TestCase
assert rdoc.options.hyperlink_all
end
+ def test_generate_default_gem
+ skip 'RubyGems 2 required' unless @a.respond_to? :default_gem?
+ @a.loaded_from =
+ File.join Gem::Specification.default_specifications_dir, 'a.gemspec'
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.generate
+
+ refute @hook.rdoc_installed?
+ refute @hook.ri_installed?
+ end
+
def test_generate_disabled
@hook.generate_rdoc = false
@hook.generate_ri = false