diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 0de45d3f1..e5b7cfaf5 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -59,20 +59,20 @@ source_suffix = '%(suffix)s' #source_encoding = 'utf-8' # The master toctree document. -master_doc = '%(master)s' +master_doc = '%(master_str)s' # General information about the project. -project = u'%(project)s' -copyright = u'%(copyright)s' +project = u'%(project_str)s' +copyright = u'%(copyright_str)s' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '%(version)s' +version = '%(version_str)s' # The full version, including alpha/beta/rc tags. -release = '%(release)s' +release = '%(release_str)s' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -197,8 +197,8 @@ htmlhelp_basename = '%(project_fn)sdoc' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('%(master)s', '%(project_fn)s.tex', ur'%(project_doc_texescaped)s', - ur'%(author_texescaped)s', 'manual'), + ('%(master_str)s', '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s', + u'%(author_texescaped_str)s', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -625,6 +625,12 @@ directly.''' d['project_doc_texescaped'] = unicode(d['project'] + ' Documentation').\ translate(texescape.tex_escape_map) + # escape backslashes and single quotes in strings that are put into + # a Python string literal + for key in ('project', 'copyright', 'author_texescaped', + 'project_doc_texescaped', 'version', 'release', 'master'): + d[key + '_str'] = d[key].replace('\\', '\\\\').replace("'", "\\'") + if not path.isdir(d['path']): mkdir_p(d['path']) @@ -642,12 +648,6 @@ directly.''' mkdir_p(path.join(srcdir, d['dot'] + 'templates')) mkdir_p(path.join(srcdir, d['dot'] + 'static')) - def escape(key): - d[key] = d[key].encode('string-escape') - for key in ('project', 'copyright', 'version', 'release', - 'master', 'suffix'): - escape(key) - conf_text = QUICKSTART_CONF % d if d['ext_intersphinx'].upper() in ('Y', 'YES'): conf_text += INTERSPHINX_CONFIG diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index ae001eb6b..4441ab23a 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -113,7 +113,7 @@ def test_quickstart_all_answers(tempdir): 'Separate source and build': 'y', 'Name prefix for templates': '.', 'Project name': 'STASI\xe2\x84\xa2', - 'Author name': 'Wolfgang Sch\xc3\xa4uble & G. Beckstein', + 'Author name': 'Wolfgang Sch\xc3\xa4uble & G\'Beckstein', 'Project version': '2.0', 'Project release': '2.0.1', 'Source file suffix': '.txt', @@ -142,14 +142,14 @@ def test_quickstart_all_answers(tempdir): assert ns['source_suffix'] == '.txt' assert ns['master_doc'] == 'contents' assert ns['project'] == u'STASI™' - assert ns['copyright'] == u'%s, Wolfgang Schäuble & G. Beckstein' % \ + assert ns['copyright'] == u'%s, Wolfgang Schäuble & G\'Beckstein' % \ time.strftime('%Y') assert ns['version'] == '2.0' assert ns['release'] == '2.0.1' assert ns['html_static_path'] == ['.static'] assert ns['latex_documents'] == [ ('contents', 'STASI.tex', u'STASI™ Documentation', - ur'Wolfgang Schäuble \& G. Beckstein', 'manual')] + u'Wolfgang Schäuble \\& G\'Beckstein', 'manual')] assert (tempdir / 'build').isdir() assert (tempdir / 'source' / '.static').isdir()