summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2013-06-09 09:48:43 +0900
committershimizukawa <shimizukawa@gmail.com>2013-06-09 09:48:43 +0900
commit990bc93820783cd20b1fc3a7de0bf1cd387e10da (patch)
treeedadb786a837266ffbab6838ad2700fc5cb8b27f
parentc48fd4ee27448b18581549d689e523b6e7060891 (diff)
downloadsphinx-990bc93820783cd20b1fc3a7de0bf1cd387e10da.tar.gz
Fix "Title underline is short" WARNING is given when using fullwidth characters to "Project name" on quickstart. Closes #1189
-rw-r--r--CHANGES2
-rw-r--r--sphinx/quickstart.py4
-rw-r--r--tests/test_quickstart.py35
3 files changed, 39 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 0b8cc80d..c7bfe35e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -28,6 +28,8 @@ Bugs fixed
Thanks to tychoish.
* #1188: sphinx-quickstart raises UnicodeEncodeError if "Project version"
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)
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index 41b4f3c5..73926f82 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -14,6 +14,8 @@ from os import path
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
+from docutils.utils import column_width
+
from sphinx import __version__
from sphinx.util.osutil import make_filename
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_manpage'] = d['project_fn'].lower()
d['now'] = time.asctime()
- d['project_underline'] = len(d['project']) * '='
+ d['project_underline'] = column_width(d['project']) * '='
extensions = (',\n' + indent).join(
repr('sphinx.ext.' + name)
for name in ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py
index f2de2f56..b7b1ec44 100644
--- a/tests/test_quickstart.py
+++ b/tests/test_quickstart.py
@@ -11,13 +11,20 @@
import sys
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.util.console import nocolor, coloron
from sphinx.util.pycompat import execfile_
+
+warnfile = StringIO()
+
+
def setup_module():
nocolor()
@@ -230,3 +237,29 @@ def test_generated_files_eol(tempdir):
assert_eol(tempdir / 'make.bat', '\r\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