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').\
|
d['project_doc_texescaped'] = (d['project'] + ' Documentation').\
|
||||||
translate(texescape.tex_escape_map)
|
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'])
|
ensuredir(d['path'])
|
||||||
|
|
||||||
srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']
|
srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
{% if append_syspath -%}
|
{% if append_syspath -%}
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, '{{ module_path }}')
|
sys.path.insert(0, {{ module_path | repr }})
|
||||||
{% else -%}
|
{% else -%}
|
||||||
# import os
|
# import os
|
||||||
# import sys
|
# import sys
|
||||||
{% if module_path -%}
|
{% if module_path -%}
|
||||||
# sys.path.insert(0, '{{ module_path }}')
|
# sys.path.insert(0, {{ module_path | repr }})
|
||||||
{% else -%}
|
{% else -%}
|
||||||
# sys.path.insert(0, os.path.abspath('.'))
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
@ -26,14 +26,14 @@ sys.path.insert(0, '{{ module_path }}')
|
|||||||
|
|
||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
project = '{{ project_str }}'
|
project = {{ project | repr }}
|
||||||
copyright = '{{ copyright_str }}'
|
copyright = {{ copyright | repr }}
|
||||||
author = '{{ author_str }}'
|
author = {{ author | repr }}
|
||||||
|
|
||||||
# The short X.Y version
|
# The short X.Y version
|
||||||
version = '{{ version_str }}'
|
version = {{ version | repr }}
|
||||||
# The full version, including alpha/beta/rc tags
|
# The full version, including alpha/beta/rc tags
|
||||||
release = '{{ release_str }}'
|
release = {{ release | repr }}
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
@ -54,11 +54,11 @@ templates_path = ['{{ dot }}templates']
|
|||||||
# You can specify multiple suffix as a list of string:
|
# You can specify multiple suffix as a list of string:
|
||||||
#
|
#
|
||||||
# source_suffix = ['.rst', '.md']
|
# source_suffix = ['.rst', '.md']
|
||||||
source_suffix = '{{ suffix }}'
|
source_suffix = {{ suffix | repr }}
|
||||||
|
|
||||||
{% if master_doc != 'index' -%}
|
{% if master_doc != 'index' -%}
|
||||||
# The master toctree document.
|
# The master toctree document.
|
||||||
master_doc = '{{ master_str }}'
|
master_doc = {{ master | repr }}
|
||||||
|
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
@ -127,8 +127,8 @@ latex_elements = {
|
|||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
(master_doc, '{{ project_fn }}.tex', '{{ project_doc_texescaped_str }}',
|
(master_doc, '{{ project_fn }}.tex', {{ project_doc_texescaped | repr }},
|
||||||
'{{ author_texescaped_str }}', 'manual'),
|
{{ author_texescaped | repr }}, 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user