Commits

Georg Brandl committed 1666d81

Fix the fix of #127 to actually work.

Comments (0)

Files changed (2)

sphinx/quickstart.py

 #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.
 # 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
     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'])
 
     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

tests/test_quickstart.py

         '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',
     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()