mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
all: provide docutils version in sphinx.util.compat
This commit is contained in:
+7
-12
@@ -39,19 +39,8 @@ if '+' in __version__ or 'pre' in __version__:
|
||||
def main(argv=sys.argv):
|
||||
"""Sphinx build "main" command-line entry."""
|
||||
if sys.version_info[:3] < (2, 5, 0):
|
||||
sys.stderr.write('Error: Sphinx requires at least '
|
||||
'Python 2.5 to run.\n')
|
||||
sys.stderr.write('Error: Sphinx requires at least Python 2.5 to run.\n')
|
||||
return 1
|
||||
if sys.version_info[:3] >= (3, 3, 0):
|
||||
try:
|
||||
import docutils
|
||||
x, y = docutils.__version__.split('.')[:2]
|
||||
if (int(x), int(y)) < (0, 10):
|
||||
sys.stderr.write('Error: Sphinx requires at least '
|
||||
'Docutils 0.10 for Python 3.3 and above.\n')
|
||||
return 1
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
from sphinx import cmdline
|
||||
except ImportError:
|
||||
@@ -78,6 +67,12 @@ def main(argv=sys.argv):
|
||||
sys.stderr.write(hint)
|
||||
return 1
|
||||
raise
|
||||
if sys.version_info[:3] >= (3, 3, 0):
|
||||
from sphinx.util.compat import docutils_version
|
||||
if docutils_version < (0, 10):
|
||||
sys.stderr.write('Error: Sphinx requires at least '
|
||||
'Docutils 0.10 for Python 3.3 and above.\n')
|
||||
return 1
|
||||
return cmdline.main(argv)
|
||||
|
||||
|
||||
|
||||
+4
-10
@@ -22,6 +22,7 @@ from sphinx.locale import _, init as init_locale
|
||||
from sphinx.util import split_index_msg
|
||||
from sphinx.util.nodes import traverse_translatable_index, extract_messages
|
||||
from sphinx.util.osutil import ustrftime, find_catalog
|
||||
from sphinx.util.compat import docutils_version
|
||||
from sphinx.util.pycompat import all
|
||||
|
||||
|
||||
@@ -131,21 +132,14 @@ class CustomLocaleReporter(object):
|
||||
"""
|
||||
Replacer for document.reporter.get_source_and_line method.
|
||||
|
||||
reST text lines for translation not have original source line number.
|
||||
This class provide correct line number at reporting.
|
||||
reST text lines for translation do not have the original source line number.
|
||||
This class provides the correct line numbers when reporting.
|
||||
"""
|
||||
def __init__(self, source, line):
|
||||
self.source, self.line = source, line
|
||||
|
||||
try:
|
||||
from docutils import __version__ as du_version
|
||||
v = tuple([int(x) for x in du_version.split('.')[:2]])
|
||||
except ImportError:
|
||||
v = (99, 99)
|
||||
self.du_version = v
|
||||
|
||||
def set_reporter(self, document):
|
||||
if self.du_version < (0, 9):
|
||||
if docutils_version < (0, 9):
|
||||
document.reporter.locator = self.get_source_and_line
|
||||
else:
|
||||
document.reporter.get_source_and_line = self.get_source_and_line
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
from docutils import nodes
|
||||
|
||||
from docutils import __version__ as _du_version
|
||||
docutils_version = tuple(int(x) for x in _du_version.split('.')[:2])
|
||||
|
||||
def make_admonition(node_class, name, arguments, options, content, lineno,
|
||||
content_offset, block_text, state, state_machine):
|
||||
#if not content:
|
||||
|
||||
Reference in New Issue
Block a user