[前][次][番号順一覧][スレッド一覧]

ruby-changes:26847

From: drbrain <ko1@a...>
Date: Wed, 23 Jan 2013 10:10:28 +0900 (JST)
Subject: [ruby-changes:26847] drbrain:r38899 (trunk): * lib/rdoc/servlet.rb: Fixed display of site and home documentation.

drbrain	2013-01-23 10:02:24 +0900 (Wed, 23 Jan 2013)

  New Revision: 38899

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38899

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rdoc/any_method.rb
    trunk/lib/rdoc/attr.rb
    trunk/lib/rdoc/class_module.rb
    trunk/lib/rdoc/code_object.rb
    trunk/lib/rdoc/servlet.rb
    trunk/lib/rdoc/top_level.rb
    trunk/test/rdoc/test_rdoc_any_method.rb
    trunk/test/rdoc/test_rdoc_attr.rb
    trunk/test/rdoc/test_rdoc_class_module.rb
    trunk/test/rdoc/test_rdoc_constant.rb
    trunk/test/rdoc/test_rdoc_servlet.rb
    trunk/test/rdoc/test_rdoc_top_level.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38898)
+++ ChangeLog	(revision 38899)
@@ -1,3 +1,24 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jan 23 09:53:39 2013  Eric Hodel  <drbrain@s...>
+
+	* 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@s...>
 
 	* lib/rubygems/test_case.rb:  Use Dir.tmpdir for rubygems tests instead
Index: lib/rdoc/top_level.rb
===================================================================
--- lib/rdoc/top_level.rb	(revision 38898)
+++ lib/rdoc/top_level.rb	(revision 38899)
@@ -187,6 +187,7 @@ class RDoc::TopLevel < RDoc::Context https://github.com/ruby/ruby/blob/trunk/lib/rdoc/top_level.rb#L187
 
   ##
   # Dumps this TopLevel for use by ri.  See also #marshal_load
+
   def marshal_dump
     [
       MARSHAL_VERSION,
Index: lib/rdoc/code_object.rb
===================================================================
--- lib/rdoc/code_object.rb	(revision 38898)
+++ lib/rdoc/code_object.rb	(revision 38899)
@@ -116,6 +116,13 @@ class RDoc::CodeObject https://github.com/ruby/ruby/blob/trunk/lib/rdoc/code_object.rb#L116
     @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
Index: lib/rdoc/class_module.rb
===================================================================
--- lib/rdoc/class_module.rb	(revision 38898)
+++ lib/rdoc/class_module.rb	(revision 38899)
@@ -323,6 +323,7 @@ class RDoc::ClassModule < RDoc::Context https://github.com/ruby/ruby/blob/trunk/lib/rdoc/class_module.rb#L323
   end
 
   def marshal_load array # :nodoc:
+    initialize_visibility
     initialize_methods_etc
     @current_section   = nil
     @document_self     = true
Index: lib/rdoc/servlet.rb
===================================================================
--- lib/rdoc/servlet.rb	(revision 38898)
+++ lib/rdoc/servlet.rb	(revision 38899)
@@ -387,8 +387,12 @@ version.  If you're viewing Ruby's docum https://github.com/ruby/ruby/blob/trunk/lib/rdoc/servlet.rb#L387
 
   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 docum https://github.com/ruby/ruby/blob/trunk/lib/rdoc/servlet.rb#L400
         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
Index: lib/rdoc/any_method.rb
===================================================================
--- lib/rdoc/any_method.rb	(revision 38898)
+++ lib/rdoc/any_method.rb	(revision 38899)
@@ -123,6 +123,8 @@ class RDoc::AnyMethod < RDoc::MethodAttr https://github.com/ruby/ruby/blob/trunk/lib/rdoc/any_method.rb#L123
   # * #parent_name
 
   def marshal_load array
+    initialize_visibility
+
     @dont_rename_initialize = nil
     @is_alias_for           = nil
     @token_stream           = nil
Index: lib/rdoc/attr.rb
===================================================================
--- lib/rdoc/attr.rb	(revision 38898)
+++ lib/rdoc/attr.rb	(revision 38899)
@@ -121,6 +121,8 @@ class RDoc::Attr < RDoc::MethodAttr https://github.com/ruby/ruby/blob/trunk/lib/rdoc/attr.rb#L121
   # * #parent_name
 
   def marshal_load array
+    initialize_visibility
+
     @aliases      = []
     @parent       = nil
     @parent_name  = nil
Index: test/rdoc/test_rdoc_attr.rb
===================================================================
--- test/rdoc/test_rdoc_attr.rb	(revision 38898)
+++ test/rdoc/test_rdoc_attr.rb	(revision 38899)
@@ -137,6 +137,8 @@ class TestRDocAttr < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_attr.rb#L137
     # 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 https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_attr.rb#L167
     # version 3
     assert_equal cm,           loaded.parent
     assert_equal section,      loaded.section
+
+    assert loaded.display?
   end
 
   def test_params
Index: test/rdoc/test_rdoc_top_level.rb
===================================================================
--- test/rdoc/test_rdoc_top_level.rb	(revision 38898)
+++ test/rdoc/test_rdoc_top_level.rb	(revision 38899)
@@ -205,6 +205,8 @@ class TestRDocTopLevel < XrefTestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_top_level.rb#L205
     assert_equal RDoc::Parser::Simple, loaded.parser
 
     assert_equal comment, loaded.comment
+
+    assert loaded.display?
   end
 
   def test_name
Index: test/rdoc/test_rdoc_constant.rb
===================================================================
--- test/rdoc/test_rdoc_constant.rb	(revision 38898)
+++ test/rdoc/test_rdoc_constant.rb	(revision 38899)
@@ -86,6 +86,8 @@ class TestRDocConstant < XrefTestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_constant.rb#L86
     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 https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_constant.rb#L118
     assert_nil                   loaded.visibility
     assert_equal cm,             loaded.parent
     assert_equal section,        loaded.section
+
+    assert loaded.display?
   end
 
   def test_marshal_round_trip
Index: test/rdoc/test_rdoc_servlet.rb
===================================================================
--- test/rdoc/test_rdoc_servlet.rb	(revision 38898)
+++ test/rdoc/test_rdoc_servlet.rb	(revision 38899)
@@ -12,7 +12,7 @@ class TestRDocServlet < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_servlet.rb#L12
     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 https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_servlet.rb#L34
 
     @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 https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_servlet.rb#L418
     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'
Index: test/rdoc/test_rdoc_any_method.rb
===================================================================
--- test/rdoc/test_rdoc_any_method.rb	(revision 38898)
+++ test/rdoc/test_rdoc_any_method.rb	(revision 38899)
@@ -100,24 +100,31 @@ method(a, b) { |c, d| ... } https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_any_method.rb#L100
     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| ... } https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_any_method.rb#L170
     assert_equal nil,            loaded.file
     assert_equal cm,             loaded.parent
     assert_equal section,        loaded.section
+
+    assert loaded.display?
   end
 
   def test_name
Index: test/rdoc/test_rdoc_class_module.rb
===================================================================
--- test/rdoc/test_rdoc_class_module.rb	(revision 38898)
+++ test/rdoc/test_rdoc_class_module.rb	(revision 38899)
@@ -289,6 +289,8 @@ class TestRDocClassModule < XrefTestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_class_module.rb#L289
 
     expected = { nil => s0 }
     assert_equal expected, loaded.sections_hash
+
+    assert loaded.display?
   end
 
   def test_marshal_load_version_1

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]