summaryrefslogtreecommitdiff
path: root/tests/test_apidoc.py
blob: 3bc16f5c15014a4f71bd4a4b2cd109f5f1d1d679 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""
    test_apidoc
    ~~~~~~~~~~~

    Test the sphinx.apidoc module.

    :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

from __future__ import print_function

import sys

from sphinx import apidoc

from util import with_tempdir, with_app, rootdir


@with_tempdir
def test_simple(tempdir):
    codedir = rootdir / 'root'
    outdir = tempdir / 'out'
    args = ['sphinx-apidoc', '-o', outdir, '-F', codedir]
    apidoc.main(args)

    assert (outdir / 'conf.py').isfile()
    assert (outdir / 'autodoc_fodder.rst').isfile()
    assert (outdir / 'index.rst').isfile()

    @with_app('text', srcdir=outdir)
    def assert_build(app, status, warning):
        app.build()
        print(status.getvalue())
        print(warning.getvalue())

    sys.path.append(codedir)
    try:
        assert_build()
    finally:
        sys.path.remove(codedir)