|
2 | 2 |
|
3 | 3 | import pytest
|
4 | 4 | from docutils import nodes
|
5 |
| -from docutils.nodes import bullet_list, comment, list_item, reference, title |
| 5 | +from docutils.nodes import bullet_list, comment, list_item, literal, reference, title |
6 | 6 |
|
7 | 7 | from sphinx import addnodes
|
8 | 8 | from sphinx.addnodes import compact_paragraph, only
|
@@ -126,6 +126,46 @@ def test_glob(app):
|
126 | 126 | assert app.env.numbered_toctrees == set()
|
127 | 127 |
|
128 | 128 |
|
| 129 | +@pytest.mark.sphinx('dummy', testroot='toctree-domain-objects') |
| 130 | +def test_domain_objects(app): |
| 131 | + includefiles = ['domains'] |
| 132 | + |
| 133 | + app.build() |
| 134 | + |
| 135 | + assert app.env.toc_num_entries['index'] == 0 |
| 136 | + assert app.env.toc_num_entries['domains'] == 9 |
| 137 | + assert app.env.toctree_includes['index'] == includefiles |
| 138 | + for file in includefiles: |
| 139 | + assert 'index' in app.env.files_to_rebuild[file] |
| 140 | + assert app.env.glob_toctrees == set() |
| 141 | + assert app.env.numbered_toctrees == {'index'} |
| 142 | + |
| 143 | + # tocs |
| 144 | + toctree = app.env.tocs['domains'] |
| 145 | + print(toctree[0][1][1][1][0]) |
| 146 | + assert_node(toctree, |
| 147 | + [bullet_list, list_item, (compact_paragraph, # [0][0] |
| 148 | + [bullet_list, (list_item, # [0][1][0] |
| 149 | + [list_item, # [0][1][1] |
| 150 | + (compact_paragraph, # [0][1][1][0] |
| 151 | + [bullet_list, (list_item, # [0][1][1][1][0] |
| 152 | + list_item, |
| 153 | + list_item, |
| 154 | + list_item)])], # [0][1][1][1][3] |
| 155 | + list_item, |
| 156 | + list_item)])]) # [0][1][1] |
| 157 | + |
| 158 | + assert_node(toctree[0][0], |
| 159 | + [compact_paragraph, reference, "test-domain-objects"]) |
| 160 | + |
| 161 | + assert_node(toctree[0][1][0], |
| 162 | + [list_item, ([compact_paragraph, reference, literal, "hello.world()"])]) |
| 163 | + |
| 164 | + print(toctree[0][1][1][1][3]) |
| 165 | + assert_node(toctree[0][1][1][1][3], |
| 166 | + [list_item, ([compact_paragraph, reference, literal, "hello.HelloWorldPrinter.print()"])]) |
| 167 | + |
| 168 | + |
129 | 169 | @pytest.mark.sphinx('xml', testroot='toctree')
|
130 | 170 | @pytest.mark.test_params(shared_result='test_environment_toctree_basic')
|
131 | 171 | def test_get_toc_for(app):
|
|
0 commit comments