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

ruby-changes:26436

From: drbrain <ko1@a...>
Date: Thu, 20 Dec 2012 12:57:18 +0900 (JST)
Subject: [ruby-changes:26436] drbrain:r38487 (trunk): * lib/rdoc/markup/to_html.rb (class RDoc): Added current heading and

drbrain	2012-12-20 12:57:08 +0900 (Thu, 20 Dec 2012)

  New Revision: 38487

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

  Log:
    * lib/rdoc/markup/to_html.rb (class RDoc):  Added current heading and
      top links to headings.
    * lib/rdoc/generator/template/darkfish/rdoc.css:  ditto
    * test/rdoc/test_rdoc_generator_markup.rb:  Test for above
    * test/rdoc/test_rdoc_markup_to_html.rb:  ditto
    
    * test/rdoc/test_rdoc_comment.rb:  Removed trailing whitespace.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rdoc/generator/template/darkfish/rdoc.css
    trunk/lib/rdoc/markup/to_html.rb
    trunk/test/rdoc/test_rdoc_comment.rb
    trunk/test/rdoc/test_rdoc_generator_markup.rb
    trunk/test/rdoc/test_rdoc_markup_to_html.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38486)
+++ ChangeLog	(revision 38487)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Dec 20 12:56:53 2012  Eric Hodel  <drbrain@s...>
+
+	* lib/rdoc/markup/to_html.rb (class RDoc):  Added current heading and
+	  top links to headings.
+	* lib/rdoc/generator/template/darkfish/rdoc.css:  ditto
+	* test/rdoc/test_rdoc_generator_markup.rb:  Test for above
+	* test/rdoc/test_rdoc_markup_to_html.rb:  ditto
+
+	* test/rdoc/test_rdoc_comment.rb:  Removed trailing whitespace.
+
 Thu Dec 20 11:05:26 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* test/ruby/envutil.rb (assert_valid_syntax): move from
Index: lib/rdoc/generator/template/darkfish/rdoc.css
===================================================================
--- lib/rdoc/generator/template/darkfish/rdoc.css	(revision 38486)
+++ lib/rdoc/generator/template/darkfish/rdoc.css	(revision 38487)
@@ -28,6 +28,27 @@ h1 { https://github.com/ruby/ruby/blob/trunk/lib/rdoc/generator/template/darkfish/rdoc.css#L28
 }
 h2,h3,h4 { margin-top: 1.5em; }
 
+h1 span,
+h2 span,
+h3 span,
+h4 span,
+h5 span,
+h6 span {
+  display: none;
+  padding-left: 1em;
+  font-size: 50%;
+  vertical-align: super;
+}
+
+h1:hover span,
+h2:hover span,
+h3:hover span,
+h4:hover span,
+h5:hover span,
+h6:hover span {
+  display: inline;
+}
+
 :link,
 :visited {
   color: #6C8C22;
Index: lib/rdoc/markup/to_html.rb
===================================================================
--- lib/rdoc/markup/to_html.rb	(revision 38486)
+++ lib/rdoc/markup/to_html.rb	(revision 38487)
@@ -268,6 +268,10 @@ class RDoc::Markup::ToHtml < RDoc::Marku https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/to_html.rb#L268
 
     @res << "\n<h#{level} id=\"#{label}\">"
     @res << to_html(heading.text)
+    unless @options.pipe then
+      @res << "<span><a href=\"##{label}\">&para;</a>"
+      @res << " <a href=\"#documentation\">&uarr;</a></span>"
+    end
     @res << "</h#{level}>\n"
   end
 
Index: test/rdoc/test_rdoc_comment.rb
===================================================================
--- test/rdoc/test_rdoc_comment.rb	(revision 38486)
+++ test/rdoc/test_rdoc_comment.rb	(revision 38487)
@@ -70,7 +70,7 @@ call-seq: https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_comment.rb#L70
     comment = RDoc::Comment.new <<-COMMENT, @top_level
 # call-seq:
 #   bla => true or false
-#\s
+#
 # moar comment
     COMMENT
 
Index: test/rdoc/test_rdoc_generator_markup.rb
===================================================================
--- test/rdoc/test_rdoc_generator_markup.rb	(revision 38486)
+++ test/rdoc/test_rdoc_generator_markup.rb	(revision 38487)
@@ -37,7 +37,10 @@ class TestRDocGeneratorMarkup < RDoc::Te https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_generator_markup.rb#L37
   def test_description
     @comment = '= Hello'
 
-    assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", description
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", description
   end
 
   def test_formatter
Index: test/rdoc/test_rdoc_markup_to_html.rb
===================================================================
--- test/rdoc/test_rdoc_markup_to_html.rb	(revision 38486)
+++ test/rdoc/test_rdoc_markup_to_html.rb	(revision 38487)
@@ -23,32 +23,55 @@ class TestRDocMarkupToHtml < RDoc::Marku https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L23
   end
 
   def accept_heading
-    assert_equal "\n<h5 id=\"label-Hello\">Hello</h5>\n", @to.res.join
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+    expected = "\n<h5 id=\"label-Hello\">Hello#{links}</h5>\n"
+
+    assert_equal expected, @to.res.join
   end
 
   def accept_heading_1
-    assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
   end
 
   def accept_heading_2
-    assert_equal "\n<h2 id=\"label-Hello\">Hello</h2>\n", @to.res.join
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h2 id=\"label-Hello\">Hello#{links}</h2>\n", @to.res.join
   end
 
   def accept_heading_3
-    assert_equal "\n<h3 id=\"label-Hello\">Hello</h3>\n", @to.res.join
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h3 id=\"label-Hello\">Hello#{links}</h3>\n", @to.res.join
   end
 
   def accept_heading_4
-    assert_equal "\n<h4 id=\"label-Hello\">Hello</h4>\n", @to.res.join
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h4 id=\"label-Hello\">Hello#{links}</h4>\n", @to.res.join
   end
 
   def accept_heading_b
-    assert_equal "\n<h1 id=\"label-Hello\"><strong>Hello</strong></h1>\n",
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+    inner = "<strong>Hello</strong>"
+
+    assert_equal "\n<h1 id=\"label-Hello\">#{inner}#{links}</h1>\n",
                  @to.res.join
   end
 
   def accept_heading_suppressed_crossref
-    assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
   end
 
   def accept_list_end_bullet
@@ -324,7 +347,10 @@ class TestRDocMarkupToHtml < RDoc::Marku https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L347
 
     @to.accept_heading @RM::Heading.new(7, 'Hello')
 
-    assert_equal "\n<h6 id=\"label-Hello\">Hello</h6>\n", @to.res.join
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h6 id=\"label-Hello\">Hello#{links}</h6>\n", @to.res.join
   end
 
   def test_accept_heading_aref_class
@@ -333,7 +359,10 @@ class TestRDocMarkupToHtml < RDoc::Marku https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L359
 
     @to.accept_heading @RM::Heading.new(1, 'Hello')
 
-    assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n",
+    links = '<span><a href="#label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n",
                  @to.res.join
   end
 
@@ -343,10 +372,23 @@ class TestRDocMarkupToHtml < RDoc::Marku https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L372
 
     @to.accept_heading @RM::Heading.new(1, 'Hello')
 
-    assert_equal "\n<h1 id=\"method-i-foo-label-Hello\">Hello</h1>\n",
+    links = '<span><a href="#method-i-foo-label-Hello">&para;</a> ' +
+            '<a href="#documentation">&uarr;</a></span>'
+
+    assert_equal "\n<h1 id=\"method-i-foo-label-Hello\">Hello#{links}</h1>\n",
                  @to.res.join
   end
 
+  def test_accept_heading_pipe
+    @options.pipe = true
+
+    @to.start_accepting
+
+    @to.accept_heading @RM::Heading.new(1, 'Hello')
+
+    assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
+  end
+
   def test_accept_verbatim_parseable
     verb = @RM::Verbatim.new("class C\n", "end\n")
 

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

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