mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'stable'
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -22,6 +22,7 @@ Bugs fixed
|
|||||||
|
|
||||||
* #1769: allows generating quickstart files/dirs for destination dir that
|
* #1769: allows generating quickstart files/dirs for destination dir that
|
||||||
doesn't overwrite existent files/dirs. Thanks to WAKAYAMA shirou.
|
doesn't overwrite existent files/dirs. Thanks to WAKAYAMA shirou.
|
||||||
|
* #1773: sphinx-quickstart doesn't accept non-ASCII character as a option argument.
|
||||||
|
|
||||||
|
|
||||||
Release 1.3 (released Mar 10, 2015)
|
Release 1.3 (released Mar 10, 2015)
|
||||||
|
|||||||
25
README.rst
25
README.rst
@@ -8,10 +8,29 @@ This is the Sphinx documentation generator, see http://sphinx-doc.org/.
|
|||||||
Installing
|
Installing
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Use ``setup.py``::
|
Install from PyPI to use stable version::
|
||||||
|
|
||||||
python setup.py build
|
pip install -U sphinx
|
||||||
sudo python setup.py install
|
|
||||||
|
Install from PyPI to use beta version::
|
||||||
|
|
||||||
|
pip install -U --pre sphinx
|
||||||
|
|
||||||
|
Install from newest dev version in stable branch::
|
||||||
|
|
||||||
|
pip install git+https://github.com/sphinx-doc/sphinx@stable
|
||||||
|
|
||||||
|
Install from newest dev version in master branch::
|
||||||
|
|
||||||
|
pip install git+https://github.com/sphinx-doc/sphinx
|
||||||
|
|
||||||
|
Install from cloned source::
|
||||||
|
|
||||||
|
pip install .
|
||||||
|
|
||||||
|
Install from cloned source as editable::
|
||||||
|
|
||||||
|
pip install -e .
|
||||||
|
|
||||||
|
|
||||||
Reading the docs
|
Reading the docs
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[egg_info]
|
[egg_info]
|
||||||
tag_build = dev
|
tag_build = .dev
|
||||||
tag_date = true
|
tag_date = true
|
||||||
|
|
||||||
[aliases]
|
[aliases]
|
||||||
|
|||||||
@@ -15,19 +15,23 @@
|
|||||||
import sys
|
import sys
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
__version__ = '1.4a0+'
|
__version__ = '1.3+'
|
||||||
__released__ = '1.4a0' # used when Sphinx builds its own docs
|
__released__ = '1.3+' # used when Sphinx builds its own docs
|
||||||
|
|
||||||
# version info for better programmatic use
|
# version info for better programmatic use
|
||||||
# possible values for 3rd element: 'alpha', 'beta', 'rc', 'final'
|
# possible values for 3rd element: 'alpha', 'beta', 'rc', 'final'
|
||||||
# 'final' has 0 as the last element
|
# 'final' has 0 as the last element
|
||||||
version_info = (1, 4, 0, 'alpha', 0)
|
version_info = (1, 3, 1, 'beta', 1)
|
||||||
|
|
||||||
package_dir = path.abspath(path.dirname(__file__))
|
package_dir = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
if '+' in __version__ or 'pre' in __version__:
|
__display_version__ = __version__ # used for command line version
|
||||||
|
if __version__.endswith('+'):
|
||||||
# try to find out the changeset hash if checked out from hg, and append
|
# try to find out the changeset hash if checked out from hg, and append
|
||||||
# it to __version__ (since we use this value from setup.py, it gets
|
# it to __version__ (since we use this value from setup.py, it gets
|
||||||
# automatically propagated to an installed copy as well)
|
# automatically propagated to an installed copy as well)
|
||||||
|
__display_version__ = __version__
|
||||||
|
__version__ = __version__[:-1] # remove '+' for PEP-440 version spec.
|
||||||
try:
|
try:
|
||||||
import subprocess
|
import subprocess
|
||||||
p = subprocess.Popen(['git', 'show', '-s', '--pretty=format:%h',
|
p = subprocess.Popen(['git', 'show', '-s', '--pretty=format:%h',
|
||||||
@@ -35,7 +39,7 @@ if '+' in __version__ or 'pre' in __version__:
|
|||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
if out:
|
if out:
|
||||||
__version__ += '/' + out.decode().strip()
|
__display_version__ += '/' + out.decode().strip()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import optparse
|
|||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from sphinx.util.osutil import walk
|
from sphinx.util.osutil import walk
|
||||||
from sphinx import __version__
|
from sphinx import __display_version__
|
||||||
|
|
||||||
# automodule options
|
# automodule options
|
||||||
if 'SPHINX_APIDOC_OPTIONS' in os.environ:
|
if 'SPHINX_APIDOC_OPTIONS' in os.environ:
|
||||||
@@ -318,7 +318,7 @@ Note: By default this script will not overwrite already created files.""")
|
|||||||
(opts, args) = parser.parse_args(argv[1:])
|
(opts, args) = parser.parse_args(argv[1:])
|
||||||
|
|
||||||
if opts.show_version:
|
if opts.show_version:
|
||||||
print('Sphinx (sphinx-apidoc) %s' % __version__)
|
print('Sphinx (sphinx-apidoc) %s' % __display_version__)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class Sphinx(object):
|
|||||||
self.messagelog = deque(maxlen=10)
|
self.messagelog = deque(maxlen=10)
|
||||||
|
|
||||||
# say hello to the world
|
# say hello to the world
|
||||||
self.info(bold('Running Sphinx v%s' % sphinx.__version__))
|
self.info(bold('Running Sphinx v%s' % sphinx.__display_version__))
|
||||||
|
|
||||||
# status code for command-line application
|
# status code for command-line application
|
||||||
self.statuscode = 0
|
self.statuscode = 0
|
||||||
@@ -158,7 +158,7 @@ class Sphinx(object):
|
|||||||
|
|
||||||
# check the Sphinx version if requested
|
# check the Sphinx version if requested
|
||||||
if self.config.needs_sphinx and \
|
if self.config.needs_sphinx and \
|
||||||
self.config.needs_sphinx > sphinx.__version__[:3]:
|
self.config.needs_sphinx > sphinx.__display_version__[:3]:
|
||||||
raise VersionRequirementError(
|
raise VersionRequirementError(
|
||||||
'This project needs at least Sphinx v%s and therefore cannot '
|
'This project needs at least Sphinx v%s and therefore cannot '
|
||||||
'be built with this version.' % self.config.needs_sphinx)
|
'be built with this version.' % self.config.needs_sphinx)
|
||||||
@@ -453,7 +453,7 @@ class Sphinx(object):
|
|||||||
|
|
||||||
def require_sphinx(self, version):
|
def require_sphinx(self, version):
|
||||||
# check the Sphinx version if requested
|
# check the Sphinx version if requested
|
||||||
if version > sphinx.__version__[:3]:
|
if version > sphinx.__display_version__[:3]:
|
||||||
raise VersionRequirementError(version)
|
raise VersionRequirementError(version)
|
||||||
|
|
||||||
def import_object(self, objname, source=None):
|
def import_object(self, objname, source=None):
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from docutils.utils import new_document
|
|||||||
from docutils.frontend import OptionParser
|
from docutils.frontend import OptionParser
|
||||||
from docutils.readers.doctree import Reader as DoctreeReader
|
from docutils.readers.doctree import Reader as DoctreeReader
|
||||||
|
|
||||||
from sphinx import package_dir, __version__
|
from sphinx import package_dir, __display_version__
|
||||||
from sphinx.util import jsonimpl, copy_static_entry
|
from sphinx.util import jsonimpl, copy_static_entry
|
||||||
from sphinx.util.osutil import SEP, os_path, relative_uri, ensuredir, \
|
from sphinx.util.osutil import SEP, os_path, relative_uri, ensuredir, \
|
||||||
movefile, ustrftime, copyfile
|
movefile, ustrftime, copyfile
|
||||||
@@ -343,7 +343,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
script_files = self.script_files,
|
script_files = self.script_files,
|
||||||
language = self.config.language,
|
language = self.config.language,
|
||||||
css_files = self.css_files,
|
css_files = self.css_files,
|
||||||
sphinx_version = __version__,
|
sphinx_version = __display_version__,
|
||||||
style = stylename,
|
style = stylename,
|
||||||
rellinks = rellinks,
|
rellinks = rellinks,
|
||||||
builder = self.name,
|
builder = self.name,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from os import path
|
|||||||
from six import text_type, binary_type
|
from six import text_type, binary_type
|
||||||
from docutils.utils import SystemMessage
|
from docutils.utils import SystemMessage
|
||||||
|
|
||||||
from sphinx import __version__
|
from sphinx import __display_version__
|
||||||
from sphinx.errors import SphinxError
|
from sphinx.errors import SphinxError
|
||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
|
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
|
||||||
@@ -40,7 +40,7 @@ Filename arguments:
|
|||||||
without -a and without filenames, write new and changed files.
|
without -a and without filenames, write new and changed files.
|
||||||
with -a, write all files.
|
with -a, write all files.
|
||||||
with filenames, write these.
|
with filenames, write these.
|
||||||
""" % __version__
|
""" % __display_version__
|
||||||
|
|
||||||
EPILOG = """\
|
EPILOG = """\
|
||||||
For more information, visit <http://sphinx-doc.org/>.
|
For more information, visit <http://sphinx-doc.org/>.
|
||||||
@@ -131,7 +131,7 @@ def main(argv):
|
|||||||
|
|
||||||
# handle basic options
|
# handle basic options
|
||||||
if opts.version:
|
if opts.version:
|
||||||
print('Sphinx (sphinx-build) %s' % __version__)
|
print('Sphinx (sphinx-build) %s' % __display_version__)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# get paths (first and second positional argument)
|
# get paths (first and second positional argument)
|
||||||
|
|||||||
@@ -1525,7 +1525,7 @@ def setup(app):
|
|||||||
app.add_event('autodoc-process-signature')
|
app.add_event('autodoc-process-signature')
|
||||||
app.add_event('autodoc-skip-member')
|
app.add_event('autodoc-skip-member')
|
||||||
|
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|
||||||
|
|
||||||
class testcls:
|
class testcls:
|
||||||
|
|||||||
@@ -584,4 +584,4 @@ def setup(app):
|
|||||||
app.connect('doctree-read', process_autosummary_toc)
|
app.connect('doctree-read', process_autosummary_toc)
|
||||||
app.connect('builder-inited', process_generate_options)
|
app.connect('builder-inited', process_generate_options)
|
||||||
app.add_config_value('autosummary_generate', [], True)
|
app.add_config_value('autosummary_generate', [], True)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -266,4 +266,4 @@ def setup(app):
|
|||||||
app.add_config_value('coverage_ignore_c_items', {}, False)
|
app.add_config_value('coverage_ignore_c_items', {}, False)
|
||||||
app.add_config_value('coverage_write_headline', True, False)
|
app.add_config_value('coverage_write_headline', True, False)
|
||||||
app.add_config_value('coverage_skip_undoc_in_source', False, False)
|
app.add_config_value('coverage_skip_undoc_in_source', False, False)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -444,4 +444,4 @@ def setup(app):
|
|||||||
app.add_config_value('doctest_test_doctest_blocks', 'default', False)
|
app.add_config_value('doctest_test_doctest_blocks', 'default', False)
|
||||||
app.add_config_value('doctest_global_setup', '', False)
|
app.add_config_value('doctest_global_setup', '', False)
|
||||||
app.add_config_value('doctest_global_cleanup', '', False)
|
app.add_config_value('doctest_global_cleanup', '', False)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -61,4 +61,4 @@ def setup_link_roles(app):
|
|||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_config_value('extlinks', {}, 'env')
|
app.add_config_value('extlinks', {}, 'env')
|
||||||
app.connect('builder-inited', setup_link_roles)
|
app.connect('builder-inited', setup_link_roles)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -317,4 +317,4 @@ def setup(app):
|
|||||||
app.add_config_value('graphviz_dot', 'dot', 'html')
|
app.add_config_value('graphviz_dot', 'dot', 'html')
|
||||||
app.add_config_value('graphviz_dot_args', [], 'html')
|
app.add_config_value('graphviz_dot_args', [], 'html')
|
||||||
app.add_config_value('graphviz_output_format', 'png', 'html')
|
app.add_config_value('graphviz_output_format', 'png', 'html')
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -75,4 +75,4 @@ def setup(app):
|
|||||||
app.add_node(ifconfig)
|
app.add_node(ifconfig)
|
||||||
app.add_directive('ifconfig', IfConfig)
|
app.add_directive('ifconfig', IfConfig)
|
||||||
app.connect('doctree-resolved', process_ifconfig_nodes)
|
app.connect('doctree-resolved', process_ifconfig_nodes)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -408,4 +408,4 @@ def setup(app):
|
|||||||
app.add_config_value('inheritance_graph_attrs', {}, False),
|
app.add_config_value('inheritance_graph_attrs', {}, False),
|
||||||
app.add_config_value('inheritance_node_attrs', {}, False),
|
app.add_config_value('inheritance_node_attrs', {}, False),
|
||||||
app.add_config_value('inheritance_edge_attrs', {}, False),
|
app.add_config_value('inheritance_edge_attrs', {}, False),
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -282,4 +282,4 @@ def setup(app):
|
|||||||
app.add_config_value('intersphinx_cache_limit', 5, False)
|
app.add_config_value('intersphinx_cache_limit', 5, False)
|
||||||
app.connect('missing-reference', missing_reference)
|
app.connect('missing-reference', missing_reference)
|
||||||
app.connect('builder-inited', load_mappings)
|
app.connect('builder-inited', load_mappings)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -59,4 +59,4 @@ def setup(app):
|
|||||||
mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None))
|
mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None))
|
||||||
app.add_config_value('jsmath_path', '', False)
|
app.add_config_value('jsmath_path', '', False)
|
||||||
app.connect('builder-inited', builder_inited)
|
app.connect('builder-inited', builder_inited)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -74,4 +74,4 @@ def doctree_read(app, doctree):
|
|||||||
def setup(app):
|
def setup(app):
|
||||||
app.connect('doctree-read', doctree_read)
|
app.connect('doctree-read', doctree_read)
|
||||||
app.add_config_value('linkcode_resolve', None, '')
|
app.add_config_value('linkcode_resolve', None, '')
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -71,4 +71,4 @@ def setup(app):
|
|||||||
app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html')
|
app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html')
|
||||||
app.add_config_value('mathjax_display', [r'\[', r'\]'], 'html')
|
app.add_config_value('mathjax_display', [r'\[', r'\]'], 'html')
|
||||||
app.connect('builder-inited', builder_inited)
|
app.connect('builder-inited', builder_inited)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ def setup(app):
|
|||||||
|
|
||||||
for name, (default, rebuild) in iteritems(Config._config_values):
|
for name, (default, rebuild) in iteritems(Config._config_values):
|
||||||
app.add_config_value(name, default, rebuild)
|
app.add_config_value(name, default, rebuild)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|
||||||
|
|
||||||
def _process_docstring(app, what, name, obj, options, lines):
|
def _process_docstring(app, what, name, obj, options, lines):
|
||||||
|
|||||||
@@ -247,4 +247,4 @@ def setup(app):
|
|||||||
app.add_config_value('pngmath_latex_preamble', '', 'html')
|
app.add_config_value('pngmath_latex_preamble', '', 'html')
|
||||||
app.add_config_value('pngmath_add_tooltips', True, 'html')
|
app.add_config_value('pngmath_add_tooltips', True, 'html')
|
||||||
app.connect('build-finished', cleanup_tempdir)
|
app.connect('build-finished', cleanup_tempdir)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -188,4 +188,4 @@ def setup(app):
|
|||||||
app.connect('doctree-resolved', process_todo_nodes)
|
app.connect('doctree-resolved', process_todo_nodes)
|
||||||
app.connect('env-purge-doc', purge_todos)
|
app.connect('env-purge-doc', purge_todos)
|
||||||
app.connect('env-merge-info', merge_info)
|
app.connect('env-merge-info', merge_info)
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -217,4 +217,4 @@ def setup(app):
|
|||||||
app.connect('missing-reference', missing_reference)
|
app.connect('missing-reference', missing_reference)
|
||||||
# app.add_config_value('viewcode_include_modules', [], 'env')
|
# app.add_config_value('viewcode_include_modules', [], 'env')
|
||||||
# app.add_config_value('viewcode_exclude_modules', [], 'env')
|
# app.add_config_value('viewcode_exclude_modules', [], 'env')
|
||||||
return {'version': sphinx.__version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Make(object):
|
|||||||
shutil.rmtree(self.builddir_join(item))
|
shutil.rmtree(self.builddir_join(item))
|
||||||
|
|
||||||
def build_help(self):
|
def build_help(self):
|
||||||
print(bold("Sphinx v%s" % sphinx.__version__))
|
print(bold("Sphinx v%s" % sphinx.__display_version__))
|
||||||
print("Please use `make %s' where %s is one of" % ((blue('target'),)*2))
|
print("Please use `make %s' where %s is one of" % ((blue('target'),)*2))
|
||||||
for osname, bname, description in BUILDERS:
|
for osname, bname, description in BUILDERS:
|
||||||
if not osname or os.name == osname:
|
if not osname or os.name == osname:
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from six import PY2, PY3, text_type
|
from six import PY2, PY3, text_type, binary_type
|
||||||
from six.moves import input
|
from six.moves import input
|
||||||
from six.moves.urllib.parse import quote as urlquote
|
from six.moves.urllib.parse import quote as urlquote
|
||||||
from docutils.utils import column_width
|
from docutils.utils import column_width
|
||||||
|
|
||||||
from sphinx import __version__
|
from sphinx import __display_version__
|
||||||
from sphinx.util.osutil import make_filename
|
from sphinx.util.osutil import make_filename
|
||||||
from sphinx.util.console import purple, bold, red, turquoise, \
|
from sphinx.util.console import purple, bold, red, turquoise, \
|
||||||
nocolor, color_terminal
|
nocolor, color_terminal
|
||||||
@@ -1048,6 +1048,27 @@ def ok(x):
|
|||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
def term_decode(text):
|
||||||
|
if isinstance(text, text_type):
|
||||||
|
return text
|
||||||
|
|
||||||
|
# for Python 2.x, try to get a Unicode string out of it
|
||||||
|
if text.decode('ascii', 'replace').encode('ascii', 'replace') == text:
|
||||||
|
return text
|
||||||
|
|
||||||
|
if TERM_ENCODING:
|
||||||
|
text = text.decode(TERM_ENCODING)
|
||||||
|
else:
|
||||||
|
print(turquoise('* Note: non-ASCII characters entered '
|
||||||
|
'and terminal encoding unknown -- assuming '
|
||||||
|
'UTF-8 or Latin-1.'))
|
||||||
|
try:
|
||||||
|
text = text.decode('utf-8')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
text = text.decode('latin1')
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def do_prompt(d, key, text, default=None, validator=nonempty):
|
def do_prompt(d, key, text, default=None, validator=nonempty):
|
||||||
while True:
|
while True:
|
||||||
if default:
|
if default:
|
||||||
@@ -1072,19 +1093,7 @@ def do_prompt(d, key, text, default=None, validator=nonempty):
|
|||||||
x = term_input(prompt).strip()
|
x = term_input(prompt).strip()
|
||||||
if default and not x:
|
if default and not x:
|
||||||
x = default
|
x = default
|
||||||
if not isinstance(x, text_type):
|
x = term_decode(x)
|
||||||
# for Python 2.x, try to get a Unicode string out of it
|
|
||||||
if x.decode('ascii', 'replace').encode('ascii', 'replace') != x:
|
|
||||||
if TERM_ENCODING:
|
|
||||||
x = x.decode(TERM_ENCODING)
|
|
||||||
else:
|
|
||||||
print(turquoise('* Note: non-ASCII characters entered '
|
|
||||||
'and terminal encoding unknown -- assuming '
|
|
||||||
'UTF-8 or Latin-1.'))
|
|
||||||
try:
|
|
||||||
x = x.decode('utf-8')
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
x = x.decode('latin1')
|
|
||||||
try:
|
try:
|
||||||
x = validator(x)
|
x = validator(x)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
@@ -1126,7 +1135,7 @@ def ask_user(d):
|
|||||||
* batchfile: make command file
|
* batchfile: make command file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print(bold('Welcome to the Sphinx %s quickstart utility.') % __version__)
|
print(bold('Welcome to the Sphinx %s quickstart utility.') % __display_version__)
|
||||||
print('''
|
print('''
|
||||||
Please enter values for the following settings (just press Enter to
|
Please enter values for the following settings (just press Enter to
|
||||||
accept a default value, if one is given in brackets).''')
|
accept a default value, if one is given in brackets).''')
|
||||||
@@ -1396,7 +1405,7 @@ def usage(argv, msg=None):
|
|||||||
USAGE = """\
|
USAGE = """\
|
||||||
Sphinx v%s
|
Sphinx v%s
|
||||||
Usage: %%prog [options] [projectdir]
|
Usage: %%prog [options] [projectdir]
|
||||||
""" % __version__
|
""" % __display_version__
|
||||||
|
|
||||||
EPILOG = """\
|
EPILOG = """\
|
||||||
For more information, visit <http://sphinx-doc.org/>.
|
For more information, visit <http://sphinx-doc.org/>.
|
||||||
@@ -1410,20 +1419,23 @@ def valid_dir(d):
|
|||||||
if not path.isdir(dir):
|
if not path.isdir(dir):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
invalid_dirs = ['Makefile', 'make.bat']
|
if set(['Makefile', 'make.bat']) & set(os.listdir(dir)):
|
||||||
if set(invalid_dirs) & set(os.listdir(dir)):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
master = d['master']
|
|
||||||
suffix = d['suffix']
|
|
||||||
source = ['_static', '_templates', 'conf.py', master+suffix]
|
|
||||||
if d['sep']:
|
if d['sep']:
|
||||||
dir = os.path.join('source', dir)
|
dir = os.path.join('source', dir)
|
||||||
if not path.exists(dir):
|
if not path.exists(dir):
|
||||||
return True
|
return True
|
||||||
if not path.isdir(dir):
|
if not path.isdir(dir):
|
||||||
return False
|
return False
|
||||||
if set(source) & set(os.listdir(dir)):
|
|
||||||
|
reserved_names = [
|
||||||
|
'conf.py',
|
||||||
|
d['dot'] + 'static',
|
||||||
|
d['dot'] + 'templates',
|
||||||
|
d['master'] + d['suffix'],
|
||||||
|
]
|
||||||
|
if set(reserved_names) & set(os.listdir(dir)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -1447,7 +1459,7 @@ def main(argv=sys.argv):
|
|||||||
nocolor()
|
nocolor()
|
||||||
|
|
||||||
parser = optparse.OptionParser(USAGE, epilog=EPILOG,
|
parser = optparse.OptionParser(USAGE, epilog=EPILOG,
|
||||||
version='Sphinx v%s' % __version__,
|
version='Sphinx v%s' % __display_version__,
|
||||||
formatter=MyFormatter())
|
formatter=MyFormatter())
|
||||||
parser.add_option('-q', '--quiet', action='store_true', dest='quiet',
|
parser.add_option('-q', '--quiet', action='store_true', dest='quiet',
|
||||||
default=False,
|
default=False,
|
||||||
@@ -1512,21 +1524,17 @@ def main(argv=sys.argv):
|
|||||||
opts.ensure_value('path', args[0])
|
opts.ensure_value('path', args[0])
|
||||||
|
|
||||||
d = vars(opts)
|
d = vars(opts)
|
||||||
for k, v in list(d.items()):
|
# delete None or False value
|
||||||
# delete None or False value
|
d = dict((k, v) for k, v in d.items() if not (v is None or v is False))
|
||||||
if v is None or v is False:
|
|
||||||
del d[k]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if 'quiet' in d:
|
if 'quiet' in d:
|
||||||
if 'project' not in d or 'author' not in d or \
|
if not set(['project', 'author', 'version']).issubset(d):
|
||||||
'version' not in d:
|
|
||||||
print('''"quiet" is specified, but any of "project", \
|
print('''"quiet" is specified, but any of "project", \
|
||||||
"author" or "version" is not specified.''')
|
"author" or "version" is not specified.''')
|
||||||
return
|
return
|
||||||
|
|
||||||
if all(['quiet' in d, 'project' in d, 'author' in d,
|
if set(['quiet', 'project', 'author', 'version']).issubset(d):
|
||||||
'version' in d]):
|
|
||||||
# quiet mode with all required params satisfied, use default
|
# quiet mode with all required params satisfied, use default
|
||||||
d.setdefault('release', d['version'])
|
d.setdefault('release', d['version'])
|
||||||
d2 = DEFAULT_VALUE.copy()
|
d2 = DEFAULT_VALUE.copy()
|
||||||
@@ -1551,6 +1559,12 @@ def main(argv=sys.argv):
|
|||||||
print()
|
print()
|
||||||
print('[Interrupted.]')
|
print('[Interrupted.]')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# decode values in d if value is a Python string literal
|
||||||
|
for key, value in d.items():
|
||||||
|
if isinstance(value, binary_type):
|
||||||
|
d[key] = term_decode(value)
|
||||||
|
|
||||||
generate(d)
|
generate(d)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ def save_traceback(app):
|
|||||||
'# %s' % strip_colors(force_decode(s, 'utf-8')).strip()
|
'# %s' % strip_colors(force_decode(s, 'utf-8')).strip()
|
||||||
for s in app.messagelog)
|
for s in app.messagelog)
|
||||||
os.write(fd, (_DEBUG_HEADER %
|
os.write(fd, (_DEBUG_HEADER %
|
||||||
(sphinx.__version__,
|
(sphinx.__display_version__,
|
||||||
platform.python_version(),
|
platform.python_version(),
|
||||||
platform.python_implementation(),
|
platform.python_implementation(),
|
||||||
docutils.__version__, docutils.__version_details__,
|
docutils.__version__, docutils.__version_details__,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from six import itervalues
|
|||||||
from six.moves import range
|
from six.moves import range
|
||||||
from docutils import nodes, writers
|
from docutils import nodes, writers
|
||||||
|
|
||||||
from sphinx import addnodes, __version__
|
from sphinx import addnodes, __display_version__
|
||||||
from sphinx.locale import admonitionlabels, _
|
from sphinx.locale import admonitionlabels, _
|
||||||
from sphinx.util import ustrftime
|
from sphinx.util import ustrftime
|
||||||
from sphinx.writers.latex import collected_footnote
|
from sphinx.writers.latex import collected_footnote
|
||||||
@@ -39,7 +39,7 @@ TEMPLATE = """\
|
|||||||
@setfilename %(filename)s
|
@setfilename %(filename)s
|
||||||
@documentencoding UTF-8
|
@documentencoding UTF-8
|
||||||
@ifinfo
|
@ifinfo
|
||||||
@*Generated by Sphinx """ + __version__ + """.@*
|
@*Generated by Sphinx """ + __display_version__ + """.@*
|
||||||
@end ifinfo
|
@end ifinfo
|
||||||
@settitle %(title)s
|
@settitle %(title)s
|
||||||
@defindex ge
|
@defindex ge
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import re
|
|||||||
from six import PY3, iteritems
|
from six import PY3, iteritems
|
||||||
from six.moves import html_entities
|
from six.moves import html_entities
|
||||||
|
|
||||||
from sphinx import __version__
|
from sphinx import __display_version__
|
||||||
from util import remove_unicode_literals, gen_with_app
|
from util import remove_unicode_literals, gen_with_app
|
||||||
from etree13 import ElementTree as ET
|
from etree13 import ElementTree as ET
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ def check_static_entries(outdir):
|
|||||||
assert (staticdir / 'subdir' / 'foo.css').isfile()
|
assert (staticdir / 'subdir' / 'foo.css').isfile()
|
||||||
# a file from a file entry in html_static_path
|
# a file from a file entry in html_static_path
|
||||||
assert (staticdir / 'templated.css').isfile()
|
assert (staticdir / 'templated.css').isfile()
|
||||||
assert (staticdir / 'templated.css').text().splitlines()[1] == __version__
|
assert (staticdir / 'templated.css').text().splitlines()[1] == __display_version__
|
||||||
# a file from _static, but matches exclude_patterns
|
# a file from _static, but matches exclude_patterns
|
||||||
assert not (staticdir / 'excluded.css').exists()
|
assert not (staticdir / 'excluded.css').exists()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user