mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Fix #2040: UnicodeDecodeError in sphinx-apidoc when author contains non-ascii characters
This commit is contained in:
@@ -19,6 +19,7 @@ Bugs fixed
|
||||
* #2186: Fix LaTeX output of \mathbb in math
|
||||
* #1480, #2188: LaTeX: Support math in section titles
|
||||
* #2071: Fix same footnote in more than two section titles => LaTeX/PDF Bug
|
||||
* #2040: Fix UnicodeDecodeError in sphinx-apidoc when author contains non-ascii characters
|
||||
|
||||
|
||||
Release 1.3.3 (released Dec 2, 2015)
|
||||
|
||||
+15
-4
@@ -353,10 +353,10 @@ Note: By default this script will not overwrite already created files.""")
|
||||
path = opts.destdir,
|
||||
sep = False,
|
||||
dot = '_',
|
||||
project = opts.header,
|
||||
author = opts.author or 'Author',
|
||||
version = opts.version or '',
|
||||
release = opts.release or opts.version or '',
|
||||
project = None,
|
||||
author = 'Author',
|
||||
version = '',
|
||||
release = '',
|
||||
suffix = '.' + opts.suffix,
|
||||
master = 'index',
|
||||
epub = True,
|
||||
@@ -369,6 +369,17 @@ 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 not opts.dryrun:
|
||||
qs.generate(d, silent=True, overwrite=opts.force)
|
||||
elif not opts.notoc:
|
||||
|
||||
@@ -40,3 +40,37 @@ def test_simple(tempdir):
|
||||
assert_build()
|
||||
finally:
|
||||
sys.path.remove(codedir)
|
||||
|
||||
|
||||
@with_tempdir
|
||||
def test_multibyte_parameters(tempdir):
|
||||
codedir = rootdir / 'root'
|
||||
outdir = tempdir / 'out'
|
||||
args = ['sphinx-apidoc', '-o', outdir, '-F', codedir,
|
||||
'--doc-project', u'プロジェクト名'.encode('utf-8'),
|
||||
'--doc-author', u'著者名'.encode('utf-8'),
|
||||
'--doc-version', u'バージョン'.encode('utf-8'),
|
||||
'--doc-release', u'リリース'.encode('utf-8')]
|
||||
apidoc.main(args)
|
||||
|
||||
assert (outdir / 'conf.py').isfile()
|
||||
assert (outdir / 'autodoc_fodder.rst').isfile()
|
||||
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
|
||||
|
||||
@with_app('text', srcdir=outdir)
|
||||
def assert_build(app, status, warning):
|
||||
app.build()
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
|
||||
sys.path.append(codedir)
|
||||
try:
|
||||
assert_build()
|
||||
finally:
|
||||
sys.path.remove(codedir)
|
||||
|
||||
Reference in New Issue
Block a user