2007-07-23 04:02:25 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Sphinx
|
|
|
|
~~~~~~
|
|
|
|
|
2008-01-16 14:27:25 -06:00
|
|
|
The Sphinx documentation toolchain.
|
2007-07-23 04:02:25 -05:00
|
|
|
|
2017-12-31 10:06:58 -06:00
|
|
|
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
2008-12-27 05:19:17 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
2007-07-23 04:02:25 -05:00
|
|
|
"""
|
|
|
|
|
2010-07-28 12:58:17 -05:00
|
|
|
# Keep this file executable as-is in Python 3!
|
|
|
|
# (Otherwise getting the version out of it from setup.py is impossible.)
|
|
|
|
|
2016-12-04 02:52:45 -06:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import os
|
|
|
|
import warnings
|
2008-11-29 12:56:58 -06:00
|
|
|
from os import path
|
2007-07-23 04:02:25 -05:00
|
|
|
|
2017-09-21 04:28:44 -05:00
|
|
|
from .cmd import build
|
2016-12-04 02:52:45 -06:00
|
|
|
from .deprecation import RemovedInNextVersionWarning
|
2017-09-21 04:28:44 -05:00
|
|
|
from .deprecation import RemovedInSphinx20Warning
|
2017-03-02 21:19:09 -06:00
|
|
|
|
2016-12-04 02:52:45 -06:00
|
|
|
# by default, all DeprecationWarning under sphinx package will be emit.
|
|
|
|
# Users can avoid this by using environment variable: PYTHONWARNINGS=
|
|
|
|
if 'PYTHONWARNINGS' not in os.environ:
|
|
|
|
warnings.filterwarnings('default',
|
|
|
|
category=RemovedInNextVersionWarning, module='sphinx')
|
|
|
|
# docutils.io using mode='rU' for open
|
|
|
|
warnings.filterwarnings('ignore', "'U' mode is deprecated",
|
|
|
|
DeprecationWarning, module='docutils.io')
|
|
|
|
|
2018-01-20 04:48:11 -06:00
|
|
|
__version__ = '1.8.0+'
|
|
|
|
__released__ = '1.8.0' # used when Sphinx builds its own docs
|
2015-03-14 02:46:24 -05:00
|
|
|
|
2017-10-22 08:59:09 -05:00
|
|
|
#: Version info for better programmatic use.
|
|
|
|
#:
|
|
|
|
#: A tuple of five elements; for Sphinx version 1.2.1 beta 3 this would be
|
|
|
|
#: ``(1, 2, 1, 'beta', 3)``. The fourth element can be one of: ``alpha``,
|
|
|
|
#: ``beta``, ``rc``, ``final``. ``final`` always has 0 as the last element.
|
|
|
|
#:
|
|
|
|
#: .. versionadded:: 1.2
|
|
|
|
#: Before version 1.2, check the string ``sphinx.__version__``.
|
2018-01-20 04:48:11 -06:00
|
|
|
version_info = (1, 8, 0, 'beta', 0)
|
2008-01-21 14:20:37 -06:00
|
|
|
|
2008-11-29 12:56:58 -06:00
|
|
|
package_dir = path.abspath(path.dirname(__file__))
|
|
|
|
|
2015-03-14 02:46:24 -05:00
|
|
|
__display_version__ = __version__ # used for command line version
|
|
|
|
if __version__.endswith('+'):
|
2016-12-27 15:01:48 -06:00
|
|
|
# try to find out the commit hash if checked out from git, and append
|
2009-08-04 16:29:05 -05:00
|
|
|
# it to __version__ (since we use this value from setup.py, it gets
|
|
|
|
# automatically propagated to an installed copy as well)
|
2015-03-14 02:46:24 -05:00
|
|
|
__display_version__ = __version__
|
|
|
|
__version__ = __version__[:-1] # remove '+' for PEP-440 version spec.
|
2009-08-04 16:29:05 -05:00
|
|
|
try:
|
|
|
|
import subprocess
|
2015-02-24 09:17:41 -06:00
|
|
|
p = subprocess.Popen(['git', 'show', '-s', '--pretty=format:%h',
|
2009-08-04 16:29:05 -05:00
|
|
|
path.join(package_dir, '..')],
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
out, err = p.communicate()
|
|
|
|
if out:
|
2017-05-07 00:09:54 -05:00
|
|
|
__display_version__ += '/' + out.decode().strip()
|
2009-08-04 16:29:05 -05:00
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
2008-01-21 14:20:37 -06:00
|
|
|
|
2017-09-21 04:28:44 -05:00
|
|
|
def main(*args, **kwargs):
|
|
|
|
warnings.warn(
|
|
|
|
'`sphinx.main()` has moved to `sphinx.cmd.build.main()`.',
|
|
|
|
RemovedInSphinx20Warning,
|
|
|
|
stacklevel=2,
|
|
|
|
)
|
2017-10-17 07:15:00 -05:00
|
|
|
return build.main(*args, **kwargs)
|
2014-01-11 12:36:05 -06:00
|
|
|
|
|
|
|
|
2007-07-23 04:02:25 -05:00
|
|
|
if __name__ == '__main__':
|
2017-09-21 04:28:44 -05:00
|
|
|
warnings.warn(
|
|
|
|
'`sphinx` has moved to `sphinx.build`.',
|
|
|
|
RemovedInSphinx20Warning,
|
|
|
|
stacklevel=2,
|
|
|
|
)
|
|
|
|
build.main()
|