Merged in tk0miya/sphinx (pull request #266)

Rename :filename: option of code-block directive to :caption:
This commit is contained in:
Takayuki Shimizukawa
2014-08-24 11:02:36 +09:00
13 changed files with 89 additions and 25 deletions

View File

@@ -0,0 +1,21 @@
Dedent
======
Code blocks
-----------
.. code-block:: ruby
:caption: caption-test.rb
def ruby?
false
end
Literal Include
---------------
.. literalinclude:: literal.inc
:language: python
:caption: caption-test.py
:lines: 10-11

View File

@@ -2,6 +2,7 @@ test-directive-code
===================
.. toctree::
:glob:
*

View File

@@ -77,6 +77,27 @@ def test_code_block_dedent(app):
assert actual == '\n\n'
@with_app(buildername='html',
srcdir=(test_roots / 'test-directive-code'),
_copy_to_temp=True)
def test_code_block_caption_html(app):
app.builder.build('index')
html = (app.outdir / 'caption.html').text()
caption = '<div class="code-block-caption"><code>caption-test.rb</code></div>'
assert caption in html
@with_app(buildername='latex',
srcdir=(test_roots / 'test-directive-code'),
_copy_to_temp=True)
def test_code_block_caption_latex(app):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text()
caption = ('{\\colorbox[rgb]{0.9,0.9,0.9}{\\makebox[\\textwidth][l]'
'{\\small\\texttt{caption-test.rb}}}}')
assert caption in latex
@with_app(buildername='xml',
srcdir=(test_roots / 'test-directive-code'),
_copy_to_temp=True)
@@ -129,3 +150,24 @@ def test_literal_include_dedent(app):
actual = get_dedent_actual(1000)
assert actual == '\n\n'
@with_app(buildername='html',
srcdir=(test_roots / 'test-directive-code'),
_copy_to_temp=True)
def test_literalinclude_caption_html(app):
app.builder.build('index')
html = (app.outdir / 'caption.html').text()
caption = '<div class="code-block-caption"><code>caption-test.py</code></div>'
assert caption in html
@with_app(buildername='latex',
srcdir=(test_roots / 'test-directive-code'),
_copy_to_temp=True)
def test_literalinclude_caption_latex(app):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text()
caption = ('{\\colorbox[rgb]{0.9,0.9,0.9}{\\makebox[\\textwidth][l]'
'{\\small\\texttt{caption-test.py}}}}')
assert caption in latex