mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merged in tk0miya/sphinx (pull request #266)
Rename :filename: option of code-block directive to :caption:
This commit is contained in:
21
tests/roots/test-directive-code/caption.rst
Normal file
21
tests/roots/test-directive-code/caption.rst
Normal 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
|
||||
@@ -2,6 +2,7 @@ test-directive-code
|
||||
===================
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
*
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user