mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rdoc/servlet.rb: Fixed display of site and home documentation.
Fixes rdoc issue #170 by Thomas Leitner. * test/rdoc/test_rdoc_servlet.rb: Test for above. * lib/rdoc/code_object.rb: Split #initialize_visibility from #initialize for reuse when loading a stored object. Fixes rdoc issue #171 by Thomas Leitner. * lib/rdoc/any_method.rb: Initialize visibility for #display? For rdoc issue #171 * lib/rdoc/attr.rb: ditto. * lib/rdoc/class_module.rb: ditto. * lib/rdoc/top_level.rb: ditto. * test/rdoc/test_rdoc_any_method.rb: Test for above. * test/rdoc/test_rdoc_attr.rb: ditto. * test/rdoc/test_rdoc_class_module.rb: ditto. * test/rdoc/test_rdoc_constant.rb: ditto. * test/rdoc/test_rdoc_top_level.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
95548d9dc3
commit
5864dbc9f1
13 changed files with 110 additions and 12 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
Wed Jan 23 09:53:39 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc/servlet.rb: Fixed display of site and home documentation.
|
||||
Fixes rdoc issue #170 by Thomas Leitner.
|
||||
* test/rdoc/test_rdoc_servlet.rb: Test for above.
|
||||
|
||||
* lib/rdoc/code_object.rb: Split #initialize_visibility from
|
||||
#initialize for reuse when loading a stored object.
|
||||
Fixes rdoc issue #171 by Thomas Leitner.
|
||||
|
||||
* lib/rdoc/any_method.rb: Initialize visibility for #display? For
|
||||
rdoc issue #171
|
||||
* lib/rdoc/attr.rb: ditto.
|
||||
* lib/rdoc/class_module.rb: ditto.
|
||||
* lib/rdoc/top_level.rb: ditto.
|
||||
* test/rdoc/test_rdoc_any_method.rb: Test for above.
|
||||
* test/rdoc/test_rdoc_attr.rb: ditto.
|
||||
* test/rdoc/test_rdoc_class_module.rb: ditto.
|
||||
* test/rdoc/test_rdoc_constant.rb: ditto.
|
||||
* test/rdoc/test_rdoc_top_level.rb: ditto.
|
||||
|
||||
Wed Jan 23 06:43:26 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rubygems/test_case.rb: Use Dir.tmpdir for rubygems tests instead
|
||||
|
|
|
@ -123,6 +123,8 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|||
# * #parent_name
|
||||
|
||||
def marshal_load array
|
||||
initialize_visibility
|
||||
|
||||
@dont_rename_initialize = nil
|
||||
@is_alias_for = nil
|
||||
@token_stream = nil
|
||||
|
|
|
@ -121,6 +121,8 @@ class RDoc::Attr < RDoc::MethodAttr
|
|||
# * #parent_name
|
||||
|
||||
def marshal_load array
|
||||
initialize_visibility
|
||||
|
||||
@aliases = []
|
||||
@parent = nil
|
||||
@parent_name = nil
|
||||
|
|
|
@ -323,6 +323,7 @@ class RDoc::ClassModule < RDoc::Context
|
|||
end
|
||||
|
||||
def marshal_load array # :nodoc:
|
||||
initialize_visibility
|
||||
initialize_methods_etc
|
||||
@current_section = nil
|
||||
@document_self = true
|
||||
|
|
|
@ -116,6 +116,13 @@ class RDoc::CodeObject
|
|||
@full_name = nil
|
||||
@store = nil
|
||||
|
||||
initialize_visibility
|
||||
end
|
||||
|
||||
##
|
||||
# Initializes state for visibility of this CodeObject and its children.
|
||||
|
||||
def initialize_visibility # :nodoc:
|
||||
@document_children = true
|
||||
@document_self = true
|
||||
@done_documenting = false
|
||||
|
|
|
@ -387,8 +387,12 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
|
|||
|
||||
def store_for source_name
|
||||
case source_name
|
||||
when 'home' then
|
||||
RDoc::Store.new RDoc::RI::Paths.home_dir, :home
|
||||
when 'ruby' then
|
||||
RDoc::Store.new RDoc::RI::Paths.system_dir, :system
|
||||
when 'site' then
|
||||
RDoc::Store.new RDoc::RI::Paths.site_dir, :site
|
||||
else
|
||||
ri_dir, type = ri_paths.find do |dir, dir_type|
|
||||
next unless dir_type == :gem
|
||||
|
@ -396,7 +400,8 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
|
|||
source_name == dir[%r%/([^/]*)/ri$%, 1]
|
||||
end
|
||||
|
||||
raise "could not find ri documentation for #{source_name}" unless
|
||||
raise RDoc::Error,
|
||||
"could not find ri documentation for #{source_name}" unless
|
||||
ri_dir
|
||||
|
||||
RDoc::Store.new ri_dir, type
|
||||
|
|
|
@ -187,6 +187,7 @@ class RDoc::TopLevel < RDoc::Context
|
|||
|
||||
##
|
||||
# Dumps this TopLevel for use by ri. See also #marshal_load
|
||||
|
||||
def marshal_dump
|
||||
[
|
||||
MARSHAL_VERSION,
|
||||
|
|
|
@ -100,24 +100,31 @@ method(a, b) { |c, d| ... }
|
|||
assert_equal section, loaded.section
|
||||
end
|
||||
|
||||
def test_marshal_load
|
||||
instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
|
||||
|
||||
assert_equal 'C1#m', instance_method.full_name
|
||||
assert_equal 'C1', instance_method.parent_name
|
||||
assert_equal '(foo)', instance_method.params
|
||||
|
||||
def test_marshal_load_aliased_method
|
||||
aliased_method = Marshal.load Marshal.dump(@c2.method_list.last)
|
||||
|
||||
assert_equal 'C2#a', aliased_method.full_name
|
||||
assert_equal 'C2', aliased_method.parent_name
|
||||
assert_equal '()', aliased_method.params
|
||||
assert aliased_method.display?
|
||||
end
|
||||
|
||||
def test_marshal_load_class_method
|
||||
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
|
||||
|
||||
assert_equal 'C1::m', class_method.full_name
|
||||
assert_equal 'C1', class_method.parent_name
|
||||
assert_equal '()', class_method.params
|
||||
assert class_method.display?
|
||||
end
|
||||
|
||||
def test_marshal_load_instance_method
|
||||
instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
|
||||
|
||||
assert_equal 'C1#m', instance_method.full_name
|
||||
assert_equal 'C1', instance_method.parent_name
|
||||
assert_equal '(foo)', instance_method.params
|
||||
assert instance_method.display?
|
||||
end
|
||||
|
||||
def test_marshal_load_version_0
|
||||
|
@ -163,6 +170,8 @@ method(a, b) { |c, d| ... }
|
|||
assert_equal nil, loaded.file
|
||||
assert_equal cm, loaded.parent
|
||||
assert_equal section, loaded.section
|
||||
|
||||
assert loaded.display?
|
||||
end
|
||||
|
||||
def test_name
|
||||
|
|
|
@ -137,6 +137,8 @@ class TestRDocAttr < RDoc::TestCase
|
|||
# version 3
|
||||
assert_equal cm, loaded.parent
|
||||
assert_equal section, loaded.section
|
||||
|
||||
assert loaded.display?
|
||||
end
|
||||
|
||||
def test_marshal_load_version_2
|
||||
|
@ -165,6 +167,8 @@ class TestRDocAttr < RDoc::TestCase
|
|||
# version 3
|
||||
assert_equal cm, loaded.parent
|
||||
assert_equal section, loaded.section
|
||||
|
||||
assert loaded.display?
|
||||
end
|
||||
|
||||
def test_params
|
||||
|
|
|
@ -289,6 +289,8 @@ class TestRDocClassModule < XrefTestCase
|
|||
|
||||
expected = { nil => s0 }
|
||||
assert_equal expected, loaded.sections_hash
|
||||
|
||||
assert loaded.display?
|
||||
end
|
||||
|
||||
def test_marshal_load_version_1
|
||||
|
|
|
@ -86,6 +86,8 @@ class TestRDocConstant < XrefTestCase
|
|||
assert_nil loaded.visibility
|
||||
assert_equal cm, loaded.parent
|
||||
assert_equal section, loaded.section
|
||||
|
||||
assert loaded.display?
|
||||
end
|
||||
|
||||
def test_marshal_load_version_0
|
||||
|
@ -116,6 +118,8 @@ class TestRDocConstant < XrefTestCase
|
|||
assert_nil loaded.visibility
|
||||
assert_equal cm, loaded.parent
|
||||
assert_equal section, loaded.section
|
||||
|
||||
assert loaded.display?
|
||||
end
|
||||
|
||||
def test_marshal_round_trip
|
||||
|
|
|
@ -12,7 +12,7 @@ class TestRDocServlet < RDoc::TestCase
|
|||
Gem.ensure_gem_subdirectories @tempdir
|
||||
|
||||
@spec = Gem::Specification.new 'spec', '1.0'
|
||||
@spec.loaded_from = File.join @tempdir, @spec.spec_file
|
||||
@spec.loaded_from = @spec.spec_file
|
||||
|
||||
Gem::Specification.reset
|
||||
Gem::Specification.all = [@spec]
|
||||
|
@ -34,13 +34,15 @@ class TestRDocServlet < RDoc::TestCase
|
|||
|
||||
@req.instance_variable_set :@header, Hash.new { |h, k| h[k] = [] }
|
||||
|
||||
@base = File.join @tempdir, 'base'
|
||||
@system_dir = File.join @tempdir, 'base', 'system'
|
||||
@base = File.join @tempdir, 'base'
|
||||
@system_dir = File.join @tempdir, 'base', 'system'
|
||||
@home_dir = File.join @tempdir, 'home'
|
||||
@gem_doc_dir = File.join @tempdir, 'doc'
|
||||
|
||||
@orig_base = RDoc::RI::Paths::BASE
|
||||
RDoc::RI::Paths::BASE.replace @base
|
||||
@orig_ri_path_homedir = RDoc::RI::Paths::HOMEDIR
|
||||
RDoc::RI::Paths::HOMEDIR.replace File.join @tempdir, 'home'
|
||||
RDoc::RI::Paths::HOMEDIR.replace @home_dir
|
||||
|
||||
RDoc::RI::Paths.instance_variable_set \
|
||||
:@gemdirs, %w[/nonexistent/gems/example-1.0/ri]
|
||||
|
@ -416,6 +418,42 @@ class TestRDocServlet < RDoc::TestCase
|
|||
assert_match %r%\Avar search_data =%, @res.body
|
||||
end
|
||||
|
||||
def test_store_for_gem
|
||||
store = @s.store_for 'spec-1.0'
|
||||
|
||||
assert_equal File.join(@gem_doc_dir, 'spec-1.0', 'ri'), store.path
|
||||
assert_equal :gem, store.type
|
||||
end
|
||||
|
||||
def test_store_for_home
|
||||
store = @s.store_for 'home'
|
||||
|
||||
assert_equal @home_dir, store.path
|
||||
assert_equal :home, store.type
|
||||
end
|
||||
|
||||
def test_store_for_missing
|
||||
e = assert_raises RDoc::Error do
|
||||
@s.store_for 'missing'
|
||||
end
|
||||
|
||||
assert_equal 'could not find ri documentation for missing', e.message
|
||||
end
|
||||
|
||||
def test_store_for_ruby
|
||||
store = @s.store_for 'ruby'
|
||||
|
||||
assert_equal @system_dir, store.path
|
||||
assert_equal :system, store.type
|
||||
end
|
||||
|
||||
def test_store_for_site
|
||||
store = @s.store_for 'site'
|
||||
|
||||
assert_equal File.join(@base, 'site'), store.path
|
||||
assert_equal :site, store.type
|
||||
end
|
||||
|
||||
def touch_system_cache_path
|
||||
store = RDoc::Store.new @system_dir
|
||||
store.title = 'Standard Library Documentation'
|
||||
|
|
|
@ -205,6 +205,8 @@ class TestRDocTopLevel < XrefTestCase
|
|||
assert_equal RDoc::Parser::Simple, loaded.parser
|
||||
|
||||
assert_equal comment, loaded.comment
|
||||
|
||||
assert loaded.display?
|
||||
end
|
||||
|
||||
def test_name
|
||||
|
|
Loading…
Reference in a new issue