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

ruby-changes:26281

From: drbrain <ko1@a...>
Date: Wed, 12 Dec 2012 14:17:06 +0900 (JST)
Subject: [ruby-changes:26281] drbrain:r38338 (trunk): * lib/rdoc/class_module.rb: Added RDoc::ClassModule#documented? which

drbrain	2012-12-12 14:16:53 +0900 (Wed, 12 Dec 2012)

  New Revision: 38338

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

  Log:
    * lib/rdoc/class_module.rb:  Added RDoc::ClassModule#documented? which
      checks comment_location.  Hide RDoc::ClassModule#comment=.
    * test/rdoc/test_rdoc_class_module.rb:  Test for above.
    
    * lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml:
      Fix display of the table of contents in the sidebar.
    
    * lib/rdoc/generator/template/darkfish/table_of_contents.rhtml:
      Use #comment_location when displaying classes or modules.
    
    * test/rdoc/test_rdoc_store.rb:  Use comment_location.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rdoc/class_module.rb
    trunk/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml
    trunk/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml
    trunk/test/rdoc/test_rdoc_class_module.rb
    trunk/test/rdoc/test_rdoc_store.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38337)
+++ ChangeLog	(revision 38338)
@@ -1,3 +1,17 @@
+Wed Dec 12 14:16:35 2012  Eric Hodel  <drbrain@s...>
+
+	* lib/rdoc/class_module.rb:  Added RDoc::ClassModule#documented? which
+	  checks comment_location.  Hide RDoc::ClassModule#comment=.
+	* test/rdoc/test_rdoc_class_module.rb:  Test for above.
+
+	* lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml:
+	  Fix display of the table of contents in the sidebar.
+
+	* lib/rdoc/generator/template/darkfish/table_of_contents.rhtml:
+	  Use #comment_location when displaying classes or modules.
+
+	* test/rdoc/test_rdoc_store.rb:  Use comment_location.
+
 Wed Dec 12 13:40:52 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_insnhelper.c (vm_getivar): no uninitialized instance variables
Index: lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml
===================================================================
--- lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml	(revision 38337)
+++ lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml	(revision 38338)
@@ -1,4 +1,10 @@
-<% table = current.parse(current.comment).table_of_contents
+<% comment = if current.respond_to? :comment_location then
+               current.comment_location
+             else
+               current.comment
+             end
+   table = current.parse(comment).table_of_contents
+
    if table.length > 1 then %>
 <div id="table-of-contents">
   <nav class="section">
Index: lib/rdoc/generator/template/darkfish/table_of_contents.rhtml
===================================================================
--- lib/rdoc/generator/template/darkfish/table_of_contents.rhtml	(revision 38337)
+++ lib/rdoc/generator/template/darkfish/table_of_contents.rhtml	(revision 38338)
@@ -30,7 +30,7 @@
   <li class="<%= klass.type %>">
     <a href="<%= klass.path %>"><%= klass.full_name %></a>
 <% table = []
-   table.concat klass.parse(klass.comment).table_of_contents
+   table.concat klass.parse(klass.comment_location).table_of_contents
    table.concat klass.section_contents
 
    unless table.empty? then %>
Index: lib/rdoc/class_module.rb
===================================================================
--- lib/rdoc/class_module.rb	(revision 38337)
+++ lib/rdoc/class_module.rb	(revision 38338)
@@ -184,7 +184,7 @@
   # Appends +comment+ to the current comment, but separated by a rule.  Works
   # more like <tt>+=</tt>.
 
-  def comment= comment
+  def comment= comment # :nodoc:
     comment = case comment
               when RDoc::Comment then
                 comment.normalize
@@ -217,6 +217,14 @@
   end
 
   ##
+  # Does this class or module have a comment with content or is
+  # #received_nodoc true?
+
+  def documented?
+    super or !@comment_location.empty?
+  end
+
+  ##
   # Iterates the ancestors of this class or module for which an
   # RDoc::ClassModule exists.
 
Index: test/rdoc/test_rdoc_store.rb
===================================================================
--- test/rdoc/test_rdoc_store.rb	(revision 38337)
+++ test/rdoc/test_rdoc_store.rb	(revision 38338)
@@ -708,7 +708,7 @@
 
     document = @RM::Document.new inner
 
-    assert_equal document, s.load_class('Object').comment
+    assert_equal document, s.load_class('Object').comment_location
   end
 
   # This is a functional test
Index: test/rdoc/test_rdoc_class_module.rb
===================================================================
--- test/rdoc/test_rdoc_class_module.rb	(revision 38337)
+++ test/rdoc/test_rdoc_class_module.rb	(revision 38338)
@@ -95,6 +95,28 @@
     refute @c1.document_self_or_methods
   end
 
+  def test_documented_eh
+    cm = RDoc::ClassModule.new 'C'
+
+    refute cm.documented?
+
+    cm.add_comment 'hi', @top_level
+
+    assert cm.documented?
+
+    cm.comment.replace ''
+
+    assert cm.documented?
+
+    cm.comment_location.clear
+
+    refute cm.documented?
+
+    cm.document_self = nil # notify :nodoc:
+
+    assert cm.documented?
+  end
+
   def test_each_ancestor
     assert_equal [@parent], @child.each_ancestor.to_a
   end

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

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