mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Replace a and b or c
by the more legible b if a or c
.
This commit is contained in:
parent
acdcf81599
commit
814513ba9f
@ -355,8 +355,8 @@ class Sphinx:
|
|||||||
if self._warncount and self.keep_going:
|
if self._warncount and self.keep_going:
|
||||||
self.statuscode = 1
|
self.statuscode = 1
|
||||||
|
|
||||||
status = (self.statuscode == 0 and
|
status = (__('succeeded') if self.statuscode == 0
|
||||||
__('succeeded') or __('finished with problems'))
|
else __('finished with problems'))
|
||||||
if self._warncount:
|
if self._warncount:
|
||||||
if self.warningiserror:
|
if self.warningiserror:
|
||||||
msg = __('build %s, %s warning (with warnings treated as errors).',
|
msg = __('build %s, %s warning (with warnings treated as errors).',
|
||||||
@ -511,7 +511,7 @@ class Sphinx:
|
|||||||
logger.debug('[app] adding config value: %r',
|
logger.debug('[app] adding config value: %r',
|
||||||
(name, default, rebuild) + ((types,) if types else ())) # type: ignore
|
(name, default, rebuild) + ((types,) if types else ())) # type: ignore
|
||||||
if rebuild in (False, True):
|
if rebuild in (False, True):
|
||||||
rebuild = rebuild and 'env' or ''
|
rebuild = 'env' if rebuild else ''
|
||||||
self.config.add(name, default, rebuild, types)
|
self.config.add(name, default, rebuild, types)
|
||||||
|
|
||||||
def add_event(self, name):
|
def add_event(self, name):
|
||||||
|
@ -461,11 +461,8 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
else:
|
else:
|
||||||
self.last_updated = None
|
self.last_updated = None
|
||||||
|
|
||||||
logo = self.config.html_logo and \
|
logo = path.basename(self.config.html_logo) if self.config.html_logo else ''
|
||||||
path.basename(self.config.html_logo) or ''
|
favicon = path.basename(self.config.html_favicon) if self.config.html_favicon else ''
|
||||||
|
|
||||||
favicon = self.config.html_favicon and \
|
|
||||||
path.basename(self.config.html_favicon) or ''
|
|
||||||
|
|
||||||
if not isinstance(self.config.html_use_opensearch, str):
|
if not isinstance(self.config.html_use_opensearch, str):
|
||||||
logger.warning(__('html_use_opensearch config value must now be a string'))
|
logger.warning(__('html_use_opensearch config value must now be a string'))
|
||||||
@ -567,7 +564,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
|
|
||||||
# title rendered as HTML
|
# title rendered as HTML
|
||||||
title_node = self.env.longtitles.get(docname)
|
title_node = self.env.longtitles.get(docname)
|
||||||
title = title_node and self.render_partial(title_node)['title'] or ''
|
title = self.render_partial(title_node)['title'] if title_node else ''
|
||||||
|
|
||||||
# Suffix for the document
|
# Suffix for the document
|
||||||
source_suffix = path.splitext(self.env.doc2path(docname))[1]
|
source_suffix = path.splitext(self.env.doc2path(docname))[1]
|
||||||
@ -624,7 +621,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
self.imgpath = relative_uri(self.get_target_uri(docname), self.imagedir)
|
self.imgpath = relative_uri(self.get_target_uri(docname), self.imagedir)
|
||||||
self.post_process_images(doctree)
|
self.post_process_images(doctree)
|
||||||
title_node = self.env.longtitles.get(docname)
|
title_node = self.env.longtitles.get(docname)
|
||||||
title = title_node and self.render_partial(title_node)['title'] or ''
|
title = self.render_partial(title_node)['title'] if title_node else ''
|
||||||
self.index_page(docname, doctree, title)
|
self.index_page(docname, doctree, title)
|
||||||
|
|
||||||
def finish(self) -> None:
|
def finish(self) -> None:
|
||||||
|
@ -243,7 +243,7 @@ class LaTeXBuilder(Builder):
|
|||||||
|
|
||||||
doctree = self.assemble_doctree(
|
doctree = self.assemble_doctree(
|
||||||
docname, toctree_only,
|
docname, toctree_only,
|
||||||
appendices=((docclass != 'howto') and self.config.latex_appendices or []))
|
appendices=(self.config.latex_appendices if docclass != 'howto' else []))
|
||||||
doctree['tocdepth'] = tocdepth
|
doctree['tocdepth'] = tocdepth
|
||||||
self.post_process_images(doctree)
|
self.post_process_images(doctree)
|
||||||
self.update_doc_context(title, author)
|
self.update_doc_context(title, author)
|
||||||
|
@ -366,7 +366,7 @@ def generate(d: Dict, overwrite: bool = True, silent: bool = False, templatedir:
|
|||||||
|
|
||||||
ensuredir(d['path'])
|
ensuredir(d['path'])
|
||||||
|
|
||||||
srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']
|
srcdir = path.join(d['path'], 'source') if d['sep'] else d['path']
|
||||||
|
|
||||||
ensuredir(srcdir)
|
ensuredir(srcdir)
|
||||||
if d['sep']:
|
if d['sep']:
|
||||||
@ -412,15 +412,15 @@ def generate(d: Dict, overwrite: bool = True, silent: bool = False, templatedir:
|
|||||||
batchfile_template = 'quickstart/make.bat_t'
|
batchfile_template = 'quickstart/make.bat_t'
|
||||||
|
|
||||||
if d['makefile'] is True:
|
if d['makefile'] is True:
|
||||||
d['rsrcdir'] = d['sep'] and 'source' or '.'
|
d['rsrcdir'] = 'source' if d['sep'] else '.'
|
||||||
d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
|
d['rbuilddir'] = 'build' if d['sep'] else d['dot'] + 'build'
|
||||||
# use binary mode, to avoid writing \r\n on Windows
|
# use binary mode, to avoid writing \r\n on Windows
|
||||||
write_file(path.join(d['path'], 'Makefile'),
|
write_file(path.join(d['path'], 'Makefile'),
|
||||||
template.render(makefile_template, d), '\n')
|
template.render(makefile_template, d), '\n')
|
||||||
|
|
||||||
if d['batchfile'] is True:
|
if d['batchfile'] is True:
|
||||||
d['rsrcdir'] = d['sep'] and 'source' or '.'
|
d['rsrcdir'] = 'source' if d['sep'] else '.'
|
||||||
d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
|
d['rbuilddir'] = 'build' if d['sep'] else d['dot'] + 'build'
|
||||||
write_file(path.join(d['path'], 'make.bat'),
|
write_file(path.join(d['path'], 'make.bat'),
|
||||||
template.render(batchfile_template, d), '\r\n')
|
template.render(batchfile_template, d), '\r\n')
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ class HList(SphinxDirective):
|
|||||||
index = 0
|
index = 0
|
||||||
newnode = addnodes.hlist()
|
newnode = addnodes.hlist()
|
||||||
for column in range(ncolumns):
|
for column in range(ncolumns):
|
||||||
endindex = index + (column < nmore and (npercol + 1) or npercol)
|
endindex = index + ((npercol + 1) if column < nmore else npercol)
|
||||||
bullet_list = nodes.bullet_list()
|
bullet_list = nodes.bullet_list()
|
||||||
bullet_list += fulllist.children[index:endindex]
|
bullet_list += fulllist.children[index:endindex]
|
||||||
newnode += addnodes.hlistcol('', bullet_list)
|
newnode += addnodes.hlistcol('', bullet_list)
|
||||||
|
@ -105,7 +105,7 @@ class JSObject(ObjectDescription):
|
|||||||
def add_target_and_index(self, name_obj: Tuple[str, str], sig: str,
|
def add_target_and_index(self, name_obj: Tuple[str, str], sig: str,
|
||||||
signode: desc_signature) -> None:
|
signode: desc_signature) -> None:
|
||||||
mod_name = self.env.ref_context.get('js:module')
|
mod_name = self.env.ref_context.get('js:module')
|
||||||
fullname = (mod_name and mod_name + '.' or '') + name_obj[0]
|
fullname = (mod_name + '.' if mod_name else '') + name_obj[0]
|
||||||
if fullname not in self.state.document.ids:
|
if fullname not in self.state.document.ids:
|
||||||
signode['names'].append(fullname)
|
signode['names'].append(fullname)
|
||||||
signode['ids'].append(fullname.replace('$', '_S_'))
|
signode['ids'].append(fullname.replace('$', '_S_'))
|
||||||
@ -385,7 +385,7 @@ class JavaScriptDomain(Domain):
|
|||||||
) -> Element:
|
) -> Element:
|
||||||
mod_name = node.get('js:module')
|
mod_name = node.get('js:module')
|
||||||
prefix = node.get('js:object')
|
prefix = node.get('js:object')
|
||||||
searchorder = node.hasattr('refspecific') and 1 or 0
|
searchorder = 1 if node.hasattr('refspecific') else 0
|
||||||
name, obj = self.find_obj(env, mod_name, prefix, target, typ, searchorder)
|
name, obj = self.find_obj(env, mod_name, prefix, target, typ, searchorder)
|
||||||
if not obj:
|
if not obj:
|
||||||
return None
|
return None
|
||||||
|
@ -315,7 +315,7 @@ class PyObject(ObjectDescription):
|
|||||||
def add_target_and_index(self, name_cls: Tuple[str, str], sig: str,
|
def add_target_and_index(self, name_cls: Tuple[str, str], sig: str,
|
||||||
signode: desc_signature) -> None:
|
signode: desc_signature) -> None:
|
||||||
modname = self.options.get('module', self.env.ref_context.get('py:module'))
|
modname = self.options.get('module', self.env.ref_context.get('py:module'))
|
||||||
fullname = (modname and modname + '.' or '') + name_cls[0]
|
fullname = (modname + '.' if modname else '') + name_cls[0]
|
||||||
# note target
|
# note target
|
||||||
if fullname not in self.state.document.ids:
|
if fullname not in self.state.document.ids:
|
||||||
signode['names'].append(fullname)
|
signode['names'].append(fullname)
|
||||||
@ -830,7 +830,7 @@ class PythonModuleIndex(Index):
|
|||||||
num_toplevels += 1
|
num_toplevels += 1
|
||||||
subtype = 0
|
subtype = 0
|
||||||
|
|
||||||
qualifier = deprecated and _('Deprecated') or ''
|
qualifier = _('Deprecated') if deprecated else ''
|
||||||
entries.append(IndexEntry(stripped + modname, subtype, docname,
|
entries.append(IndexEntry(stripped + modname, subtype, docname,
|
||||||
'module-' + stripped + modname, platforms,
|
'module-' + stripped + modname, platforms,
|
||||||
qualifier, synopsis))
|
qualifier, synopsis))
|
||||||
@ -1008,7 +1008,7 @@ class PythonDomain(Domain):
|
|||||||
) -> Element:
|
) -> Element:
|
||||||
modname = node.get('py:module')
|
modname = node.get('py:module')
|
||||||
clsname = node.get('py:class')
|
clsname = node.get('py:class')
|
||||||
searchmode = node.hasattr('refspecific') and 1 or 0
|
searchmode = 1 if node.hasattr('refspecific') else 0
|
||||||
matches = self.find_obj(env, modname, clsname, target,
|
matches = self.find_obj(env, modname, clsname, target,
|
||||||
type, searchmode)
|
type, searchmode)
|
||||||
if not matches:
|
if not matches:
|
||||||
|
@ -252,7 +252,7 @@ class TocTree:
|
|||||||
|
|
||||||
# prune the tree to maxdepth, also set toc depth and current classes
|
# prune the tree to maxdepth, also set toc depth and current classes
|
||||||
_toctree_add_classes(newnode, 1)
|
_toctree_add_classes(newnode, 1)
|
||||||
self._toctree_prune(newnode, 1, prune and maxdepth or 0, collapse)
|
self._toctree_prune(newnode, 1, maxdepth if prune else 0, collapse)
|
||||||
|
|
||||||
if isinstance(newnode[-1], nodes.Element) and len(newnode[-1]) == 0: # No titles found
|
if isinstance(newnode[-1], nodes.Element) and len(newnode[-1]) == 0: # No titles found
|
||||||
return None
|
return None
|
||||||
|
@ -295,7 +295,7 @@ class Documenter:
|
|||||||
# support explicit module and class name separation via ::
|
# support explicit module and class name separation via ::
|
||||||
if explicit_modname is not None:
|
if explicit_modname is not None:
|
||||||
modname = explicit_modname[:-2]
|
modname = explicit_modname[:-2]
|
||||||
parents = path and path.rstrip('.').split('.') or []
|
parents = path.rstrip('.').split('.') if path else []
|
||||||
else:
|
else:
|
||||||
modname = None
|
modname = None
|
||||||
parents = []
|
parents = []
|
||||||
@ -308,7 +308,7 @@ class Documenter:
|
|||||||
self.args = args
|
self.args = args
|
||||||
self.retann = retann
|
self.retann = retann
|
||||||
self.fullname = (self.modname or '') + \
|
self.fullname = (self.modname or '') + \
|
||||||
(self.objpath and '.' + '.'.join(self.objpath) or '')
|
('.' + '.'.join(self.objpath) if self.objpath else '')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def import_object(self) -> bool:
|
def import_object(self) -> bool:
|
||||||
@ -399,7 +399,7 @@ class Documenter:
|
|||||||
args, retann = result
|
args, retann = result
|
||||||
|
|
||||||
if args is not None:
|
if args is not None:
|
||||||
return args + (retann and (' -> %s' % retann) or '')
|
return args + ((' -> %s' % retann) if retann else '')
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@ -1103,9 +1103,9 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
sourcename = self.get_sourcename()
|
sourcename = self.get_sourcename()
|
||||||
self.add_line('', sourcename)
|
self.add_line('', sourcename)
|
||||||
if hasattr(self.object, '__bases__') and len(self.object.__bases__):
|
if hasattr(self.object, '__bases__') and len(self.object.__bases__):
|
||||||
bases = [b.__module__ in ('__builtin__', 'builtins') and
|
bases = [':class:`%s`' % b.__name__
|
||||||
':class:`%s`' % b.__name__ or
|
if b.__module__ in ('__builtin__', 'builtins')
|
||||||
':class:`%s.%s`' % (b.__module__, b.__name__)
|
else ':class:`%s.%s`' % (b.__module__, b.__name__)
|
||||||
for b in self.object.__bases__]
|
for b in self.object.__bases__]
|
||||||
self.add_line(' ' + _('Bases: %s') % ', '.join(bases),
|
self.add_line(' ' + _('Bases: %s') % ', '.join(bases),
|
||||||
sourcename)
|
sourcename)
|
||||||
|
@ -722,7 +722,7 @@ def process_generate_options(app: Sphinx) -> None:
|
|||||||
if os.path.isfile(env.doc2path(x))]
|
if os.path.isfile(env.doc2path(x))]
|
||||||
else:
|
else:
|
||||||
ext = list(app.config.source_suffix)
|
ext = list(app.config.source_suffix)
|
||||||
genfiles = [genfile + (not genfile.endswith(tuple(ext)) and ext[0] or '')
|
genfiles = [genfile + (ext[0] if not genfile.endswith(tuple(ext)) else '')
|
||||||
for genfile in genfiles]
|
for genfile in genfiles]
|
||||||
|
|
||||||
for entry in genfiles[:]:
|
for entry in genfiles[:]:
|
||||||
|
@ -326,7 +326,7 @@ class DocTestBuilder(Builder):
|
|||||||
def finish(self) -> None:
|
def finish(self) -> None:
|
||||||
# write executive summary
|
# write executive summary
|
||||||
def s(v: int) -> str:
|
def s(v: int) -> str:
|
||||||
return v != 1 and 's' or ''
|
return 's' if v != 1 else ''
|
||||||
repl = (self.total_tries, s(self.total_tries),
|
repl = (self.total_tries, s(self.total_tries),
|
||||||
self.total_failures, s(self.total_failures),
|
self.total_failures, s(self.total_failures),
|
||||||
self.setup_failures, s(self.setup_failures),
|
self.setup_failures, s(self.setup_failures),
|
||||||
@ -523,8 +523,8 @@ Doctest summary
|
|||||||
self.type = 'single' # as for ordinary doctests
|
self.type = 'single' # as for ordinary doctests
|
||||||
else:
|
else:
|
||||||
# testcode and output separate
|
# testcode and output separate
|
||||||
output = code[1] and code[1].code or ''
|
output = code[1].code if code[1] else ''
|
||||||
options = code[1] and code[1].options or {}
|
options = code[1].options if code[1] else {}
|
||||||
# disable <BLANKLINE> processing as it is not needed
|
# disable <BLANKLINE> processing as it is not needed
|
||||||
options[doctest.DONT_ACCEPT_BLANKLINE] = True
|
options[doctest.DONT_ACCEPT_BLANKLINE] = True
|
||||||
# find out if we're testing an exception
|
# find out if we're testing an exception
|
||||||
|
@ -176,7 +176,7 @@ def fetch_inventory(app: Sphinx, uri: str, inv: Any) -> Any:
|
|||||||
uri = path.dirname(newinv)
|
uri = path.dirname(newinv)
|
||||||
with f:
|
with f:
|
||||||
try:
|
try:
|
||||||
join = localuri and path.join or posixpath.join
|
join = path.join if localuri else posixpath.join
|
||||||
invdata = InventoryFile.load(f, uri, join)
|
invdata = InventoryFile.load(f, uri, join)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise ValueError('unknown or unsupported inventory version: %r' % exc)
|
raise ValueError('unknown or unsupported inventory version: %r' % exc)
|
||||||
@ -401,7 +401,7 @@ def inspect_main(argv: List[str]) -> None:
|
|||||||
print(key)
|
print(key)
|
||||||
for entry, einfo in sorted(invdata[key].items()):
|
for entry, einfo in sorted(invdata[key].items()):
|
||||||
print('\t%-40s %s%s' % (entry,
|
print('\t%-40s %s%s' % (entry,
|
||||||
einfo[3] != '-' and '%-40s: ' % einfo[3] or '',
|
'%-40s: ' % einfo[3] if einfo[3] != '-' else '',
|
||||||
einfo[2]))
|
einfo[2]))
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
print(exc.args[0] % exc.args[1:])
|
print(exc.args[0] % exc.args[1:])
|
||||||
|
@ -112,7 +112,7 @@ class GoogleDocstring:
|
|||||||
|
|
||||||
if not self._config:
|
if not self._config:
|
||||||
from sphinx.ext.napoleon import Config
|
from sphinx.ext.napoleon import Config
|
||||||
self._config = self._app and self._app.config or Config() # type: ignore
|
self._config = self._app.config if self._app else Config() # type: ignore
|
||||||
|
|
||||||
if not what:
|
if not what:
|
||||||
if inspect.isclass(obj):
|
if inspect.isclass(obj):
|
||||||
@ -385,7 +385,7 @@ class GoogleDocstring:
|
|||||||
def _format_field(self, _name: str, _type: str, _desc: List[str]) -> List[str]:
|
def _format_field(self, _name: str, _type: str, _desc: List[str]) -> List[str]:
|
||||||
_desc = self._strip_empty(_desc)
|
_desc = self._strip_empty(_desc)
|
||||||
has_desc = any(_desc)
|
has_desc = any(_desc)
|
||||||
separator = has_desc and ' -- ' or ''
|
separator = ' -- ' if has_desc else ''
|
||||||
if _name:
|
if _name:
|
||||||
if _type:
|
if _type:
|
||||||
if '`' in _type:
|
if '`' in _type:
|
||||||
|
@ -188,7 +188,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
|||||||
self.loaders = [SphinxFileSystemLoader(x) for x in loaderchain]
|
self.loaders = [SphinxFileSystemLoader(x) for x in loaderchain]
|
||||||
|
|
||||||
use_i18n = builder.app.translator is not None
|
use_i18n = builder.app.translator is not None
|
||||||
extensions = use_i18n and ['jinja2.ext.i18n'] or []
|
extensions = ['jinja2.ext.i18n'] if use_i18n else []
|
||||||
self.environment = SandboxedEnvironment(loader=self,
|
self.environment = SandboxedEnvironment(loader=self,
|
||||||
extensions=extensions)
|
extensions=extensions)
|
||||||
self.environment.filters['tobool'] = _tobool
|
self.environment.filters['tobool'] = _tobool
|
||||||
|
@ -296,7 +296,7 @@ class FilterSystemMessages(SphinxTransform):
|
|||||||
default_priority = 999
|
default_priority = 999
|
||||||
|
|
||||||
def apply(self, **kwargs) -> None:
|
def apply(self, **kwargs) -> None:
|
||||||
filterlevel = self.config.keep_warnings and 2 or 5
|
filterlevel = 2 if self.config.keep_warnings else 5
|
||||||
for node in self.document.traverse(nodes.system_message):
|
for node in self.document.traverse(nodes.system_message):
|
||||||
if node['level'] < filterlevel:
|
if node['level'] < filterlevel:
|
||||||
logger.debug('%s [filtered system message]', node.astext())
|
logger.debug('%s [filtered system message]', node.astext())
|
||||||
|
@ -155,7 +155,7 @@ class ReferencesResolver(SphinxPostTransform):
|
|||||||
if self.config.nitpicky:
|
if self.config.nitpicky:
|
||||||
warn = True
|
warn = True
|
||||||
if self.config.nitpick_ignore:
|
if self.config.nitpick_ignore:
|
||||||
dtype = domain and '%s:%s' % (domain.name, typ) or typ
|
dtype = '%s:%s' % (domain.name, typ) if domain else typ
|
||||||
if (dtype, target) in self.config.nitpick_ignore:
|
if (dtype, target) in self.config.nitpick_ignore:
|
||||||
warn = False
|
warn = False
|
||||||
# for "std" types also try without domain name
|
# for "std" types also try without domain name
|
||||||
|
@ -83,7 +83,7 @@ def dumps(obj: Any, key: bool = False) -> str:
|
|||||||
if obj is None:
|
if obj is None:
|
||||||
return 'null'
|
return 'null'
|
||||||
elif obj is True or obj is False:
|
elif obj is True or obj is False:
|
||||||
return obj and 'true' or 'false'
|
return 'true' if obj else 'false'
|
||||||
elif isinstance(obj, (int, float)):
|
elif isinstance(obj, (int, float)):
|
||||||
return str(obj)
|
return str(obj)
|
||||||
elif isinstance(obj, dict):
|
elif isinstance(obj, dict):
|
||||||
|
@ -90,7 +90,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
self.permalink_text = self.config.html_add_permalinks
|
self.permalink_text = self.config.html_add_permalinks
|
||||||
# support backwards-compatible setting to a bool
|
# support backwards-compatible setting to a bool
|
||||||
if not isinstance(self.permalink_text, str):
|
if not isinstance(self.permalink_text, str):
|
||||||
self.permalink_text = self.permalink_text and '¶' or ''
|
self.permalink_text = '¶' if self.permalink_text else ''
|
||||||
self.permalink_text = self.encode(self.permalink_text)
|
self.permalink_text = self.encode(self.permalink_text)
|
||||||
self.secnumber_suffix = self.config.html_secnumber_suffix
|
self.secnumber_suffix = self.config.html_secnumber_suffix
|
||||||
self.param_separator = ''
|
self.param_separator = ''
|
||||||
|
@ -62,7 +62,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
self.permalink_text = self.config.html_add_permalinks
|
self.permalink_text = self.config.html_add_permalinks
|
||||||
# support backwards-compatible setting to a bool
|
# support backwards-compatible setting to a bool
|
||||||
if not isinstance(self.permalink_text, str):
|
if not isinstance(self.permalink_text, str):
|
||||||
self.permalink_text = self.permalink_text and '¶' or ''
|
self.permalink_text = '¶' if self.permalink_text else ''
|
||||||
self.permalink_text = self.encode(self.permalink_text)
|
self.permalink_text = self.encode(self.permalink_text)
|
||||||
self.secnumber_suffix = self.config.html_secnumber_suffix
|
self.secnumber_suffix = self.config.html_secnumber_suffix
|
||||||
self.param_separator = ''
|
self.param_separator = ''
|
||||||
|
@ -699,7 +699,7 @@ class LaTeXTranslator(SphinxTranslator):
|
|||||||
def hypertarget(self, id: str, withdoc: bool = True, anchor: bool = True) -> str:
|
def hypertarget(self, id: str, withdoc: bool = True, anchor: bool = True) -> str:
|
||||||
if withdoc:
|
if withdoc:
|
||||||
id = self.curfilestack[-1] + ':' + id
|
id = self.curfilestack[-1] + ':' + id
|
||||||
return (anchor and '\\phantomsection' or '') + \
|
return ('\\phantomsection' if anchor else '') + \
|
||||||
'\\label{%s}' % self.idescape(id)
|
'\\label{%s}' % self.idescape(id)
|
||||||
|
|
||||||
def hypertarget_to(self, node: Element, anchor: bool = False) -> str:
|
def hypertarget_to(self, node: Element, anchor: bool = False) -> str:
|
||||||
@ -1525,7 +1525,7 @@ class LaTeXTranslator(SphinxTranslator):
|
|||||||
elif isinstance(node[0], nodes.image) and 'width' in node[0]:
|
elif isinstance(node[0], nodes.image) and 'width' in node[0]:
|
||||||
length = self.latex_image_length(node[0]['width'])
|
length = self.latex_image_length(node[0]['width'])
|
||||||
self.body.append('\\begin{wrapfigure}{%s}{%s}\n\\centering' %
|
self.body.append('\\begin{wrapfigure}{%s}{%s}\n\\centering' %
|
||||||
(node['align'] == 'right' and 'r' or 'l', length or '0pt'))
|
('r' if node['align'] == 'right' else 'l', length or '0pt'))
|
||||||
self.context.append('\\end{wrapfigure}\n')
|
self.context.append('\\end{wrapfigure}\n')
|
||||||
elif self.in_minipage:
|
elif self.in_minipage:
|
||||||
self.body.append('\n\\begin{center}')
|
self.body.append('\n\\begin{center}')
|
||||||
|
@ -242,7 +242,7 @@ class TexinfoTranslator(SphinxTranslator):
|
|||||||
title = self.settings.title # type: str
|
title = self.settings.title # type: str
|
||||||
if not title:
|
if not title:
|
||||||
title_node = self.document.next_node(nodes.title)
|
title_node = self.document.next_node(nodes.title)
|
||||||
title = (title_node and title_node.astext()) or '<untitled>'
|
title = title_node.astext() if title_node else '<untitled>'
|
||||||
elements['title'] = self.escape_id(title) or '<untitled>'
|
elements['title'] = self.escape_id(title) or '<untitled>'
|
||||||
# filename
|
# filename
|
||||||
if not elements['filename']:
|
if not elements['filename']:
|
||||||
@ -292,7 +292,7 @@ class TexinfoTranslator(SphinxTranslator):
|
|||||||
# each section is also a node
|
# each section is also a node
|
||||||
for section in self.document.traverse(nodes.section):
|
for section in self.document.traverse(nodes.section):
|
||||||
title = cast(nodes.TextElement, section.next_node(nodes.Titular))
|
title = cast(nodes.TextElement, section.next_node(nodes.Titular))
|
||||||
name = (title and title.astext()) or '<untitled>'
|
name = title.astext() if title else '<untitled>'
|
||||||
section['node_name'] = add_node_name(name)
|
section['node_name'] = add_node_name(name)
|
||||||
|
|
||||||
def collect_node_menus(self) -> None:
|
def collect_node_menus(self) -> None:
|
||||||
@ -306,7 +306,7 @@ class TexinfoTranslator(SphinxTranslator):
|
|||||||
node_menus[node['node_name']] = entries
|
node_menus[node['node_name']] = entries
|
||||||
# try to find a suitable "Top" node
|
# try to find a suitable "Top" node
|
||||||
title = self.document.next_node(nodes.title)
|
title = self.document.next_node(nodes.title)
|
||||||
top = (title and title.parent) or self.document
|
top = title.parent if title else self.document
|
||||||
if not isinstance(top, (nodes.document, nodes.section)):
|
if not isinstance(top, (nodes.document, nodes.section)):
|
||||||
top = self.document
|
top = self.document
|
||||||
if top is not self.document:
|
if top is not self.document:
|
||||||
|
Loading…
Reference in New Issue
Block a user