merge with stable

This commit is contained in:
shimizukawa 2016-04-18 14:41:06 +09:00
commit 132059a253
13 changed files with 339 additions and 202 deletions

12
CHANGES
View File

@ -19,9 +19,21 @@ Documentation
Release 1.4.2 (in development) Release 1.4.2 (in development)
============================== ==============================
Features added
--------------
* Now :confval:`suppress_warnings` accepts following configurations: ``app.add_node``, ``app.add_directive``, ``app.add_role`` and ``app.add_generic_role`` (ref: #2451)
Bugs fixed Bugs fixed
---------- ----------
* #2370: the equations are slightly misaligned in LaTeX writer
* #1817, #2077: suppress pep8 warnings on conf.py generated by sphinx-quickstart
* #2407: building docs crash if document includes large data image URIs
* #2436: Sphinx does not check version by :confval:`needs_sphinx` if loading extensions failed
* #2397: Setup shorthandoff for turkish documents
* #2447: VerbatimBorderColor wrongly used also for captions of PDF
Release 1.4.1 (released Apr 12, 2016) Release 1.4.1 (released Apr 12, 2016)
===================================== =====================================

View File

@ -218,6 +218,10 @@ General configuration
Sphinx supports following warning types: Sphinx supports following warning types:
* app.add_node
* app.add_directive
* app.add_role
* app.add_generic_role
* ref.term * ref.term
* ref.ref * ref.ref
* ref.numref * ref.numref

View File

@ -111,7 +111,7 @@ These are the basic steps needed to start developing on Sphinx.
* Run the unit tests:: * Run the unit tests::
pip install nose mock pip install -r test-reqs.txt
make test make test
* Build the documentation and check the output for different builders:: * Build the documentation and check the output for different builders::

View File

@ -133,6 +133,15 @@ class Sphinx(object):
self.config.check_unicode(self.warn) self.config.check_unicode(self.warn)
# defer checking types until i18n has been initialized # defer checking types until i18n has been initialized
# initialize some limited config variables before loading extensions
self.config.pre_init_values(self.warn)
# check the Sphinx version if requested
if self.config.needs_sphinx and self.config.needs_sphinx > sphinx.__display_version__:
raise VersionRequirementError(
'This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.' % self.config.needs_sphinx)
# set confdir to srcdir if -C given (!= no confdir); a few pieces # set confdir to srcdir if -C given (!= no confdir); a few pieces
# of code expect a confdir to be set # of code expect a confdir to be set
if self.confdir is None: if self.confdir is None:
@ -163,13 +172,6 @@ class Sphinx(object):
# now that we know all config values, collect them from conf.py # now that we know all config values, collect them from conf.py
self.config.init_values(self.warn) self.config.init_values(self.warn)
# check the Sphinx version if requested
if self.config.needs_sphinx and \
self.config.needs_sphinx > sphinx.__display_version__:
raise VersionRequirementError(
'This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.' % self.config.needs_sphinx)
# check extension versions if requested # check extension versions if requested
if self.config.needs_extensions: if self.config.needs_extensions:
for extname, needs_ver in self.config.needs_extensions.items(): for extname, needs_ver in self.config.needs_extensions.items():
@ -584,7 +586,8 @@ class Sphinx(object):
hasattr(nodes.GenericNodeVisitor, 'visit_' + node.__name__): hasattr(nodes.GenericNodeVisitor, 'visit_' + node.__name__):
self.warn('while setting up extension %s: node class %r is ' self.warn('while setting up extension %s: node class %r is '
'already registered, its visitors will be overridden' % 'already registered, its visitors will be overridden' %
(self._setting_up_extension, node.__name__)) (self._setting_up_extension, node.__name__),
type='app', subtype='add_node')
nodes._add_node_class_names([node.__name__]) nodes._add_node_class_names([node.__name__])
for key, val in iteritems(kwds): for key, val in iteritems(kwds):
try: try:
@ -636,7 +639,8 @@ class Sphinx(object):
if name in directives._directives: if name in directives._directives:
self.warn('while setting up extension %s: directive %r is ' self.warn('while setting up extension %s: directive %r is '
'already registered, it will be overridden' % 'already registered, it will be overridden' %
(self._setting_up_extension[-1], name)) (self._setting_up_extension[-1], name),
type='app', subtype='add_directive')
directives.register_directive( directives.register_directive(
name, self._directive_helper(obj, content, arguments, **options)) name, self._directive_helper(obj, content, arguments, **options))
@ -645,7 +649,8 @@ class Sphinx(object):
if name in roles._roles: if name in roles._roles:
self.warn('while setting up extension %s: role %r is ' self.warn('while setting up extension %s: role %r is '
'already registered, it will be overridden' % 'already registered, it will be overridden' %
(self._setting_up_extension[-1], name)) (self._setting_up_extension[-1], name),
type='app', subtype='add_role')
roles.register_local_role(name, role) roles.register_local_role(name, role)
def add_generic_role(self, name, nodeclass): def add_generic_role(self, name, nodeclass):
@ -655,7 +660,8 @@ class Sphinx(object):
if name in roles._roles: if name in roles._roles:
self.warn('while setting up extension %s: role %r is ' self.warn('while setting up extension %s: role %r is '
'already registered, it will be overridden' % 'already registered, it will be overridden' %
(self._setting_up_extension[-1], name)) (self._setting_up_extension[-1], name),
type='app', subtype='add_generic_role')
role = roles.GenericRole(name, nodeclass) role = roles.GenericRole(name, nodeclass)
roles.register_local_role(name, role) roles.register_local_role(name, role)

View File

@ -338,40 +338,60 @@ class Config(object):
'characters; this can lead to Unicode errors occurring. ' 'characters; this can lead to Unicode errors occurring. '
'Please use Unicode strings, e.g. %r.' % (name, u'Content')) 'Please use Unicode strings, e.g. %r.' % (name, u'Content'))
def convert_overrides(self, name, value):
if not isinstance(value, string_types):
return value
else:
defvalue = self.values[name][0]
if isinstance(defvalue, dict):
raise ValueError('cannot override dictionary config setting %r, '
'ignoring (use %r to set individual elements)' %
(name, name + '.key=value'))
elif isinstance(defvalue, list):
return value.split(',')
elif isinstance(defvalue, integer_types):
try:
return int(value)
except ValueError:
raise ValueError('invalid number %r for config value %r, ignoring' %
(value, name))
elif hasattr(defvalue, '__call__'):
return value
elif defvalue is not None and not isinstance(defvalue, string_types):
raise ValueError('cannot override config setting %r with unsupported '
'type, ignoring' % name)
else:
return value
def pre_init_values(self, warn):
"""Initialize some limited config variables before loading extensions"""
variables = ['needs_sphinx', 'suppress_warnings']
for name in variables:
try:
if name in self.overrides:
self.__dict__[name] = self.convert_overrides(name, self.overrides[name])
elif name in self._raw_config:
self.__dict__[name] = self._raw_config[name]
except ValueError as exc:
warn(exc)
def init_values(self, warn): def init_values(self, warn):
config = self._raw_config config = self._raw_config
for valname, value in iteritems(self.overrides): for valname, value in iteritems(self.overrides):
if '.' in valname: try:
realvalname, key = valname.split('.', 1) if '.' in valname:
config.setdefault(realvalname, {})[key] = value realvalname, key = valname.split('.', 1)
continue config.setdefault(realvalname, {})[key] = value
elif valname not in self.values:
warn('unknown config value %r in override, ignoring' % valname)
continue
defvalue = self.values[valname][0]
if isinstance(value, string_types):
if isinstance(defvalue, dict):
warn('cannot override dictionary config setting %r, '
'ignoring (use %r to set individual elements)' %
(valname, valname + '.key=value'))
continue continue
elif isinstance(defvalue, list): elif valname not in self.values:
config[valname] = value.split(',') warn('unknown config value %r in override, ignoring' % valname)
elif isinstance(defvalue, integer_types): continue
try: if isinstance(value, string_types):
config[valname] = int(value) config[valname] = self.convert_overrides(valname, value)
except ValueError:
warn('invalid number %r for config value %r, ignoring'
% (value, valname))
elif hasattr(defvalue, '__call__'):
config[valname] = value
elif defvalue is not None and not isinstance(defvalue, string_types):
warn('cannot override config setting %r with unsupported '
'type, ignoring' % valname)
else: else:
config[valname] = value config[valname] = value
else: except ValueError as exc:
config[valname] = value warn(exc)
for name in config: for name in config:
if name in self.values: if name in self.values:
self.__dict__[name] = config[name] self.__dict__[name] = config[name]

View File

@ -907,7 +907,11 @@ class BuildEnvironment:
# The special key ? is set for nonlocal URIs. # The special key ? is set for nonlocal URIs.
node['candidates'] = candidates = {} node['candidates'] = candidates = {}
imguri = node['uri'] imguri = node['uri']
if imguri.find('://') != -1: if imguri.startswith('data:'):
self.warn_node('image data URI found. some builders might not support', node)
candidates['?'] = imguri
continue
elif imguri.find('://') != -1:
self.warn_node('nonlocal image URI found: %s' % imguri, node) self.warn_node('nonlocal image URI found: %s' % imguri, node)
candidates['?'] = imguri candidates['?'] = imguri
continue continue

View File

@ -29,24 +29,38 @@ class eqref(nodes.Inline, nodes.TextElement):
def wrap_displaymath(math, label, numbering): def wrap_displaymath(math, label, numbering):
parts = math.split('\n\n') def is_equation(part):
ret = [] return part.strip()
for i, part in enumerate(parts):
if not part.strip(): if label is None:
continue labeldef = ''
ret.append(r'\begin{split}%s\end{split}' % part)
if not ret:
return ''
if label is not None or numbering:
env_begin = r'\begin{align}'
if label is not None:
env_begin += r'\label{%s}' % label
env_end = r'\end{align}'
else: else:
env_begin = r'\begin{align*}' labeldef = r'\label{%s}' % label
env_end = r'\end{align*}' numbering = True
return ('%s\\begin{aligned}\n%s\\end{aligned}%s') % (
env_begin, '\\\\\n'.join(ret), env_end) parts = list(filter(is_equation, math.split('\n\n')))
equations = []
if len(parts) == 0:
return ''
elif len(parts) == 1:
if numbering:
begin = r'\begin{equation}' + labeldef
end = r'\end{equation}'
else:
begin = r'\begin{equation*}' + labeldef
end = r'\end{equation*}'
equations.append('\\begin{split}%s\\end{split}\n' % parts[0])
else:
if numbering:
begin = r'\begin{align}%s\!\begin{aligned}' % labeldef
end = r'\end{aligned}\end{align}'
else:
begin = r'\begin{align*}%s\!\begin{aligned}' % labeldef
end = r'\end{aligned}\end{align*}'
for part in parts:
equations.append('%s\\\\\n' % part)
return '%s\n%s%s' % (begin, ''.join(equations), end)
def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]):

View File

@ -86,18 +86,19 @@ QUICKSTART_CONF += u'''\
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.')) #
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0' #
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@ -109,11 +110,13 @@ templates_path = ['%(dot)stemplates']
# The suffix(es) of source filenames. # The suffix(es) of source filenames.
# 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)s' source_suffix = '%(suffix)s'
# The encoding of source files. # The encoding of source files.
#source_encoding = 'utf-8-sig' #
# source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = '%(master_str)s' master_doc = '%(master_str)s'
@ -141,9 +144,12 @@ language = %(language)r
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
#today = '' #
# today = ''
#
# Else, today_fmt is used as the format for a strftime call. # Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%%B %%d, %%Y' #
# today_fmt = '%%B %%d, %%Y'
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
@ -152,27 +158,31 @@ exclude_patterns = [%(exclude_patterns)s]
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
#default_role = None #
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True #
# add_function_parentheses = True
# If true, the current module name will be prepended to all description # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
#add_module_names = True #
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
#show_authors = False #
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
#modindex_common_prefix = [] # modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents. # If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False # keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = %(ext_todo)s todo_include_todos = %(ext_todo)s
@ -182,31 +192,37 @@ todo_include_todos = %(ext_todo)s
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
#
html_theme = 'alabaster' html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
# documentation. # documentation.
#html_theme_options = {} #
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = [] # html_theme_path = []
# The name for this set of Sphinx documents. # The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default. # "<project> v<release> documentation" by default.
#html_title = u'%(project_str)s v%(release_str)s' #
# html_title = u'%(project_str)s v%(release_str)s'
# A shorter title for the navigation bar. Default is the same as html_title. # A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None #
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # of the sidebar.
#html_logo = None #
# html_logo = None
# The name of an image file (relative to this directory) to use as a favicon of # The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
#html_favicon = None #
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
@ -216,64 +232,79 @@ html_static_path = ['%(dot)sstatic']
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied # .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation. # directly to the root of the documentation.
#html_extra_path = [] #
# html_extra_path = []
# If not None, a 'Last updated on:' timestamp is inserted at every page # If not None, a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format. # bottom, using the given strftime format.
# The empty string is equivalent to '%%b %%d, %%Y'. # The empty string is equivalent to '%%b %%d, %%Y'.
#html_last_updated_fmt = None #
# html_last_updated_fmt = None
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.
#html_use_smartypants = True #
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # Custom sidebar templates, maps document names to template names.
#html_sidebars = {} #
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.
#html_additional_pages = {} #
# html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_domain_indices = True #
# html_domain_indices = True
# If false, no index is generated. # If false, no index is generated.
#html_use_index = True #
# html_use_index = True
# If true, the index is split into individual pages for each letter. # If true, the index is split into individual pages for each letter.
#html_split_index = False #
# html_split_index = False
# If true, links to the reST sources are added to the pages. # If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True #
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True #
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True #
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will # If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the # contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served. # base URL from which the finished HTML is served.
#html_use_opensearch = '' #
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml"). # This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None # html_file_suffix = None
# Language to be used for generating the HTML full-text search index. # Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages: # Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
#html_search_language = 'en' #
# html_search_language = 'en'
# A dictionary with options for the search language support, empty by default. # A dictionary with options for the search language support, empty by default.
# 'ja' uses this config value. # 'ja' uses this config value.
# 'zh' user can custom change `jieba` dictionary path. # 'zh' user can custom change `jieba` dictionary path.
#html_search_options = {'type': 'default'} #
# html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that # The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used. # implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js' #
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = '%(project_fn)sdoc' htmlhelp_basename = '%(project_fn)sdoc'
@ -281,17 +312,21 @@ htmlhelp_basename = '%(project_fn)sdoc'
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper', #
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt', #
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#'preamble': '', #
# 'preamble': '',
# Latex figure (float) alignment # Latex figure (float) alignment
#'figure_align': 'htbp', #
# 'figure_align': 'htbp',
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
@ -304,23 +339,29 @@ latex_documents = [
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
#latex_logo = None #
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts, # For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters. # not chapters.
#latex_use_parts = False #
# latex_use_parts = False
# If true, show page references after internal links. # If true, show page references after internal links.
#latex_show_pagerefs = False #
# latex_show_pagerefs = False
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#latex_show_urls = False #
# latex_show_urls = False
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#latex_appendices = [] #
# latex_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#latex_domain_indices = True #
# latex_domain_indices = True
# -- Options for manual page output --------------------------------------- # -- Options for manual page output ---------------------------------------
@ -333,7 +374,8 @@ man_pages = [
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#man_show_urls = False #
# man_show_urls = False
# -- Options for Texinfo output ------------------------------------------- # -- Options for Texinfo output -------------------------------------------
@ -348,16 +390,20 @@ texinfo_documents = [
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#texinfo_appendices = [] #
# texinfo_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#texinfo_domain_indices = True #
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'. # How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote' #
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu. # If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False #
# texinfo_no_detailmenu = False
''' '''
EPUB_CONFIG = u''' EPUB_CONFIG = u'''
@ -371,65 +417,80 @@ epub_publisher = author
epub_copyright = copyright epub_copyright = copyright
# The basename for the epub file. It defaults to the project name. # The basename for the epub file. It defaults to the project name.
#epub_basename = project # epub_basename = project
# The HTML theme for the epub output. Since the default themes are not # The HTML theme for the epub output. Since the default themes are not
# optimized for small screen space, using the same theme for HTML and epub # optimized for small screen space, using the same theme for HTML and epub
# output is usually not wise. This defaults to 'epub', a theme designed to save # output is usually not wise. This defaults to 'epub', a theme designed to save
# visual space. # visual space.
#epub_theme = 'epub' #
# epub_theme = 'epub'
# The language of the text. It defaults to the language option # The language of the text. It defaults to the language option
# or 'en' if the language is not set. # or 'en' if the language is not set.
#epub_language = '' #
# epub_language = ''
# The scheme of the identifier. Typical schemes are ISBN or URL. # The scheme of the identifier. Typical schemes are ISBN or URL.
#epub_scheme = '' # epub_scheme = ''
# The unique identifier of the text. This can be a ISBN number # The unique identifier of the text. This can be a ISBN number
# or the project homepage. # or the project homepage.
#epub_identifier = '' #
# epub_identifier = ''
# A unique identification for the text. # A unique identification for the text.
#epub_uid = '' #
# epub_uid = ''
# A tuple containing the cover image and cover page html template filenames. # A tuple containing the cover image and cover page html template filenames.
#epub_cover = () #
# epub_cover = ()
# A sequence of (type, uri, title) tuples for the guide element of content.opf. # A sequence of (type, uri, title) tuples for the guide element of content.opf.
#epub_guide = () #
# epub_guide = ()
# HTML files that should be inserted before the pages created by sphinx. # HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title. # The format is a list of tuples containing the path and title.
#epub_pre_files = [] #
# epub_pre_files = []
# HTML files that should be inserted after the pages created by sphinx. # HTML files that should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title. # The format is a list of tuples containing the path and title.
#epub_post_files = [] #
# epub_post_files = []
# A list of files that should not be packed into the epub file. # A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html'] epub_exclude_files = ['search.html']
# The depth of the table of contents in toc.ncx. # The depth of the table of contents in toc.ncx.
#epub_tocdepth = 3 #
# epub_tocdepth = 3
# Allow duplicate toc entries. # Allow duplicate toc entries.
#epub_tocdup = True #
# epub_tocdup = True
# Choose between 'default' and 'includehidden'. # Choose between 'default' and 'includehidden'.
#epub_tocscope = 'default' #
# epub_tocscope = 'default'
# Fix unsupported image types using the Pillow. # Fix unsupported image types using the Pillow.
#epub_fix_images = False #
# epub_fix_images = False
# Scale large images. # Scale large images.
#epub_max_image_width = 0 #
# epub_max_image_width = 0
# How to display URL addresses: 'footnote', 'no', or 'inline'. # How to display URL addresses: 'footnote', 'no', or 'inline'.
#epub_show_urls = 'inline' #
# epub_show_urls = 'inline'
# If false, no index is generated. # If false, no index is generated.
#epub_use_index = True #
# epub_use_index = True
''' '''
INTERSPHINX_CONFIG = u''' INTERSPHINX_CONFIG = u'''

View File

@ -152,99 +152,63 @@
\newcommand*{\sphinxAtStartFootnote}{\mbox{ }} \newcommand*{\sphinxAtStartFootnote}{\mbox{ }}
% Redefine the Verbatim environment to allow border and background colors. % Redefine the Verbatim environment to allow border and background colors
% and to handle the top caption in a non separable by pagebreak way.
% The original environment is still used for verbatims within tables. % The original environment is still used for verbatims within tables.
\let\OriginalVerbatim=\Verbatim \let\OriginalVerbatim=\Verbatim
\let\endOriginalVerbatim=\endVerbatim \let\endOriginalVerbatim=\endVerbatim
% Play with vspace to be able to keep the indentation. \newcommand\Sphinx@colorbox [2]{%
\newlength\Sphinx@scratchlength % #1 will be \fcolorbox or, for first part of frame: \Sphinx@fcolorbox
\newcommand\Sphinxcolorbox [1]{% #1{VerbatimBorderColor}{VerbatimColor}{%
\setlength\Sphinx@scratchlength{\linewidth}% % adjust width to be able to handle indentation.
\advance\Sphinx@scratchlength -\@totalleftmargin % \begin{minipage}{\dimexpr\linewidth-\@totalleftmargin\relax}%
\fcolorbox{VerbatimBorderColor}{VerbatimColor}{% #2%
\begin{minipage}{\Sphinx@scratchlength}%
#1
\end{minipage}% \end{minipage}%
}% }%
} }
% used for split frames for continuation on next and final page % use of \color@b@x here is compatible with both xcolor.sty and color.sty
\def\MidFrameCommand{\Sphinxcolorbox} \def\Sphinx@fcolorbox #1#2%
\let\LastFrameCommand\MidFrameCommand {\color@b@x {\fboxsep\z@\color{#1}\Sphinx@VerbatimFBox}{\color{#2}}}%
% We customize \FrameCommand (for non split frames) and \FirstFrameCommand
% (split frames), in order for the framed environment to insert a Title above
% the frame, which can not be separated by a pagebreak.
% The title is specified from outside as macro \SphinxVerbatimTitle. % The title is specified from outside as macro \SphinxVerbatimTitle.
% \SphinxVerbatimTitle is reset to empty after each use of Verbatim environment. % \SphinxVerbatimTitle is reset to empty after each use of Verbatim.
% It is also possible to use directly framed environment (i.e. not indirectly
% via the Verbatim environment next), then it is \SphinxFrameTitle which specifies
% the title.
\newcommand*\SphinxFrameTitle {}
\newcommand*\SphinxVerbatimTitle {} \newcommand*\SphinxVerbatimTitle {}
% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
\newcommand*\SphinxLiteralBlockLabel {}
\newcommand*\SphinxSetupCaptionForVerbatim [2] \newcommand*\SphinxSetupCaptionForVerbatim [2]
{% {%
\needspace{\literalblockneedspace}\vspace{\literalblockcaptiontopvspace}% \needspace{\literalblockneedspace}\vspace{\literalblockcaptiontopvspace}%
% insert a \label via \SphinxLiteralBlockLabel
% reset to normal the color for the literal block caption
\def\SphinxVerbatimTitle \def\SphinxVerbatimTitle
{\captionof{#1}{\SphinxLiteralBlockLabel #2}\smallskip }% {\py@NormalColor\captionof{#1}{\SphinxLiteralBlockLabel #2}\smallskip }%
} }
% \SphinxLiteralBlockLabel will be set dynamically to hold the label for links
\newcommand*\SphinxLiteralBlockLabel {}
% \SphinxCustomFBox is copied from framed.sty's \CustomFBox, but % Inspired and adapted from framed.sty's \CustomFBox with extra handling
% #1=title/caption is to be set _above_ the top rule, not _below_ % of a non separable by pagebreak caption, and controlled counter stepping.
% #1 must be "vertical material", it may be left empty.
% The amsmath patches \stepcounter to inhibit stepping under
% \firstchoice@false. We use it because framed.sty typesets multiple
% times its contents.
\newif\ifSphinx@myfirstframedpass \newif\ifSphinx@myfirstframedpass
\long\def\SphinxCustomFBox#1#2#3#4#5#6#7{% \long\def\Sphinx@VerbatimFBox#1{%
% we set up amsmath (amstext.sty) conditional to inhibit counter stepping \leavevmode
% except in first pass \begingroup
\ifSphinx@myfirstframedpass\firstchoice@true \ifSphinx@myfirstframedpass\else\firstchoice@false\fi
\else\firstchoice@false\fi \setbox\@tempboxa\hbox{\kern\fboxsep{#1}\kern\fboxsep}%
\leavevmode\begingroup \hbox
\setbox\@tempboxa\hbox{% {\lower\dimexpr\fboxrule+\fboxsep+\dp\@tempboxa
\color@begingroup \hbox{%
\kern\fboxsep{#7}\kern\fboxsep \vbox{\ifx\SphinxVerbatimTitle\empty\else{\SphinxVerbatimTitle}\fi
\color@endgroup}% \hrule\@height\fboxrule\relax
\hbox{% \hbox{\vrule\@width\fboxrule\relax
\lower\dimexpr#4+\fboxsep+\dp\@tempboxa\hbox{% \vbox{\vskip\fboxsep\copy\@tempboxa\vskip\fboxsep}%
\vbox{% \vrule\@width\fboxrule\relax}%
#1% TITLE \hrule\@height\fboxrule\relax}%
\hrule\@height#3\relax }}%
\hbox{%
\vrule\@width#5\relax
\vbox{%
\vskip\fboxsep
\copy\@tempboxa
\vskip\fboxsep}%
\vrule\@width#6\relax}%
#2%
\hrule\@height#4\relax}%
}%
}%
\endgroup \endgroup
% amsmath conditional inhibits counter stepping after first pass.
\global\Sphinx@myfirstframedpassfalse \global\Sphinx@myfirstframedpassfalse
} }
% for non split frames:
\def\FrameCommand{%
% this is inspired from framed.sty v 0.96 2011/10/22 lines 185--190
% \fcolorbox (see \Sphinxcolorbox above) from color.sty uses \fbox.
\def\fbox{\SphinxCustomFBox{\SphinxFrameTitle}{}%
\fboxrule\fboxrule\fboxrule\fboxrule}%
% \fcolorbox from xcolor.sty may use rather \XC@fbox.
\let\XC@fbox\fbox
\Sphinxcolorbox
}
% for first portion of split frames:
\let\FirstFrameCommand\FrameCommand
\renewcommand{\Verbatim}[1][1]{% \renewcommand{\Verbatim}[1][1]{%
% list starts new par, but we don't want it to be set apart vertically % list starts new par, but we don't want it to be set apart vertically
\parskip\z@skip \parskip\z@skip
@ -260,14 +224,21 @@
\fi \fi
\fi \fi
% non-empty \SphinxVerbatimTitle has label inside it (in case there is one) % non-empty \SphinxVerbatimTitle has label inside it (in case there is one)
\let\SphinxFrameTitle\SphinxVerbatimTitle % Customize framed.sty \MakeFramed to glue caption to literal block
\global\Sphinx@myfirstframedpasstrue \global\Sphinx@myfirstframedpasstrue
% via \Sphinx@fcolorbox, will use \Sphinx@VerbatimFBox which inserts title
\def\FrameCommand {\Sphinx@colorbox\Sphinx@fcolorbox }%
\let\FirstFrameCommand\FrameCommand
% for mid pages and last page portion of (long) split frame:
\def\MidFrameCommand{\Sphinx@colorbox\fcolorbox }%
\let\LastFrameCommand\MidFrameCommand
% The list environement is needed to control perfectly the vertical % The list environement is needed to control perfectly the vertical
% space. % space.
\list{}{% \list{}{%
\setlength\parskip{0pt}% \setlength\parskip{0pt}%
\setlength\itemsep{0ex}% \setlength\itemsep{0ex}%
\setlength\topsep{0ex}% \setlength\topsep{0ex}%
\setlength\parsep{0pt}% let's not forget this one!
\setlength\partopsep{0pt}% \setlength\partopsep{0pt}%
\setlength\leftmargin{0pt}% \setlength\leftmargin{0pt}%
}% }%

View File

@ -127,6 +127,8 @@ class ExtBabel(Babel):
'es', 'spanish', 'nl', 'dutch', 'pl', 'polish', 'it', 'es', 'spanish', 'nl', 'dutch', 'pl', 'polish', 'it',
'italian'): 'italian'):
return '\\shorthandoff{"}' return '\\shorthandoff{"}'
elif shortlang in ('tr', 'turkish'):
return '\\shorthandoff{=}'
return '' return ''
def uses_cyrillic(self): def uses_cyrillic(self):

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -271,6 +271,7 @@ def test_babel_with_no_language_settings(app, status, warning):
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig. }}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table. }}\n' in result
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
assert '\\shorthandoff' not in result
@with_app(buildername='latex', testroot='latex-babel', @with_app(buildername='latex', testroot='latex-babel',
@ -290,6 +291,7 @@ def test_babel_with_language_de(app, status, warning):
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig. }}\n' in result
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table. }}\n' in result
assert '\\addto\\extrasngerman{\\def\\pageautorefname{page}}\n' in result assert '\\addto\\extrasngerman{\\def\\pageautorefname{page}}\n' in result
assert '\\shorthandoff{"}' in result
@with_app(buildername='latex', testroot='latex-babel', @with_app(buildername='latex', testroot='latex-babel',
@ -309,6 +311,27 @@ def test_babel_with_language_ru(app, status, warning):
assert '\\addto\\captionsrussian{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsrussian{\\renewcommand{\\figurename}{Fig. }}\n' in result
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table. }}\n' in result
assert '\\addto\\extrasrussian{\\def\\pageautorefname{page}}\n' in result assert '\\addto\\extrasrussian{\\def\\pageautorefname{page}}\n' in result
assert '\\shorthandoff' not in result
@with_app(buildername='latex', testroot='latex-babel',
confoverrides={'language': 'tr'})
def test_babel_with_language_tr(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
assert '\\documentclass[letterpaper,10pt,turkish]{sphinxmanual}' in result
assert '\\usepackage{babel}' in result
assert '\\usepackage{times}' in result
assert '\\usepackage[Sonny]{fncychap}' in result
assert ('\\addto\\captionsturkish{\\renewcommand{\\contentsname}{Table of content}}\n'
in result)
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig. }}\n' in result
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table. }}\n' in result
assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result
assert '\\shorthandoff{=}' in result
@with_app(buildername='latex', testroot='latex-babel', @with_app(buildername='latex', testroot='latex-babel',
@ -327,6 +350,7 @@ def test_babel_with_language_ja(app, status, warning):
assert '\\renewcommand{\\figurename}{Fig. }\n' in result assert '\\renewcommand{\\figurename}{Fig. }\n' in result
assert '\\renewcommand{\\tablename}{Table. }\n' in result assert '\\renewcommand{\\tablename}{Table. }\n' in result
assert u'\\def\\pageautorefname{ページ}\n' in result assert u'\\def\\pageautorefname{ページ}\n' in result
assert '\\shorthandoff' not in result
@with_app(buildername='latex', testroot='latex-babel', @with_app(buildername='latex', testroot='latex-babel',
@ -346,6 +370,7 @@ def test_babel_with_unknown_language(app, status, warning):
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig. }}\n' in result
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table. }}\n' in result
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
assert '\\shorthandoff' not in result
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue() assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()

View File

@ -71,3 +71,21 @@ def test_math_number_all_latex(app, status, warning):
app.builder.build_all() app.builder.build_all()
content = (app.outdir / 'test.tex').text() content = (app.outdir / 'test.tex').text()
macro = (r'\\begin{equation\*}\s*'
r'\\begin{split}a\^2\+b\^2=c\^2\\end{split}\s*'
r'\\end{equation\*}')
assert re.search(macro, content, re.S)
macro = r'Inline \\\(E=mc\^2\\\)'
assert re.search(macro, content, re.S)
macro = (r'\\begin{equation\*}\s*'
r'\\begin{split}e\^{i\\pi}\+1=0\\end{split}\s+'
r'\\end{equation\*}')
assert re.search(macro, content, re.S)
macro = (r'\\begin{align\*}\\!\\begin{aligned}\s*'
r'S &= \\pi r\^2\\\\\s*'
r'V &= \\frac\{4}\{3} \\pi r\^3\\\\\s*'
r'\\end{aligned}\\end{align\*}')
assert re.search(macro, content, re.S)