summaryrefslogtreecommitdiff
path: root/numpydoc/__init__.py
blob: 31cc4249c1d6bf9df431f71d6cf3f5969ee39b75 (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
"""
This package provides the numpydoc Sphinx extension for handling docstrings
formatted according to the NumPy documentation format.
"""
from ._version import __version__


def _verify_sphinx_jinja():
    """Ensure sphinx and jinja versions are compatible.

    Jinja2>=3.1 requires Sphinx>=4.0.2. Raises exception if this condition is
    not met.

    TODO: This check can be removed when the minimum supported sphinx version
    for numpydoc sphinx>=4.0.2
    """
    import sphinx, jinja2
    from packaging import version

    if version.parse(sphinx.__version__) <= version.parse("4.0.2"):
        if version.parse(jinja2.__version__) >= version.parse("3.1"):
            from sphinx.errors import VersionRequirementError

            raise VersionRequirementError(
                "\n\nSphinx<4.0.2 is incompatible with Jinja2>=3.1.\n"
                "If you wish to continue using sphinx<4.0.2 you need to pin "
                "Jinja2<3.1."
            )


_verify_sphinx_jinja()


def setup(app, *args, **kwargs):
    from .numpydoc import setup

    return setup(app, *args, **kwargs)