Refactor: split .rst file for text-latex-table

This commit is contained in:
Takeshi KOMIYA
2017-02-07 23:43:56 +09:00
parent 4cece2dd27
commit 82e011cae6
4 changed files with 247 additions and 238 deletions

View File

@@ -1,238 +1,7 @@
test-latex-table
================
simple table
------------
.. toctree::
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
grid table
----------
+---------+---------+---------+
| header1 | header2 | header3 |
+=========+=========+=========+
| cell1-1 | cell1-2 | cell1-3 |
+---------+ +---------+
| cell2-1 | | cell2-2 |
+ +---------+---------+
| | cell3-2 |
+---------+ |
| cell4-1 | |
+---------+---------+---------+
| cell5-1 |
+---------+---------+---------+
table having :widths: option
----------------------------
.. table::
:widths: 30,70
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
table with tabularcolumn
------------------------
.. tabularcolumns:: |c|c|
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
table having caption
--------------------
.. list-table:: caption for table
:header-rows: 1
* - header1
- header2
* - cell1-1
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
table having verbatim
---------------------
.. list-table::
:header-rows: 1
* - header1
- header2
* - ::
hello world
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
table having both :widths: and problematic cell
-----------------------------------------------
.. list-table::
:header-rows: 1
:widths: 30,70
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
table having problematic cell
-----------------------------
.. list-table::
:header-rows: 1
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
longtable
---------
.. table::
:class: longtable
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
longtable having :widths: option
--------------------------------
.. table::
:class: longtable
:widths: 30,70
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
longtable with tabularcolumn
----------------------------
.. tabularcolumns:: |c|c|
.. table::
:class: longtable
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
longtable having caption
------------------------
.. list-table:: caption for longtable
:class: longtable
:header-rows: 1
* - header1
- header2
* - cell1-1
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
longtable having verbatim
-------------------------
.. list-table::
:class: longtable
:header-rows: 1
* - header1
- header2
* - ::
hello world
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
longtable having both :widths: and problematic cell
---------------------------------------------------
.. list-table::
:class: longtable
:header-rows: 1
:widths: 30,70
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
longtable having problematic cell
---------------------------------
.. list-table::
:class: longtable
:header-rows: 1
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
tabular
longtable

View File

@@ -0,0 +1,117 @@
longtables
==========
longtable
---------
.. table::
:class: longtable
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
longtable having :widths: option
--------------------------------
.. table::
:class: longtable
:widths: 30,70
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
longtable with tabularcolumn
----------------------------
.. tabularcolumns:: |c|c|
.. table::
:class: longtable
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
longtable having caption
------------------------
.. list-table:: caption for longtable
:class: longtable
:header-rows: 1
* - header1
- header2
* - cell1-1
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
longtable having verbatim
-------------------------
.. list-table::
:class: longtable
:header-rows: 1
* - header1
- header2
* - ::
hello world
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
longtable having both :widths: and problematic cell
---------------------------------------------------
.. list-table::
:class: longtable
:header-rows: 1
:widths: 30,70
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
longtable having problematic cell
---------------------------------
.. list-table::
:class: longtable
:header-rows: 1
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2

View File

@@ -0,0 +1,123 @@
taburar and taburary
====================
simple table
------------
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
grid table
----------
+---------+---------+---------+
| header1 | header2 | header3 |
+=========+=========+=========+
| cell1-1 | cell1-2 | cell1-3 |
+---------+ +---------+
| cell2-1 | | cell2-2 |
+ +---------+---------+
| | cell3-2 |
+---------+ |
| cell4-1 | |
+---------+---------+---------+
| cell5-1 |
+---------+---------+---------+
table having :widths: option
----------------------------
.. table::
:widths: 30,70
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
table with tabularcolumn
------------------------
.. tabularcolumns:: |c|c|
======= =======
header1 header2
======= =======
cell1-1 cell1-2
cell2-1 cell2-2
cell3-1 cell3-2
======= =======
table having caption
--------------------
.. list-table:: caption for table
:header-rows: 1
* - header1
- header2
* - cell1-1
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
table having verbatim
---------------------
.. list-table::
:header-rows: 1
* - header1
- header2
* - ::
hello world
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
table having both :widths: and problematic cell
-----------------------------------------------
.. list-table::
:header-rows: 1
:widths: 30,70
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2
table having problematic cell
-----------------------------
.. list-table::
:header-rows: 1
* - header1
- header2
* - + item1
+ item2
- cell1-2
* - cell2-1
- cell2-2
* - cell3-1
- cell3-2

View File

@@ -824,9 +824,9 @@ def test_latex_table(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
tables = {}
for chap in re.split(r'\\chapter(?={.*})', result)[1:]:
for chap in re.split(r'\\section{', result)[1:]:
sectname, content = chap.split('}', 1)
tables[sectname[1:]] = content.strip()
tables[sectname] = content.strip()
# simple_table
table = tables['simple table']
@@ -874,7 +874,7 @@ def test_latex_table(app, status, warning):
# table having caption
table = tables['table having caption']
assert ('\\begin{threeparttable}\n\\capstart\\caption{caption for table}'
'\\label{\\detokenize{index:id1}}' in table)
'\\label{\\detokenize{tabular:id1}}' in table)
assert ('\\noindent\\begin{tabulary}{\\linewidth}{|L|L|}' in table)
assert ('\\hline\n'
'\\sphinxstylethead{\\relax \nheader1\n\\unskip}\\relax &'
@@ -929,7 +929,7 @@ def test_latex_table(app, status, warning):
# longtable having caption
table = tables['longtable having caption']
assert ('\\begin{longtable}{|l|l|}\n\\caption{caption for longtable}'
'\\label{\\detokenize{index:id2}}\\\\\n\\hline' in table)
'\\label{\\detokenize{longtable:id1}}\\\\\n\\hline' in table)
# longtable having verbatim
table = tables['longtable having verbatim']