summaryrefslogtreecommitdiff
path: root/docs/_utils.py
blob: fea47a4191ba7b2683729ec1e478938e9076938b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import tempfile

from sphinx.application import Sphinx


def find_sphinx_sources(srcdir):
    # Use a minimal Sphinx app to locate source files per conf.py.
    with tempfile.TemporaryDirectory() as tmpdir:
        app = Sphinx(
            srcdir=srcdir,
            confdir=srcdir,
            outdir=tmpdir,
            doctreedir=tmpdir,
            buildername="dummy",
            # Disable extensions: none of them affect source discovery, and
            # loading them would download intersphinx inventories.
            confoverrides={"extensions": []},
            status=None,
        )
        return [
            str(app.project.doc2path(docname, absolute=True))
            for docname in app.project.docnames
        ]