Debian Codegraph @

astropy_sphinx_theme/tests/test_basic.py

raw
1 import pytest
2 from packaging.version import Version
3 from sphinx import __version__
4
5 SPHINX_LT_17 = Version(__version__) < Version("1.7")
6
7 if SPHINX_LT_17:
8 from sphinx import build_main
9 else:
10 from sphinx.cmd.build import build_main
11
12 THEMES = ["bootstrap-astropy"]
13
14
15 BASIC_CONF = """
16 source_suffix = '.rst'
17 master_doc = 'index'
18 html_theme = '{theme}'
19 """
20
21 BASIC_INDEX = """
22 Title
23 =====
24
25 Just a test
26 """
27
28
29 @pytest.mark.parametrize("theme", THEMES)
30 def test_basic(tmpdir, theme):
31 # Just make sure the docs build with the specified theme
32 # (to make sure e.g. that no templates are missing)
33
34 with open(tmpdir.join("conf.py").strpath, "w") as f:
35 f.write(BASIC_CONF.format(theme=theme))
36
37 with open(tmpdir.join("index.rst").strpath, "w") as f:
38 f.write(BASIC_INDEX.format(theme=theme))
39
40 src_dir = tmpdir.strpath
41 html_dir = tmpdir.mkdir("html").strpath
42
43 if SPHINX_LT_17:
44 status = build_main(argv=["sphinx-build", "-W", "-b", "html", src_dir, html_dir])
45 else:
46 # As of Sphinx 1.7, the first argument is now no longer ignored
47 status = build_main(argv=["-W", "-b", "html", src_dir, html_dir])
48
49 assert status == 0