mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-04 18:33:32 -05:00
Merge pull request #6041 from tk0miya/simplify_conf.py
Simplify conf.py
This commit is contained in:
@@ -66,6 +66,7 @@ Incompatible changes
|
||||
* LaTeX: graphics inclusion of oversized images rescales to not exceed
|
||||
the text width and height, even if width and/or height option were used.
|
||||
(refs: #5956)
|
||||
* epub: ``epub_title`` defaults to the :confval:`project` option
|
||||
* #4550: All tables and figures without ``align`` option are displayed to center
|
||||
* #4587: html: Output HTML5 by default
|
||||
|
||||
|
||||
@@ -1567,7 +1567,11 @@ the `Dublin Core metadata <http://dublincore.org/>`_.
|
||||
.. confval:: epub_title
|
||||
|
||||
The title of the document. It defaults to the :confval:`html_title` option
|
||||
but can be set independently for epub creation.
|
||||
but can be set independently for epub creation. It defaults to the
|
||||
:confval:`project` option.
|
||||
|
||||
.. versionchanged:: 2.0
|
||||
It defaults to the ``project`` option.
|
||||
|
||||
.. confval:: epub_description
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ def setup(app):
|
||||
app.add_config_value('epub_version', 3.0, 'epub') # experimental
|
||||
app.add_config_value('epub_theme', 'epub', 'epub')
|
||||
app.add_config_value('epub_theme_options', {}, 'epub')
|
||||
app.add_config_value('epub_title', lambda self: self.html_title, 'epub')
|
||||
app.add_config_value('epub_title', lambda self: self.project, 'epub')
|
||||
app.add_config_value('epub_author', lambda self: self.author, 'epub')
|
||||
app.add_config_value('epub_language', lambda self: self.language or 'en', 'epub')
|
||||
app.add_config_value('epub_publisher', lambda self: self.author, 'epub')
|
||||
|
||||
@@ -30,10 +30,16 @@ project = {{ project | repr }}
|
||||
copyright = {{ copyright | repr }}
|
||||
author = {{ author | repr }}
|
||||
|
||||
{%- if version %}
|
||||
|
||||
# The short X.Y version
|
||||
version = {{ version | repr }}
|
||||
{%- endif %}
|
||||
{%- if release %}
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = {{ release | repr }}
|
||||
{%- endif %}
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
@@ -50,17 +56,20 @@ extensions = [
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['{{ dot }}templates']
|
||||
|
||||
{% if suffix != '.rst' -%}
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = {{ suffix | repr }}
|
||||
|
||||
{% if master_doc != 'index' -%}
|
||||
{% endif -%}
|
||||
{% if master != 'index' -%}
|
||||
# The master toctree document.
|
||||
master_doc = {{ master | repr }}
|
||||
|
||||
{% endif -%}
|
||||
{% if language -%}
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
@@ -68,6 +77,7 @@ master_doc = {{ master | repr }}
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = {{ language | repr }}
|
||||
|
||||
{% endif -%}
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
@@ -101,24 +111,6 @@ html_static_path = ['{{ dot }}static']
|
||||
# 'searchbox.html']``.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
|
||||
# -- Options for Epub output -------------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = project
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#
|
||||
# epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#
|
||||
# epub_uid = ''
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ['search.html']
|
||||
{%- if extensions %}
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def test_build_epub(app):
|
||||
|
||||
# toc.ncx
|
||||
toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').text())
|
||||
assert toc.find("./ncx:docTitle/ncx:text").text == 'Python documentation'
|
||||
assert toc.find("./ncx:docTitle/ncx:text").text == 'Python'
|
||||
|
||||
# toc.ncx / head
|
||||
meta = list(toc.find("./ncx:head"))
|
||||
@@ -96,7 +96,7 @@ def test_build_epub(app):
|
||||
# content.opf / metadata
|
||||
metadata = opf.find("./idpf:metadata")
|
||||
assert metadata.find("./dc:language").text == 'en'
|
||||
assert metadata.find("./dc:title").text == 'Python documentation'
|
||||
assert metadata.find("./dc:title").text == 'Python'
|
||||
assert metadata.find("./dc:description").text == 'unknown'
|
||||
assert metadata.find("./dc:creator").text == 'unknown'
|
||||
assert metadata.find("./dc:contributor").text == 'unknown'
|
||||
@@ -176,7 +176,7 @@ def test_nested_toc(app):
|
||||
|
||||
# toc.ncx
|
||||
toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').bytes())
|
||||
assert toc.find("./ncx:docTitle/ncx:text").text == 'Python documentation'
|
||||
assert toc.find("./ncx:docTitle/ncx:text").text == 'Python'
|
||||
|
||||
# toc.ncx / navPoint
|
||||
def navinfo(elem):
|
||||
@@ -231,8 +231,7 @@ def test_escaped_toc(app):
|
||||
|
||||
# toc.ncx
|
||||
toc = EPUBElementTree.fromstring((app.outdir / 'toc.ncx').bytes())
|
||||
assert toc.find("./ncx:docTitle/ncx:text").text == ('need <b>"escaped"</b> '
|
||||
'project documentation')
|
||||
assert toc.find("./ncx:docTitle/ncx:text").text == 'need <b>"escaped"</b> project'
|
||||
|
||||
# toc.ncx / navPoint
|
||||
def navinfo(elem):
|
||||
|
||||
@@ -112,8 +112,6 @@ def test_quickstart_defaults(tempdir):
|
||||
execfile_(conffile, ns)
|
||||
assert ns['extensions'] == []
|
||||
assert ns['templates_path'] == ['_templates']
|
||||
assert ns['source_suffix'] == '.rst'
|
||||
assert ns['master_doc'] == 'index'
|
||||
assert ns['project'] == 'Sphinx Test'
|
||||
assert ns['copyright'] == '%s, Georg Brandl' % time.strftime('%Y')
|
||||
assert ns['version'] == '0.1'
|
||||
|
||||
Reference in New Issue
Block a user