summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-23 01:02:24 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-23 01:02:24 +0000
commit5864dbc9f16ea388f0038669c86ac79f2a0ac432 (patch)
treed602899b4f3f2f1465688123acd05dce7ad9fe84
parent95548d9dc32238fc2134ceefb7efd8450fe793d7 (diff)
* 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
-rw-r--r--ChangeLog21
-rw-r--r--lib/rdoc/any_method.rb2
-rw-r--r--lib/rdoc/attr.rb2
-rw-r--r--lib/rdoc/class_module.rb1
-rw-r--r--lib/rdoc/code_object.rb7
-rw-r--r--lib/rdoc/servlet.rb7
-rw-r--r--lib/rdoc/top_level.rb1
-rw-r--r--test/rdoc/test_rdoc_any_method.rb23
-rw-r--r--test/rdoc/test_rdoc_attr.rb4
-rw-r--r--test/rdoc/test_rdoc_class_module.rb2
-rw-r--r--test/rdoc/test_rdoc_constant.rb4
-rw-r--r--test/rdoc/test_rdoc_servlet.rb46
-rw-r--r--test/rdoc/test_rdoc_top_level.rb2
13 files changed, 110 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 89cdaf0e32..72de5d2857 100644
--- a/ChangeLog
+++ b/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
diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb
index b32690aa7d..23110dcb2a 100644
--- a/lib/rdoc/any_method.rb
+++ b/lib/rdoc/any_method.rb
@@ -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
diff --git a/lib/rdoc/attr.rb b/lib/rdoc/attr.rb
index 155215ff99..960e1d1107 100644
--- a/lib/rdoc/attr.rb
+++ b/lib/rdoc/attr.rb
@@ -121,6 +121,8 @@ class RDoc::Attr < RDoc::MethodAttr
# * #parent_name
def marshal_load array
+ initialize_visibility
+
@aliases = []
@parent = nil
@parent_name = nil
diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb
index 1dbe57bdf1..5a279b516d 100644
--- a/lib/rdoc/class_module.rb
+++ b/lib/rdoc/class_module.rb
@@ -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
diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb
index e2d9d909da..83732e3d3b 100644
--- a/lib/rdoc/code_object.rb
+++ b/lib/rdoc/code_object.rb
@@ -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
diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb
index 71b2911fc0..4fe2f139cc 100644
--- a/lib/rdoc/servlet.rb
+++ b/lib/rdoc/servlet.rb
@@ -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
diff --git a/lib/rdoc/top_level.rb b/lib/rdoc/top_level.rb
index 7b291ade80..64e12d9ff9 100644
--- a/lib/rdoc/top_level.rb
+++ b/lib/rdoc/top_level.rb
@@ -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,
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb
index abf749c4c9..cb4a979392 100644
--- a/test/rdoc/test_rdoc_any_method.rb
+++ b/test/rdoc/test_rdoc_any_method.rb
@@ -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
diff --git a/test/rdoc/test_rdoc_attr.rb b/test/rdoc/test_rdoc_attr.rb
index 92ff1b9856..a4922df06c 100644
--- a/test/rdoc/test_rdoc_attr.rb
+++ b/test/rdoc/test_rdoc_attr.rb
@@ -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
diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb
index 670f732290..ec81282c35 100644
--- a/test/rdoc/test_rdoc_class_module.rb
+++ b/test/rdoc/test_rdoc_class_module.rb
@@ -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
diff --git a/test/rdoc/test_rdoc_constant.rb b/test/rdoc/test_rdoc_constant.rb
index 1a2e43a6e4..5c347f62ae 100644
--- a/test/rdoc/test_rdoc_constant.rb
+++ b/test/rdoc/test_rdoc_constant.rb
@@ -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
diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb
index 5c2ba4e6a7..7072a7dd86 100644
--- a/test/rdoc/test_rdoc_servlet.rb
+++ b/test/rdoc/test_rdoc_servlet.rb
@@ -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'
diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb
index 99f7b22ae0..f3ee6a4784 100644
--- a/test/rdoc/test_rdoc_top_level.rb
+++ b/test/rdoc/test_rdoc_top_level.rb
@@ -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