Fix "Title underline is short" WARNING is given when using fullwidth characters to "Project name" on quickstart. Closes #1189

This commit is contained in:
Takayuki Shimizukawa 2013-06-09 09:48:43 +09:00
parent 573d8433b9
commit 8ec83f963b
3 changed files with 39 additions and 2 deletions

View File

@ -28,6 +28,8 @@ Bugs fixed
Thanks to tychoish. Thanks to tychoish.
* #1188: sphinx-quickstart raises UnicodeEncodeError if "Project version" * #1188: sphinx-quickstart raises UnicodeEncodeError if "Project version"
includes non-ASCII characters. includes non-ASCII characters.
* #1189: "Title underline is short" WARNING is given when using fullwidth
characters to "Project name" on quickstart.
Release 1.2 (beta1 released Mar 31, 2013) Release 1.2 (beta1 released Mar 31, 2013)

View File

@ -14,6 +14,8 @@ from os import path
TERM_ENCODING = getattr(sys.stdin, 'encoding', None) TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
from docutils.utils import column_width
from sphinx import __version__ from sphinx import __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, \
@ -1088,7 +1090,7 @@ def generate(d, overwrite=True, silent=False):
d['project_fn'] = make_filename(d['project']) d['project_fn'] = make_filename(d['project'])
d['project_manpage'] = d['project_fn'].lower() d['project_manpage'] = d['project_fn'].lower()
d['now'] = time.asctime() d['now'] = time.asctime()
d['project_underline'] = len(d['project']) * '=' d['project_underline'] = column_width(d['project']) * '='
extensions = (',\n' + indent).join( extensions = (',\n' + indent).join(
repr('sphinx.ext.' + name) repr('sphinx.ext.' + name)
for name in ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage', for name in ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',

View File

@ -11,13 +11,20 @@
import sys import sys
import time import time
from StringIO import StringIO
import tempfile
from util import raises, with_tempdir from util import raises, with_tempdir, with_app
from sphinx import application
from sphinx import quickstart as qs from sphinx import quickstart as qs
from sphinx.util.console import nocolor, coloron from sphinx.util.console import nocolor, coloron
from sphinx.util.pycompat import execfile_ from sphinx.util.pycompat import execfile_
warnfile = StringIO()
def setup_module(): def setup_module():
nocolor() nocolor()
@ -230,3 +237,29 @@ def test_generated_files_eol(tempdir):
assert_eol(tempdir / 'make.bat', '\r\n') assert_eol(tempdir / 'make.bat', '\r\n')
assert_eol(tempdir / 'Makefile', '\n') assert_eol(tempdir / 'Makefile', '\n')
@with_tempdir
def test_quickstart_and_build(tmpdir):
answers = {
'Root path': tmpdir,
'Project name': ur'Fullwidth charactor: \u30c9\u30a4\u30c4',
'Author name': 'Georg Brandl',
'Project version': '0.1',
}
qs.term_input = mock_raw_input(answers)
d = {}
qs.ask_user(d)
qs.generate(d)
app = application.Sphinx(
tmpdir, #srcdir
tmpdir, #confdir
(tmpdir / '_build' / 'html'), #outdir
(tmpdir / '_build' / '.doctree'), #doctreedir
'html', #buildername
status=StringIO(),
warning=warnfile)
app.builder.build_all()
warnings = warnfile.getvalue()
assert not warnings