Fix broken in py3

This commit is contained in:
Takeshi KOMIYA 2015-12-25 16:10:37 +09:00
parent f1cf5d594a
commit 66ef8102c4
2 changed files with 24 additions and 18 deletions

View File

@ -20,6 +20,7 @@ import os
import sys
import optparse
from os import path
from six import binary_type
from sphinx.util.osutil import walk
from sphinx import __display_version__
@ -353,10 +354,10 @@ Note: By default this script will not overwrite already created files.""")
path = opts.destdir,
sep = False,
dot = '_',
project = None,
author = 'Author',
version = '',
release = '',
project = opts.header,
author = opts.author or 'Author',
version = opts.version or '',
release = opts.release or opts.version or '',
suffix = '.' + opts.suffix,
master = 'index',
epub = True,
@ -369,16 +370,14 @@ Note: By default this script will not overwrite already created files.""")
mastertoctree = text,
language = 'en',
)
if opts.header:
d['project'] = opts.header.decode('utf-8')
if opts.author:
d['author'] = opts.author.decode('utf-8')
if opts.version:
d['version'] = opts.version.decode('utf-8')
if opts.release:
d['release'] = opts.release.decode('utf-8')
elif opts.version:
d['release'] = opts.version.decode('utf-8')
if isinstance(opts.header, binary_type):
d['project'] = d['project'].decode('utf-8')
if isinstance(opts.author, binary_type):
d['author'] = d['author'].decode('utf-8')
if isinstance(opts.version, binary_type):
d['version'] = d['version'].decode('utf-8')
if isinstance(opts.release, binary_type):
d['release'] = d['release'].decode('utf-8')
if not opts.dryrun:
qs.generate(d, silent=True, overwrite=opts.force)

View File

@ -12,6 +12,7 @@
from __future__ import print_function
import sys
from six import PY2
from sphinx import apidoc
@ -58,10 +59,16 @@ def test_multibyte_parameters(tempdir):
assert (outdir / 'index.rst').isfile()
conf_py = (outdir / 'conf.py').text()
assert u"project = u'プロジェクト名'" in conf_py
assert u"author = u'著者名'" in conf_py
assert u"version = u'バージョン'" in conf_py
assert u"release = u'リリース'" in conf_py
if PY2:
assert u"project = u'プロジェクト名'" in conf_py
assert u"author = u'著者名'" in conf_py
assert u"version = u'バージョン'" in conf_py
assert u"release = u'リリース'" in conf_py
else:
assert u"project = 'プロジェクト名'" in conf_py
assert u"author = '著者名'" in conf_py
assert u"version = 'バージョン'" in conf_py
assert u"release = 'リリース'" in conf_py
@with_app('text', srcdir=outdir)
def assert_build(app, status, warning):