From ec6cacf00ad0dcf8a37cdfe2f31e6a06cd2a7262 Mon Sep 17 00:00:00 2001 From: drbrain Date: Thu, 20 Dec 2012 03:57:08 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 +++ lib/rdoc/generator/template/darkfish/rdoc.css | 21 +++++++ lib/rdoc/markup/to_html.rb | 4 ++ test/rdoc/test_rdoc_comment.rb | 2 +- test/rdoc/test_rdoc_generator_markup.rb | 5 +- test/rdoc/test_rdoc_markup_to_html.rb | 62 ++++++++++++++++--- 6 files changed, 92 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a6a4c7eb3..389cdefceb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Thu Dec 20 12:56:53 2012 Eric Hodel + + * 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 * test/ruby/envutil.rb (assert_valid_syntax): move from diff --git a/lib/rdoc/generator/template/darkfish/rdoc.css b/lib/rdoc/generator/template/darkfish/rdoc.css index b965e604e6..35207033de 100644 --- a/lib/rdoc/generator/template/darkfish/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/rdoc.css @@ -28,6 +28,27 @@ h1 { } 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; diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index afe35c26ca..37b9492e23 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -268,6 +268,10 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter @res << "\n" @res << to_html(heading.text) + unless @options.pipe then + @res << "" + @res << " " + end @res << "\n" end diff --git a/test/rdoc/test_rdoc_comment.rb b/test/rdoc/test_rdoc_comment.rb index 4d0d54edca..2a1318b66c 100644 --- a/test/rdoc/test_rdoc_comment.rb +++ b/test/rdoc/test_rdoc_comment.rb @@ -70,7 +70,7 @@ call-seq: comment = RDoc::Comment.new <<-COMMENT, @top_level # call-seq: # bla => true or false -#\s +# # moar comment COMMENT diff --git a/test/rdoc/test_rdoc_generator_markup.rb b/test/rdoc/test_rdoc_generator_markup.rb index 1b44085283..b3b5c04588 100644 --- a/test/rdoc/test_rdoc_generator_markup.rb +++ b/test/rdoc/test_rdoc_generator_markup.rb @@ -37,7 +37,10 @@ class TestRDocGeneratorMarkup < RDoc::TestCase def test_description @comment = '= Hello' - assert_equal "\n

Hello

\n", description + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\n", description end def test_formatter diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index ffff6895d1..ebd2fe7dd2 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -23,32 +23,55 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase end def accept_heading - assert_equal "\n
Hello
\n", @to.res.join + links = ' ' + + '' + expected = "\n
Hello#{links}
\n" + + assert_equal expected, @to.res.join end def accept_heading_1 - assert_equal "\n

Hello

\n", @to.res.join + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_2 - assert_equal "\n

Hello

\n", @to.res.join + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_3 - assert_equal "\n

Hello

\n", @to.res.join + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_4 - assert_equal "\n

Hello

\n", @to.res.join + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_b - assert_equal "\n

Hello

\n", + links = ' ' + + '' + inner = "Hello" + + assert_equal "\n

#{inner}#{links}

\n", @to.res.join end def accept_heading_suppressed_crossref - assert_equal "\n

Hello

\n", @to.res.join + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_list_end_bullet @@ -324,7 +347,10 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_heading @RM::Heading.new(7, 'Hello') - assert_equal "\n
Hello
\n", @to.res.join + links = ' ' + + '' + + assert_equal "\n
Hello#{links}
\n", @to.res.join end def test_accept_heading_aref_class @@ -333,7 +359,10 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_heading @RM::Heading.new(1, 'Hello') - assert_equal "\n

Hello

\n", + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\n", @to.res.join end @@ -343,10 +372,23 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_heading @RM::Heading.new(1, 'Hello') - assert_equal "\n

Hello

\n", + links = ' ' + + '' + + assert_equal "\n

Hello#{links}

\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

Hello

\n", @to.res.join + end + def test_accept_verbatim_parseable verb = @RM::Verbatim.new("class C\n", "end\n")