mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Separate numfig testcase from toctree's
This commit is contained in:
parent
c35886f6d0
commit
0c5b460dc6
58
tests/roots/test-numfig/bar.rst
Normal file
58
tests/roots/test-numfig/bar.rst
Normal file
@ -0,0 +1,58 @@
|
||||
===
|
||||
Bar
|
||||
===
|
||||
|
||||
Bar A
|
||||
=====
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
=====
|
||||
|
||||
Bar B1
|
||||
------
|
||||
|
||||
.. 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')
|
16
tests/roots/test-numfig/baz.rst
Normal file
16
tests/roots/test-numfig/baz.rst
Normal file
@ -0,0 +1,16 @@
|
||||
Baz A
|
||||
-----
|
||||
|
||||
.. 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')
|
3
tests/roots/test-numfig/conf.py
Normal file
3
tests/roots/test-numfig/conf.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
71
tests/roots/test-numfig/foo.rst
Normal file
71
tests/roots/test-numfig/foo.rst
Normal file
@ -0,0 +1,71 @@
|
||||
===
|
||||
Foo
|
||||
===
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
=====
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.1.2
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
------
|
||||
|
||||
Foo B
|
||||
=====
|
||||
|
||||
Foo B1
|
||||
------
|
||||
|
||||
.. 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')
|
36
tests/roots/test-numfig/index.rst
Normal file
36
tests/roots/test-numfig/index.rst
Normal file
@ -0,0 +1,36 @@
|
||||
test-tocdepth
|
||||
=============
|
||||
|
||||
.. toctree::
|
||||
:numbered:
|
||||
|
||||
foo
|
||||
bar
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.1
|
||||
|
||||
.. 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')
|
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 218 B |
@ -11,38 +11,10 @@ Bar A
|
||||
|
||||
should be 2.1
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
=====
|
||||
|
||||
@ -53,16 +25,3 @@ Bar B1
|
||||
|
||||
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')
|
||||
|
@ -3,16 +3,3 @@ Baz A
|
||||
|
||||
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')
|
||||
|
@ -4,53 +4,11 @@ Foo
|
||||
|
||||
should be 1
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
=====
|
||||
|
||||
should be 1.1
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.1.2
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
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
|
||||
------
|
||||
|
||||
@ -66,16 +24,3 @@ Foo B1
|
||||
|
||||
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')
|
||||
|
@ -6,31 +6,3 @@ test-tocdepth
|
||||
|
||||
foo
|
||||
bar
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
should be Fig.1
|
||||
|
||||
.. 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')
|
||||
|
@ -380,6 +380,90 @@ def test_tocdepth(app, status, warning):
|
||||
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True),
|
||||
(".//li[@class='toctree-l3']/a", '2.1.1. Bar A1', False),
|
||||
(".//li[@class='toctree-l3']/a", '2.2.1. Bar B1', False),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//h1", '1. Foo', True),
|
||||
(".//h2", '1.1. Foo A', True),
|
||||
(".//h3", '1.1.1. Foo A1', True),
|
||||
(".//h2", '1.2. Foo B', True),
|
||||
(".//h3", '1.2.1. Foo B1', True),
|
||||
],
|
||||
'bar.html': [
|
||||
(".//h1", '2. Bar', True),
|
||||
(".//h2", '2.1. Bar A', True),
|
||||
(".//h2", '2.2. Bar B', True),
|
||||
(".//h3", '2.2.1. Bar B1', True),
|
||||
],
|
||||
'baz.html': [
|
||||
(".//h1", '2.1.1. Baz A', True),
|
||||
],
|
||||
}
|
||||
|
||||
for fname, paths in iteritems(expects):
|
||||
parser = NslessParser()
|
||||
parser.entity.update(html_entities.entitydefs)
|
||||
fp = open(os.path.join(app.outdir, fname), 'rb')
|
||||
try:
|
||||
etree = ET.parse(fp, parser)
|
||||
finally:
|
||||
fp.close()
|
||||
|
||||
for xpath, check, be_found in paths:
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@gen_with_app(buildername='singlehtml', testroot='tocdepth')
|
||||
def test_tocdepth_singlehtml(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
'index.html': [
|
||||
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True),
|
||||
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True),
|
||||
(".//li[@class='toctree-l3']/a", '2.1.1. Bar A1', False),
|
||||
(".//li[@class='toctree-l3']/a", '2.2.1. Bar B1', False),
|
||||
|
||||
# index.rst
|
||||
(".//h1", 'test-tocdepth', True),
|
||||
|
||||
# foo.rst
|
||||
(".//h2", '1. Foo', True),
|
||||
(".//h3", '1.1. Foo A', True),
|
||||
(".//h4", '1.1.1. Foo A1', True),
|
||||
(".//h3", '1.2. Foo B', True),
|
||||
(".//h4", '1.2.1. Foo B1', True),
|
||||
|
||||
# bar.rst
|
||||
(".//h2", '2. Bar', True),
|
||||
(".//h3", '2.1. Bar A', True),
|
||||
(".//h3", '2.2. Bar B', True),
|
||||
(".//h4", '2.2.1. Bar B1', True),
|
||||
|
||||
# baz.rst
|
||||
(".//h4", '2.1.1. Baz A', True),
|
||||
],
|
||||
}
|
||||
|
||||
for fname, paths in iteritems(expects):
|
||||
parser = NslessParser()
|
||||
parser.entity.update(html_entities.entitydefs)
|
||||
fp = open(os.path.join(app.outdir, fname), 'rb')
|
||||
try:
|
||||
etree = ET.parse(fp, parser)
|
||||
finally:
|
||||
fp.close()
|
||||
|
||||
for xpath, check, be_found in paths:
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@gen_with_app(buildername='html', testroot='numfig')
|
||||
def test_numfig(app, status, warning):
|
||||
# issue #1251
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
'index.html': [
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^should be Fig.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@ -392,11 +476,6 @@ def test_tocdepth(app, status, warning):
|
||||
'^should be List 2$', True),
|
||||
],
|
||||
'foo.html': [
|
||||
(".//h1", '1. Foo', True),
|
||||
(".//h2", '1.1. Foo A', True),
|
||||
(".//h3", '1.1.1. Foo A1', True),
|
||||
(".//h2", '1.2. Foo B', True),
|
||||
(".//h3", '1.2.1. Foo B1', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^should be Fig.1.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@ -419,10 +498,6 @@ def test_tocdepth(app, status, warning):
|
||||
'^should be List 1.4$', True),
|
||||
],
|
||||
'bar.html': [
|
||||
(".//h1", '2. Bar', True),
|
||||
(".//h2", '2.1. Bar A', True),
|
||||
(".//h2", '2.2. Bar B', True),
|
||||
(".//h3", '2.2.1. Bar B1', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
'^should be Fig.2.1$', True),
|
||||
(".//div[@class='figure']/p[@class='caption']",
|
||||
@ -440,7 +515,6 @@ def test_tocdepth(app, status, warning):
|
||||
'^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),
|
||||
@ -462,9 +536,9 @@ def test_tocdepth(app, status, warning):
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@gen_with_app(buildername='html', testroot='tocdepth',
|
||||
@gen_with_app(buildername='html', testroot='numfig',
|
||||
confoverrides={'numfig': True})
|
||||
def test_unnumbered_toctree_with_numfig(app, status, warning):
|
||||
def test_numfig_without_numbered_toctree(app, status, warning):
|
||||
# remove :numbered: option
|
||||
index = (app.srcdir / 'index.rst').text()
|
||||
index = re.sub(':numbered:.*', '', index, re.MULTILINE)
|
||||
@ -545,9 +619,9 @@ def test_unnumbered_toctree_with_numfig(app, status, warning):
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@gen_with_app(buildername='html', testroot='tocdepth',
|
||||
@gen_with_app(buildername='html', testroot='numfig',
|
||||
confoverrides={'numfig': True})
|
||||
def test_numbered_toctree_with_numfig(app, status, warning):
|
||||
def test_numfig_with_numbered_toctree(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
@ -624,9 +698,9 @@ def test_numbered_toctree_with_numfig(app, status, warning):
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@gen_with_app(buildername='html', testroot='tocdepth',
|
||||
@gen_with_app(buildername='html', testroot='numfig',
|
||||
confoverrides={'numfig': True, 'numfig_prefix': {'figure': 'Figure:', 'table': 'Tab_', 'code-block': 'Code-'}})
|
||||
def test_numbered_toctree_with_numfig_prefix(app, status, warning):
|
||||
def test_numfig_with_prefix(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
@ -703,9 +777,9 @@ def test_numbered_toctree_with_numfig_prefix(app, status, warning):
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@gen_with_app(buildername='html', testroot='tocdepth',
|
||||
@gen_with_app(buildername='html', testroot='numfig',
|
||||
confoverrides={'numfig': True, 'numfig_secnum_depth': 2})
|
||||
def test_numbered_toctree_with_numfig_secnum_depth(app, status, warning):
|
||||
def test_numfig_with_secnum_depth(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
@ -780,48 +854,3 @@ def test_numbered_toctree_with_numfig_secnum_depth(app, status, warning):
|
||||
|
||||
for xpath, check, be_found in paths:
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
|
||||
@gen_with_app(buildername='singlehtml', testroot='tocdepth')
|
||||
def test_tocdepth_singlehtml(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
'index.html': [
|
||||
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True),
|
||||
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True),
|
||||
(".//li[@class='toctree-l3']/a", '2.1.1. Bar A1', False),
|
||||
(".//li[@class='toctree-l3']/a", '2.2.1. Bar B1', False),
|
||||
|
||||
# index.rst
|
||||
(".//h1", 'test-tocdepth', True),
|
||||
|
||||
# foo.rst
|
||||
(".//h2", '1. Foo', True),
|
||||
(".//h3", '1.1. Foo A', True),
|
||||
(".//h4", '1.1.1. Foo A1', True),
|
||||
(".//h3", '1.2. Foo B', True),
|
||||
(".//h4", '1.2.1. Foo B1', True),
|
||||
|
||||
# bar.rst
|
||||
(".//h2", '2. Bar', True),
|
||||
(".//h3", '2.1. Bar A', True),
|
||||
(".//h3", '2.2. Bar B', True),
|
||||
(".//h4", '2.2.1. Bar B1', True),
|
||||
|
||||
# baz.rst
|
||||
(".//h4", '2.1.1. Baz A', True),
|
||||
],
|
||||
}
|
||||
|
||||
for fname, paths in iteritems(expects):
|
||||
parser = NslessParser()
|
||||
parser.entity.update(html_entities.entitydefs)
|
||||
fp = open(os.path.join(app.outdir, fname), 'rb')
|
||||
try:
|
||||
etree = ET.parse(fp, parser)
|
||||
finally:
|
||||
fp.close()
|
||||
|
||||
for xpath, check, be_found in paths:
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
Loading…
Reference in New Issue
Block a user