mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Update testcases for :numref:
This commit is contained in:
parent
0d28a95f85
commit
8270575a9c
@ -24,6 +24,7 @@ exclude_patterns = ['_build', '**/excluded.*']
|
||||
keep_warnings = True
|
||||
pygments_style = 'sphinx'
|
||||
show_authors = True
|
||||
numfig = True
|
||||
|
||||
rst_epilog = '.. |subst| replace:: global substitution'
|
||||
|
||||
|
@ -143,6 +143,9 @@ Adding \n to test unescaping.
|
||||
* :ref:`my-figure`
|
||||
* :ref:`my-table`
|
||||
* :ref:`my-code-block`
|
||||
* :numref:`my-figure`
|
||||
* :numref:`my-table`
|
||||
* :numref:`my-code-block`
|
||||
* :doc:`subdir/includes`
|
||||
* ``:download:`` is tested in includes.txt
|
||||
* :option:`Python -c option <python -c>`
|
||||
|
@ -1,15 +1,21 @@
|
||||
Baz A
|
||||
-----
|
||||
|
||||
.. _fig22:
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.2.2
|
||||
|
||||
.. _table22:
|
||||
|
||||
.. csv-table:: should be Table 2.2
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. _code22:
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 2.2
|
||||
|
||||
|
@ -7,6 +7,8 @@ test-tocdepth
|
||||
foo
|
||||
bar
|
||||
|
||||
.. _fig1:
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.1
|
||||
@ -15,6 +17,8 @@ test-tocdepth
|
||||
|
||||
should be Fig.2
|
||||
|
||||
.. _table1:
|
||||
|
||||
.. csv-table:: should be Table 1
|
||||
:header-rows: 0
|
||||
|
||||
@ -25,6 +29,8 @@ test-tocdepth
|
||||
|
||||
hello,world
|
||||
|
||||
.. _code1:
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 1
|
||||
|
||||
@ -34,3 +40,11 @@ test-tocdepth
|
||||
:caption: should be List 2
|
||||
|
||||
print('hello world')
|
||||
|
||||
|
||||
* Fig.1 is :numref:`fig1`
|
||||
* Fig.2.2 is :numref:`Figure# <fig22>`
|
||||
* Table.1 is :numref:`table1`
|
||||
* Table.2.2 is :numref:`Table:# <table22>`
|
||||
* List.1 is :numref:`code1`
|
||||
* List.2.2 is :numref:`Code-# <code22>`
|
||||
|
@ -458,8 +458,7 @@ def test_tocdepth_singlehtml(app, status, warning):
|
||||
|
||||
|
||||
@gen_with_app(buildername='html', testroot='numfig')
|
||||
def test_numfig(app, status, warning):
|
||||
# issue #1251
|
||||
def test_numfig_disabled(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
@ -474,6 +473,12 @@ def test_numfig(app, status, warning):
|
||||
'^should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 2$', True),
|
||||
(".//li/code/span", '^fig1$', True),
|
||||
(".//li/code/span", '^Figure#$', True),
|
||||
(".//li/code/span", '^table1$', True),
|
||||
(".//li/code/span", '^Table:#$', True),
|
||||
(".//li/code/span", '^code1$', True),
|
||||
(".//li/code/span", '^Code-#$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@ -557,6 +562,12 @@ def test_numfig_without_numbered_toctree(app, status, warning):
|
||||
'^List 9 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 10 should be List 2$', True),
|
||||
(".//li/a/em", '^Fig.9$', True),
|
||||
(".//li/a/em", '^Figure6$', True),
|
||||
(".//li/a/em", '^Table 9$', True),
|
||||
(".//li/a/em", '^Table:6$', True),
|
||||
(".//li/a/em", '^List 9$', True),
|
||||
(".//li/a/em", '^Code-6$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@ -636,6 +647,12 @@ def test_numfig_with_numbered_toctree(app, status, warning):
|
||||
'^List 1 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2 should be List 2$', True),
|
||||
(".//li/a/em", '^Fig.1$', True),
|
||||
(".//li/a/em", '^Figure2.2$', True),
|
||||
(".//li/a/em", '^Table 1$', True),
|
||||
(".//li/a/em", '^Table:2.2$', True),
|
||||
(".//li/a/em", '^List 1$', True),
|
||||
(".//li/a/em", '^Code-2.2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@ -715,6 +732,12 @@ def test_numfig_with_prefix(app, status, warning):
|
||||
'^Code-1 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-2 should be List 2$', True),
|
||||
(".//li/a/em", '^Figure:1$', True),
|
||||
(".//li/a/em", '^Figure2.2$', True),
|
||||
(".//li/a/em", '^Tab_1$', True),
|
||||
(".//li/a/em", '^Table:2.2$', True),
|
||||
(".//li/a/em", '^Code-1$', True),
|
||||
(".//li/a/em", '^Code-2.2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@ -794,6 +817,12 @@ def test_numfig_with_secnum_depth(app, status, warning):
|
||||
'^List 1 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2 should be List 2$', True),
|
||||
(".//li/a/em", '^Fig.1$', True),
|
||||
(".//li/a/em", '^Figure2.1.2$', True),
|
||||
(".//li/a/em", '^Table 1$', True),
|
||||
(".//li/a/em", '^Table:2.1.2$', True),
|
||||
(".//li/a/em", '^List 1$', True),
|
||||
(".//li/a/em", '^Code-2.1.2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
|
@ -93,6 +93,22 @@ def test_latex(app, status, warning):
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
@with_app(buildername='latex', testroot='numfig',
|
||||
confoverrides={'numfig': True})
|
||||
def test_numref(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\ref{index:fig1}' in result
|
||||
assert '\\ref{baz:fig22}' in result
|
||||
assert '\\ref{index:table1}' in result
|
||||
assert '\\ref{baz:table22}' in result
|
||||
assert '\\ref{index:code1}' in result
|
||||
assert '\\ref{baz:code22}' in result
|
||||
|
||||
|
||||
@with_app(buildername='latex')
|
||||
def test_latex_add_latex_package(app, status, warning):
|
||||
app.add_latex_package('foo')
|
||||
|
Loading…
Reference in New Issue
Block a user