mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-13 17:02:12 -05:00
Assign fignum to tables and code-blocks
This commit is contained in:
1 parent
cffec13355
commit
7cd470f59a
9 files changed
+300
-13
No files matched your search
@@ -15,6 +15,16 @@ should be 2.1
|
||||
|
||||
should be Fig.2.1
|
||||
|
||||
.. csv-table:: should be Table 2.1
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 2.1
|
||||
|
||||
print('hello world')
|
||||
|
||||
.. toctree::
|
||||
|
||||
baz
|
||||
@@ -23,6 +33,16 @@ should be 2.1
|
||||
|
||||
should be Fig.2.3
|
||||
|
||||
.. csv-table:: should be Table 2.3
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 2.3
|
||||
|
||||
print('hello world')
|
||||
|
||||
Bar B
|
||||
=====
|
||||
|
||||
@@ -36,3 +56,13 @@ should be 2.2.1
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.2.4
|
||||
|
||||
.. csv-table:: should be Table 2.4
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 2.4
|
||||
|
||||
print('hello world')
|
||||
@@ -6,3 +6,13 @@ should be 2.1.1
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.2.2
|
||||
|
||||
.. csv-table:: should be Table 2.2
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 2.2
|
||||
|
||||
print('hello world')
|
||||
@@ -8,6 +8,16 @@ should be 1
|
||||
|
||||
should be Fig.1.1
|
||||
|
||||
.. csv-table:: should be Table 1.1
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 1.1
|
||||
|
||||
print('hello world')
|
||||
|
||||
Foo A
|
||||
=====
|
||||
|
||||
@@ -21,6 +31,26 @@ should be 1.1
|
||||
|
||||
should be Fig.1.3
|
||||
|
||||
.. csv-table:: should be Table 1.2
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. csv-table:: should be Table 1.3
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 1.2
|
||||
|
||||
print('hello world')
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 1.3
|
||||
|
||||
print('hello world')
|
||||
|
||||
Foo A1
|
||||
------
|
||||
|
||||
@@ -39,3 +69,13 @@ should be 1.2.1
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.1.4
|
||||
|
||||
.. csv-table:: should be Table 1.4
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 1.4
|
||||
|
||||
print('hello world')
|
||||
@@ -14,3 +14,23 @@ test-tocdepth
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.2
|
||||
|
||||
.. csv-table:: should be Table 1
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. csv-table:: should be Table 2
|
||||
:header-rows: 0
|
||||
|
||||
hello,world
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 1
|
||||
|
||||
print('hello world')
|
||||
|
||||
.. code-block:: python
|
||||
:caption: should be List 2
|
||||
|
||||
print('hello world')
|
||||
+151
-1
@@ -384,6 +384,12 @@ def test_tocdepth(app, status, warning):
|
||||
'^should be Fig.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^should be Fig.2$', True),
|
||||
(".//table/caption", '^should be Table 1$', True),
|
||||
(".//table/caption", '^should be Table 2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//h1", '1. Foo', True),
|
||||
@@ -399,6 +405,18 @@ def test_tocdepth(app, status, warning):
|
||||
'^should be Fig.1.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^should be Fig.1.4$', True),
|
||||
(".//table/caption", '^should be Table 1.1$', True),
|
||||
(".//table/caption", '^should be Table 1.2$', True),
|
||||
(".//table/caption", '^should be Table 1.3$', True),
|
||||
(".//table/caption", '^should be Table 1.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 1.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 1.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 1.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 1.4$', True),
|
||||
],
|
||||
'bar.html': [
|
||||
(".//h1", '2. Bar', True),
|
||||
@@ -411,11 +429,23 @@ def test_tocdepth(app, status, warning):
|
||||
'^should be Fig.2.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^should be Fig.2.4$', True),
|
||||
(".//table/caption", '^should be Table 2.1$', True),
|
||||
(".//table/caption", '^should be Table 2.3$', True),
|
||||
(".//table/caption", '^should be Table 2.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 2.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 2.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 2.4$', True),
|
||||
],
|
||||
'baz.html': [
|
||||
(".//h1", '2.1.1. Baz A', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^should be Fig.2.2$', True),
|
||||
(".//table/caption", '^should be Table 2.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^should be List 2.2$', True),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -447,6 +477,12 @@ def test_unnumbered_toctree_with_numfig(app, status, warning):
|
||||
'^Fig.9 should be Fig.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.10 should be Fig.2$', True),
|
||||
(".//table/caption", '^Table 9 should be Table 1$', True),
|
||||
(".//table/caption", '^Table 10 should be Table 2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 9 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 10 should be List 2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -457,6 +493,18 @@ def test_unnumbered_toctree_with_numfig(app, status, warning):
|
||||
'^Fig.3 should be Fig.1.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.4 should be Fig.1.4$', True),
|
||||
(".//table/caption", '^Table 1 should be Table 1.1$', True),
|
||||
(".//table/caption", '^Table 2 should be Table 1.2$', True),
|
||||
(".//table/caption", '^Table 3 should be Table 1.3$', True),
|
||||
(".//table/caption", '^Table 4 should be Table 1.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1 should be List 1.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2 should be List 1.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 3 should be List 1.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 4 should be List 1.4$', True),
|
||||
],
|
||||
'bar.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -465,10 +513,22 @@ def test_unnumbered_toctree_with_numfig(app, status, warning):
|
||||
'^Fig.7 should be Fig.2.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.8 should be Fig.2.4$', True),
|
||||
(".//table/caption", '^Table 5 should be Table 2.1$', True),
|
||||
(".//table/caption", '^Table 7 should be Table 2.3$', True),
|
||||
(".//table/caption", '^Table 8 should be Table 2.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 5 should be List 2.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 7 should be List 2.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 8 should be List 2.4$', True),
|
||||
],
|
||||
'baz.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.6 should be Fig.2.2$', True),
|
||||
(".//table/caption", '^Table 6 should be Table 2.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 6 should be List 2.2$', True),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -496,6 +556,12 @@ def test_numbered_toctree_with_numfig(app, status, warning):
|
||||
'^Fig.1 should be Fig.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.2 should be Fig.2$', True),
|
||||
(".//table/caption", '^Table 1 should be Table 1$', True),
|
||||
(".//table/caption", '^Table 2 should be Table 2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2 should be List 2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -506,6 +572,18 @@ def test_numbered_toctree_with_numfig(app, status, warning):
|
||||
'^Fig.1.3 should be Fig.1.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.1.4 should be Fig.1.4$', True),
|
||||
(".//table/caption", '^Table 1.1 should be Table 1.1$', True),
|
||||
(".//table/caption", '^Table 1.2 should be Table 1.2$', True),
|
||||
(".//table/caption", '^Table 1.3 should be Table 1.3$', True),
|
||||
(".//table/caption", '^Table 1.4 should be Table 1.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.1 should be List 1.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.2 should be List 1.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.3 should be List 1.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.4 should be List 1.4$', True),
|
||||
],
|
||||
'bar.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -514,10 +592,22 @@ def test_numbered_toctree_with_numfig(app, status, warning):
|
||||
'^Fig.2.3 should be Fig.2.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.2.4 should be Fig.2.4$', True),
|
||||
(".//table/caption", '^Table 2.1 should be Table 2.1$', True),
|
||||
(".//table/caption", '^Table 2.3 should be Table 2.3$', True),
|
||||
(".//table/caption", '^Table 2.4 should be Table 2.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.1 should be List 2.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.3 should be List 2.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.4 should be List 2.4$', True),
|
||||
],
|
||||
'baz.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.2.2 should be Fig.2.2$', True),
|
||||
(".//table/caption", '^Table 2.2 should be Table 2.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.2 should be List 2.2$', True),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -535,7 +625,7 @@ def test_numbered_toctree_with_numfig(app, status, warning):
|
||||
|
||||
|
||||
@gen_with_app(buildername='html', testroot='tocdepth',
|
||||
confoverrides={'numfig': True, 'numfig_prefix': {'figure': 'Figure:'}})
|
||||
confoverrides={'numfig': True, 'numfig_prefix': {'figure': 'Figure:', 'table': 'Tab_', 'code-block': 'Code-'}})
|
||||
def test_numbered_toctree_with_numfig_prefix(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
@@ -545,6 +635,12 @@ def test_numbered_toctree_with_numfig_prefix(app, status, warning):
|
||||
'^Figure:1 should be Fig.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Figure:2 should be Fig.2$', True),
|
||||
(".//table/caption", '^Tab_1 should be Table 1$', True),
|
||||
(".//table/caption", '^Tab_2 should be Table 2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-1 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-2 should be List 2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -555,6 +651,18 @@ def test_numbered_toctree_with_numfig_prefix(app, status, warning):
|
||||
'^Figure:1.3 should be Fig.1.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Figure:1.4 should be Fig.1.4$', True),
|
||||
(".//table/caption", '^Tab_1.1 should be Table 1.1$', True),
|
||||
(".//table/caption", '^Tab_1.2 should be Table 1.2$', True),
|
||||
(".//table/caption", '^Tab_1.3 should be Table 1.3$', True),
|
||||
(".//table/caption", '^Tab_1.4 should be Table 1.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-1.1 should be List 1.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-1.2 should be List 1.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-1.3 should be List 1.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-1.4 should be List 1.4$', True),
|
||||
],
|
||||
'bar.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -563,10 +671,22 @@ def test_numbered_toctree_with_numfig_prefix(app, status, warning):
|
||||
'^Figure:2.3 should be Fig.2.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Figure:2.4 should be Fig.2.4$', True),
|
||||
(".//table/caption", '^Tab_2.1 should be Table 2.1$', True),
|
||||
(".//table/caption", '^Tab_2.3 should be Table 2.3$', True),
|
||||
(".//table/caption", '^Tab_2.4 should be Table 2.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-2.1 should be List 2.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-2.3 should be List 2.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-2.4 should be List 2.4$', True),
|
||||
],
|
||||
'baz.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Figure:2.2 should be Fig.2.2$', True),
|
||||
(".//table/caption", '^Tab_2.2 should be Table 2.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^Code-2.2 should be List 2.2$', True),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -594,6 +714,12 @@ def test_numbered_toctree_with_numfig_secnum_depth(app, status, warning):
|
||||
'^Fig.1 should be Fig.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.2 should be Fig.2$', True),
|
||||
(".//table/caption", '^Table 1 should be Table 1$', True),
|
||||
(".//table/caption", '^Table 2 should be Table 2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1 should be List 1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2 should be List 2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -604,6 +730,18 @@ def test_numbered_toctree_with_numfig_secnum_depth(app, status, warning):
|
||||
'^Fig.1.1.2 should be Fig.1.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.1.2.1 should be Fig.1.4$', True),
|
||||
(".//table/caption", '^Table 1.1 should be Table 1.1$', True),
|
||||
(".//table/caption", '^Table 1.1.1 should be Table 1.2$', True),
|
||||
(".//table/caption", '^Table 1.1.2 should be Table 1.3$', True),
|
||||
(".//table/caption", '^Table 1.2.1 should be Table 1.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.1 should be List 1.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.1.1 should be List 1.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.1.2 should be List 1.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 1.2.1 should be List 1.4$', True),
|
||||
],
|
||||
'bar.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@@ -612,10 +750,22 @@ def test_numbered_toctree_with_numfig_secnum_depth(app, status, warning):
|
||||
'^Fig.2.1.3 should be Fig.2.3$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.2.2.1 should be Fig.2.4$', True),
|
||||
(".//table/caption", '^Table 2.1.1 should be Table 2.1$', True),
|
||||
(".//table/caption", '^Table 2.1.3 should be Table 2.3$', True),
|
||||
(".//table/caption", '^Table 2.2.1 should be Table 2.4$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.1.1 should be List 2.1$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.1.3 should be List 2.3$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.2.1 should be List 2.4$', True),
|
||||
],
|
||||
'baz.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^Fig.2.1.2 should be Fig.2.2$', True),
|
||||
(".//table/caption", '^Table 2.1.2 should be Table 2.2$', True),
|
||||
(".//div[@class='code-block-caption']",
|
||||
'^List 2.1.2 should be List 2.2$', True),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user