mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5881 from tk0miya/refactor_conf_py
refactor: Use repr() to make escaped string in template for conf.py
This commit is contained in:
commit
064c80336f
@ -395,13 +395,6 @@ def generate(d, overwrite=True, silent=False, templatedir=None):
|
||||
d['project_doc_texescaped'] = (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', 'project_doc', 'project_doc_texescaped',
|
||||
'author', 'author_texescaped', 'copyright',
|
||||
'version', 'release', 'master'):
|
||||
d[key + '_str'] = d[key].replace('\\', '\\\\').replace("'", "\\'")
|
||||
|
||||
ensuredir(d['path'])
|
||||
|
||||
srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']
|
||||
|
@ -13,12 +13,12 @@
|
||||
{% if append_syspath -%}
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, '{{ module_path }}')
|
||||
sys.path.insert(0, {{ module_path | repr }})
|
||||
{% else -%}
|
||||
# import os
|
||||
# import sys
|
||||
{% if module_path -%}
|
||||
# sys.path.insert(0, '{{ module_path }}')
|
||||
# sys.path.insert(0, {{ module_path | repr }})
|
||||
{% else -%}
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
{% endif -%}
|
||||
@ -26,14 +26,14 @@ sys.path.insert(0, '{{ module_path }}')
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = '{{ project_str }}'
|
||||
copyright = '{{ copyright_str }}'
|
||||
author = '{{ author_str }}'
|
||||
project = {{ project | repr }}
|
||||
copyright = {{ copyright | repr }}
|
||||
author = {{ author | repr }}
|
||||
|
||||
# The short X.Y version
|
||||
version = '{{ version_str }}'
|
||||
version = {{ version | repr }}
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '{{ release_str }}'
|
||||
release = {{ release | repr }}
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
@ -54,11 +54,11 @@ templates_path = ['{{ dot }}templates']
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '{{ suffix }}'
|
||||
source_suffix = {{ suffix | repr }}
|
||||
|
||||
{% if master_doc != 'index' -%}
|
||||
# The master toctree document.
|
||||
master_doc = '{{ master_str }}'
|
||||
master_doc = {{ master | repr }}
|
||||
|
||||
{% endif -%}
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
@ -127,8 +127,8 @@ latex_elements = {
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, '{{ project_fn }}.tex', '{{ project_doc_texescaped_str }}',
|
||||
'{{ author_texescaped_str }}', 'manual'),
|
||||
(master_doc, '{{ project_fn }}.tex', {{ project_doc_texescaped | repr }},
|
||||
{{ author_texescaped | repr }}, 'manual'),
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user