* lib/rdoc: Update to 3.9.1. Fixes === lines in verbatim sections.

Fixes :nodoc: on class aliases.  Fixes :stopdoc: creating references
	  to Object.  Fixes spacing when class comments are merged in ri.
	  Fixes `ri []` crash.  Fixes bug report URL when rdoc crashes.  Adds
	  :doc: and :nodoc: to allow hiding of implementation details in ruby.
	  Makes `rdoc` and `ri` gem-aware.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2011-08-05 21:21:55 +00:00
parent cd3477004e
commit ed93a37bd5
34 changed files with 1384 additions and 604 deletions

View file

@ -5,6 +5,7 @@ require 'rubygems'
require 'minitest/autorun'
require 'rdoc/markup/pre_process'
require 'rdoc/code_objects'
require 'rdoc/options'
class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase
@ -19,6 +20,8 @@ class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase
end
def teardown
RDoc::Markup::PreProcess.registered.clear
@tempfile.close
end
@ -73,6 +76,14 @@ contents of a string.
end
def test_handle
text = "# :main: M\n"
out = @pp.handle text
assert_same out, text
assert_equal "#\n", text
end
def test_handle_unregistered
text = "# :x: y\n"
out = @pp.handle text
@ -80,142 +91,329 @@ contents of a string.
assert_equal "# :x: y\n", text
end
def test_handle_block
text = "# :x: y\n"
def test_handle_directive_blankline
result = @pp.handle_directive '#', 'arg', 'a, b'
@pp.handle text do |directive, param|
false
end
assert_equal "#\n", result
end
assert_equal "# :x: y\n", text
def test_handle_directive_downcase
method = RDoc::AnyMethod.new nil, 'm'
@pp.handle text do |directive, param|
@pp.handle_directive '', 'ARG', 'a, b', method
assert_equal 'a, b', method.params
end
def test_handle_directive_arg
method = RDoc::AnyMethod.new nil, 'm'
@pp.handle_directive '', 'arg', 'a, b', method
assert_equal 'a, b', method.params
end
def test_handle_directive_arg_no_context
result = @pp.handle_directive '', 'arg', 'a, b', nil
assert_equal "\n", result
end
def test_handle_directive_args
method = RDoc::AnyMethod.new nil, 'm'
@pp.handle_directive '', 'args', 'a, b', method
assert_equal 'a, b', method.params
end
def test_handle_directive_block
result = @pp.handle_directive '', 'x', 'y' do |directive, param|
''
end
assert_equal "", text
assert_empty result
end
def test_handle_category
def test_handle_directive_block_false
result = @pp.handle_directive '', 'x', 'y' do |directive, param|
false
end
assert_equal ":x: y\n", result
end
def test_handle_directive_block_nil
result = @pp.handle_directive '', 'x', 'y' do |directive, param|
nil
end
assert_equal ":x: y\n", result
end
def test_handle_directive_category
context = RDoc::Context.new
original_section = context.current_section
text = "# :category: other\n"
@pp.handle text, context
@pp.handle_directive '', 'category', 'other', context
refute_equal original_section, context.current_section
end
def test_handle_code_object
cd = RDoc::CodeObject.new
text = "# :x: y\n"
@pp.handle text, cd
def test_handle_directive_doc
code_object = RDoc::CodeObject.new
code_object.document_self = false
code_object.force_documentation = false
assert_equal "# :x: y\n", text
assert_equal 'y', cd.metadata['x']
@pp.handle_directive '', 'doc', nil, code_object
cd.metadata.clear
text = "# :x:\n"
@pp.handle text, cd
assert_equal "# :x: \n", text
assert_includes cd.metadata, 'x'
assert code_object.document_self
assert code_object.force_documentation
end
def test_handle_code_object_block
cd = RDoc::CodeObject.new
text = "# :x: y\n"
@pp.handle text, cd do
false
end
def test_handle_directive_doc_no_context
result = @pp.handle_directive '', 'doc', nil
assert_equal "# :x: y\n", text
assert_empty cd.metadata
@pp.handle text, cd do
nil
end
assert_equal "# :x: y\n", text
assert_equal 'y', cd.metadata['x']
cd.metadata.clear
@pp.handle text, cd do
''
end
assert_equal '', text
assert_empty cd.metadata
assert_equal "\n", result
end
def test_handle_registered
def test_handle_directive_enddoc
code_object = RDoc::CodeObject.new
@pp.handle_directive '', 'enddoc', nil, code_object
assert code_object.done_documenting
end
def test_handle_directive_include
@tempfile.write 'included'
@tempfile.flush
result = @pp.handle_directive '', 'include', @file_name
assert_equal 'included', result
end
def test_handle_directive_main
@pp.options = RDoc::Options.new
@pp.handle_directive '', 'main', 'M'
assert_equal 'M', @pp.options.main_page
end
def test_handle_directive_notnew
m = RDoc::AnyMethod.new nil, 'm'
@pp.handle_directive '', 'notnew', nil, m
assert m.dont_rename_initialize
end
def test_handle_directive_not_new
m = RDoc::AnyMethod.new nil, 'm'
@pp.handle_directive '', 'not_new', nil, m
assert m.dont_rename_initialize
end
def test_handle_directive_not_dash_new
m = RDoc::AnyMethod.new nil, 'm'
@pp.handle_directive '', 'not-new', nil, m
assert m.dont_rename_initialize
end
def test_handle_directive_nodoc
code_object = RDoc::CodeObject.new
code_object.document_self = true
code_object.document_children = true
@pp.handle_directive '', 'nodoc', nil, code_object
refute code_object.document_self
assert code_object.document_children
end
def test_handle_directive_nodoc_all
code_object = RDoc::CodeObject.new
code_object.document_self = true
code_object.document_children = true
@pp.handle_directive '', 'nodoc', 'all', code_object
refute code_object.document_self
refute code_object.document_children
end
def test_handle_directive_nodoc_no_context
result = @pp.handle_directive '', 'nodoc', nil
assert_equal "\n", result
end
def test_handle_directive_registered
RDoc::Markup::PreProcess.register 'x'
text = "# :x: y\n"
@pp.handle text
assert_equal '', text
result = @pp.handle_directive '', 'x', 'y'
text = "# :x: y\n"
assert_nil result
@pp.handle text do |directive, param|
result = @pp.handle_directive '', 'x', 'y' do |directive, param|
false
end
assert_equal "# :x: y\n", text
assert_equal ":x: y\n", result
text = "# :x: y\n"
@pp.handle text do |directive, param|
result = @pp.handle_directive '', 'x', 'y' do |directive, param|
''
end
assert_equal "", text
assert_equal '', result
end
def test_handle_registered_block
def test_handle_directive_registered_block
called = nil
RDoc::Markup::PreProcess.register 'x' do |directive, param|
called = [directive, param]
'blah'
end
text = "# :x: y\n"
@pp.handle text
result = @pp.handle_directive '', 'x', 'y'
assert_equal 'blah', text
assert_equal 'blah', result
assert_equal %w[x y], called
end
def test_handle_registered_code_object
def test_handle_directive_registered_code_object
RDoc::Markup::PreProcess.register 'x'
cd = RDoc::CodeObject.new
code_object = RDoc::CodeObject.new
text = "# :x: y\n"
@pp.handle text, cd
@pp.handle_directive '', 'x', 'y', code_object
assert_equal '', text
assert_equal 'y', cd.metadata['x']
assert_equal 'y', code_object.metadata['x']
cd.metadata.clear
text = "# :x: y\n"
code_object.metadata.clear
@pp.handle text do |directive, param|
result = @pp.handle_directive '', 'x', 'y' do |directive, param|
false
end
assert_equal "# :x: y\n", text
assert_empty cd.metadata
assert_equal ":x: y\n", result
assert_empty code_object.metadata
text = "# :x: y\n"
@pp.handle text do |directive, param|
result = @pp.handle_directive '', 'x', 'y' do |directive, param|
''
end
assert_equal "", text
assert_empty cd.metadata
assert_equal '', result
assert_empty code_object.metadata
end
def test_handle_directive_startdoc
code_object = RDoc::CodeObject.new
code_object.stop_doc
code_object.force_documentation = false
@pp.handle_directive '', 'startdoc', nil, code_object
assert code_object.document_self
assert code_object.document_children
assert code_object.force_documentation
end
def test_handle_directive_stopdoc
code_object = RDoc::CodeObject.new
@pp.handle_directive '', 'stopdoc', nil, code_object
refute code_object.document_self
refute code_object.document_children
end
def test_handle_directive_title
@pp.options = RDoc::Options.new
@pp.handle_directive '', 'title', 'T'
assert_equal 'T', @pp.options.title
end
def test_handle_directive_unhandled
code_object = RDoc::CodeObject.new
@pp.handle_directive '', 'x', 'y', code_object
assert_equal 'y', code_object.metadata['x']
code_object.metadata.clear
@pp.handle_directive '', 'x', '', code_object
assert_includes code_object.metadata, 'x'
end
def test_handle_directive_unhandled_block
code_object = RDoc::CodeObject.new
@pp.handle_directive '', 'x', 'y', code_object do
false
end
assert_empty code_object.metadata
@pp.handle_directive '', 'x', 'y', code_object do
nil
end
assert_equal 'y', code_object.metadata['x']
code_object.metadata.clear
@pp.handle_directive '', 'x', 'y', code_object do
''
end
assert_empty code_object.metadata
end
def test_handle_directive_yield
method = RDoc::AnyMethod.new nil, 'm'
method.params = 'index, &block'
@pp.handle_directive '', 'yield', 'item', method
assert_equal 'item', method.block_params
assert_equal 'index', method.params
end
def test_handle_directive_yield_block_param
method = RDoc::AnyMethod.new nil, 'm'
method.params = '&block'
@pp.handle_directive '', 'yield', 'item', method
assert_equal 'item', method.block_params
assert_empty method.params
end
def test_handle_directive_yield_no_context
method = RDoc::AnyMethod.new nil, 'm'
@pp.handle_directive '', 'yield', 'item', method
assert_equal 'item', method.block_params
end
def test_handle_directive_yields
method = RDoc::AnyMethod.new nil, 'm'
@pp.handle_directive '', 'yields', 'item', method
assert_equal 'item', method.block_params
end
end