mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-13 00:42:11 -05:00
Remove deprecated items for Sphinx 6.0 (#10471)
This commit is contained in:
1 parent
7e68154e49
commit
ce31e1c0c7
34 files changed
+33
-13989
No files matched your search
@@ -6507,7 +6507,7 @@ Features added
|
||||
* HTML builder:
|
||||
|
||||
- Added ``pyramid`` theme.
|
||||
- #559: `html_add_permalinks` is now a string giving the
|
||||
- #559: ``html_add_permalinks`` is now a string giving the
|
||||
text to display in permalinks.
|
||||
- #259: HTML table rows now have even/odd CSS classes to enable
|
||||
"Zebra styling".
|
||||
|
||||
@@ -107,61 +107,6 @@ smartypants.py license::
|
||||
such damage.
|
||||
----------------------------------------------------------------------
|
||||
|
||||
The included JQuery JavaScript library is available under the MIT
|
||||
license:
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Copyright (c) 2008 John Resig, https://jquery.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------
|
||||
|
||||
The included Underscore JavaScript library is available under the MIT
|
||||
license:
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Copyright (c) 2009 Jeremy Ashkenas, DocumentCloud
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
The included implementation of NumpyDocstring._parse_numpydoc_see_also_section
|
||||
was derived from code under the following license:
|
||||
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@ epub_pre_files = [('index.xhtml', 'Welcome')]
|
||||
epub_post_files = [('usage/installation.xhtml', 'Installing Sphinx'),
|
||||
('develop.xhtml', 'Sphinx development')]
|
||||
epub_exclude_files = ['_static/opensearch.xml', '_static/doctools.js',
|
||||
'_static/jquery.js', '_static/searchtools.js',
|
||||
'_static/underscore.js', '_static/basic.css',
|
||||
'_static/searchtools.js',
|
||||
'_static/basic.css',
|
||||
'_static/language_data.js',
|
||||
'search.html', '_static/websupport.js']
|
||||
epub_fix_images = False
|
||||
|
||||
@@ -1017,20 +1017,6 @@ that use Sphinx's HTMLWriter class.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
.. confval:: html_codeblock_linenos_style
|
||||
|
||||
The style of line numbers for code-blocks.
|
||||
|
||||
* ``'table'`` -- display line numbers using ``<table>`` tag
|
||||
* ``'inline'`` -- display line numbers using ``<span>`` tag (default)
|
||||
|
||||
.. versionadded:: 3.2
|
||||
.. versionchanged:: 4.0
|
||||
|
||||
It defaults to ``'inline'``.
|
||||
|
||||
.. deprecated:: 4.0
|
||||
|
||||
.. confval:: html_context
|
||||
|
||||
A dictionary of values to pass into the template engine's context for all
|
||||
@@ -1181,24 +1167,6 @@ that use Sphinx's HTMLWriter class.
|
||||
.. deprecated:: 1.6
|
||||
To disable smart quotes, use rather :confval:`smartquotes`.
|
||||
|
||||
.. confval:: html_add_permalinks
|
||||
|
||||
Sphinx will add "permalinks" for each heading and description environment as
|
||||
paragraph signs that become visible when the mouse hovers over them.
|
||||
|
||||
This value determines the text for the permalink; it defaults to ``"¶"``.
|
||||
Set it to ``None`` or the empty string to disable permalinks.
|
||||
|
||||
.. versionadded:: 0.6
|
||||
Previously, this was always activated.
|
||||
|
||||
.. versionchanged:: 1.1
|
||||
This can now be a string to select the actual text of the link.
|
||||
Previously, only boolean values were accepted.
|
||||
|
||||
.. deprecated:: 3.5
|
||||
This has been replaced by :confval:`html_permalinks`
|
||||
|
||||
.. confval:: html_permalinks
|
||||
|
||||
If true, Sphinx will add "permalinks" for each heading and description
|
||||
@@ -2768,24 +2736,6 @@ Options for the C domain
|
||||
|
||||
.. versionadded:: 4.0.3
|
||||
|
||||
.. confval:: c_allow_pre_v3
|
||||
|
||||
A boolean (default ``False``) controlling whether to parse and try to
|
||||
convert pre-v3 style type directives and type roles.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
.. deprecated:: 3.2
|
||||
Use the directives and roles added in v3.
|
||||
|
||||
.. confval:: c_warn_on_allowed_pre_v3
|
||||
|
||||
A boolean (default ``True``) controlling whether to warn when a pre-v3
|
||||
style type directive/role is parsed and converted.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
.. deprecated:: 3.2
|
||||
Use the directives and roles added in v3.
|
||||
|
||||
.. _cpp-config:
|
||||
|
||||
Options for the C++ domain
|
||||
|
||||
@@ -6,7 +6,6 @@ Gracefully adapted from the TextPress system by Armin.
|
||||
import os
|
||||
import pickle
|
||||
import sys
|
||||
import warnings
|
||||
from collections import deque
|
||||
from io import StringIO
|
||||
from os import path
|
||||
@@ -22,7 +21,6 @@ from pygments.lexer import Lexer
|
||||
import sphinx
|
||||
from sphinx import locale, package_dir
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.domains import Domain, Index
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.environment.collectors import EnvironmentCollector
|
||||
@@ -1050,26 +1048,6 @@ class Sphinx:
|
||||
if hasattr(self.builder, 'add_css_file'):
|
||||
self.builder.add_css_file(filename, priority=priority, **kwargs) # type: ignore
|
||||
|
||||
def add_stylesheet(self, filename: str, alternate: bool = False, title: str = None
|
||||
) -> None:
|
||||
"""An alias of :meth:`add_css_file`.
|
||||
|
||||
.. deprecated:: 1.8
|
||||
"""
|
||||
logger.warning('The app.add_stylesheet() is deprecated. '
|
||||
'Please use app.add_css_file() instead.')
|
||||
|
||||
attributes = {} # type: Dict[str, Any]
|
||||
if alternate:
|
||||
attributes['rel'] = 'alternate stylesheet'
|
||||
else:
|
||||
attributes['rel'] = 'stylesheet'
|
||||
|
||||
if title:
|
||||
attributes['title'] = title
|
||||
|
||||
self.add_css_file(filename, **attributes)
|
||||
|
||||
def add_latex_package(self, packagename: str, options: str = None,
|
||||
after_hyperref: bool = False) -> None:
|
||||
r"""Register a package to include in the LaTeX source code.
|
||||
@@ -1286,12 +1264,6 @@ class Sphinx:
|
||||
raise ValueError('policy %s is not supported' % policy)
|
||||
self.registry.html_assets_policy = policy
|
||||
|
||||
@property
|
||||
def html_themes(self) -> Dict[str, str]:
|
||||
warnings.warn('app.html_themes is deprecated.',
|
||||
RemovedInSphinx60Warning)
|
||||
return self.registry.html_themes
|
||||
|
||||
|
||||
class TemplateBridge:
|
||||
"""
|
||||
|
||||
@@ -23,7 +23,7 @@ from sphinx import __display_version__, package_dir
|
||||
from sphinx import version_info as sphinx_version
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.config import ENUM, Config
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx70Warning, deprecated_alias
|
||||
from sphinx.domains import Domain, Index, IndexEntry
|
||||
from sphinx.environment.adapters.asset import ImageAdapter
|
||||
@@ -328,11 +328,6 @@ class StandaloneHTMLBuilder(Builder):
|
||||
self.script_files = []
|
||||
self.add_js_file('documentation_options.js', id="documentation_options",
|
||||
data_url_root='', priority=200)
|
||||
# Remove frameworks and compatability module below in Sphinx 6.0
|
||||
# xref RemovedInSphinx60Warning
|
||||
self.add_js_file('jquery.js', priority=200)
|
||||
self.add_js_file('underscore.js', priority=200)
|
||||
self.add_js_file('_sphinx_javascript_frameworks_compat.js', priority=200)
|
||||
self.add_js_file('doctools.js', priority=200)
|
||||
|
||||
for filename, attrs in self.app.registry.js_files:
|
||||
@@ -1290,32 +1285,6 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:
|
||||
config.html_favicon = None # type: ignore
|
||||
|
||||
|
||||
class _stable_repr_object():
|
||||
|
||||
def __repr__(self):
|
||||
return '<object>'
|
||||
|
||||
|
||||
UNSET = _stable_repr_object()
|
||||
|
||||
|
||||
def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None:
|
||||
"""Migrate html_add_permalinks to html_permalinks*."""
|
||||
html_add_permalinks = config.html_add_permalinks
|
||||
if html_add_permalinks is UNSET:
|
||||
return
|
||||
|
||||
# RemovedInSphinx60Warning
|
||||
logger.warning(__('html_add_permalinks has been deprecated since v3.5.0. '
|
||||
'Please use html_permalinks and html_permalinks_icon instead.'))
|
||||
if not html_add_permalinks:
|
||||
config.html_permalinks = False # type: ignore[attr-defined]
|
||||
return
|
||||
|
||||
config.html_permalinks_icon = html.escape( # type: ignore[attr-defined]
|
||||
html_add_permalinks
|
||||
)
|
||||
|
||||
# for compatibility
|
||||
import sphinxcontrib.serializinghtml # NOQA
|
||||
|
||||
@@ -1352,7 +1321,6 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
app.add_config_value('html_sidebars', {}, 'html')
|
||||
app.add_config_value('html_additional_pages', {}, 'html')
|
||||
app.add_config_value('html_domain_indices', True, 'html', [list])
|
||||
app.add_config_value('html_add_permalinks', UNSET, 'html')
|
||||
app.add_config_value('html_permalinks', True, 'html')
|
||||
app.add_config_value('html_permalinks_icon', '¶', 'html')
|
||||
app.add_config_value('html_use_index', True, 'html')
|
||||
@@ -1375,8 +1343,6 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
app.add_config_value('html_search_scorer', '', None)
|
||||
app.add_config_value('html_scaled_image_link', True, 'html')
|
||||
app.add_config_value('html_baseurl', '', 'html')
|
||||
app.add_config_value('html_codeblock_linenos_style', 'inline', 'html', # RemovedInSphinx60Warning # NOQA
|
||||
ENUM('table', 'inline'))
|
||||
app.add_config_value('html_math_renderer', None, 'env')
|
||||
app.add_config_value('html4_writer', False, 'html')
|
||||
|
||||
@@ -1387,7 +1353,6 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
# event handlers
|
||||
app.connect('config-inited', convert_html_css_files, priority=800)
|
||||
app.connect('config-inited', convert_html_js_files, priority=800)
|
||||
app.connect('config-inited', migrate_html_add_permalinks, priority=800)
|
||||
app.connect('config-inited', validate_html_extra_path, priority=800)
|
||||
app.connect('config-inited', validate_html_static_path, priority=800)
|
||||
app.connect('config-inited', validate_html_logo, priority=800)
|
||||
|
||||
@@ -376,7 +376,7 @@ def generate(d: Dict, overwrite: bool = True, silent: bool = False, templatedir:
|
||||
if template._has_custom_template('quickstart/master_doc.rst_t'):
|
||||
msg = ('A custom template `master_doc.rst_t` found. It has been renamed to '
|
||||
'`root_doc.rst_t`. Please rename it on your project too.')
|
||||
print(colorize('red', msg)) # RemovedInSphinx60Warning
|
||||
print(colorize('red', msg))
|
||||
write_file(masterfile, template.render('quickstart/master_doc.rst_t', d))
|
||||
else:
|
||||
write_file(masterfile, template.render('quickstart/root_doc.rst_t', d))
|
||||
|
||||
@@ -6,15 +6,15 @@ from importlib import import_module
|
||||
from typing import Any, Dict, Type
|
||||
|
||||
|
||||
class RemovedInSphinx60Warning(DeprecationWarning):
|
||||
class RemovedInSphinx70Warning(DeprecationWarning):
|
||||
pass
|
||||
|
||||
|
||||
class RemovedInSphinx70Warning(PendingDeprecationWarning):
|
||||
class RemovedInSphinx80Warning(PendingDeprecationWarning):
|
||||
pass
|
||||
|
||||
|
||||
RemovedInNextVersionWarning = RemovedInSphinx60Warning
|
||||
RemovedInNextVersionWarning = RemovedInSphinx70Warning
|
||||
|
||||
|
||||
def deprecated_alias(modname: str, objects: Dict[str, object],
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import os
|
||||
import warnings
|
||||
from os import path
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Sequence, Tuple, cast
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Sequence, cast
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.nodes import Node, make_id, system_message
|
||||
from docutils.nodes import Node, make_id
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils.parsers.rst.directives import images, tables
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.directives import optional_int
|
||||
from sphinx.domains.math import MathDomain
|
||||
from sphinx.locale import __
|
||||
@@ -78,24 +76,6 @@ class Meta(MetaBase, SphinxDirective):
|
||||
return result
|
||||
|
||||
|
||||
class RSTTable(tables.RSTTable):
|
||||
"""The table directive which sets source and line information to its caption.
|
||||
|
||||
Only for docutils-0.13 or older version."""
|
||||
|
||||
def run(self) -> List[Node]:
|
||||
warnings.warn('RSTTable is deprecated.',
|
||||
RemovedInSphinx60Warning)
|
||||
return super().run()
|
||||
|
||||
def make_title(self) -> Tuple[nodes.title, List[system_message]]:
|
||||
title, message = super().make_title()
|
||||
if title:
|
||||
set_source_info(self, title)
|
||||
|
||||
return title, message
|
||||
|
||||
|
||||
class CSVTable(tables.CSVTable):
|
||||
"""The csv-table directive which searches a CSV file from Sphinx project's source
|
||||
directory when an absolute path is given via :file: option.
|
||||
@@ -118,24 +98,6 @@ class CSVTable(tables.CSVTable):
|
||||
return super().run()
|
||||
|
||||
|
||||
class ListTable(tables.ListTable):
|
||||
"""The list-table directive which sets source and line information to its caption.
|
||||
|
||||
Only for docutils-0.13 or older version."""
|
||||
|
||||
def run(self) -> List[Node]:
|
||||
warnings.warn('ListTable is deprecated.',
|
||||
RemovedInSphinx60Warning)
|
||||
return super().run()
|
||||
|
||||
def make_title(self) -> Tuple[nodes.title, List[system_message]]:
|
||||
title, message = super().make_title()
|
||||
if title:
|
||||
set_source_info(self, title)
|
||||
|
||||
return title, message
|
||||
|
||||
|
||||
class Code(SphinxDirective):
|
||||
"""Parse and mark up content of a code block.
|
||||
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ from sphinx import addnodes
|
||||
from sphinx.addnodes import pending_xref
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.deprecation import RemovedInSphinx70Warning
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.domains import Domain, ObjType
|
||||
from sphinx.environment import BuildEnvironment
|
||||
@@ -3271,7 +3271,7 @@ class CObject(ObjectDescription[ASTDeclaration]):
|
||||
msg = "{}: Pre-v3 C type directive '.. c:type:: {}' converted to " \
|
||||
"'.. c:{}:: {}'." \
|
||||
"\nThe original parsing error was:\n{}"
|
||||
msg = msg.format(RemovedInSphinx60Warning.__name__,
|
||||
msg = msg.format(RemovedInSphinx70Warning.__name__,
|
||||
sig, ast.objectType, ast, eOrig)
|
||||
logger.warning(msg, location=signode)
|
||||
except DefinitionError as e:
|
||||
@@ -3704,7 +3704,7 @@ class CXRefRole(XRefRole):
|
||||
if self.env.config['c_warn_on_allowed_pre_v3']:
|
||||
msg = "{}: Pre-v3 C type role ':c:type:`{}`' converted to ':c:expr:`{}`'."
|
||||
msg += "\nThe original parsing error was:\n{}"
|
||||
msg = msg.format(RemovedInSphinx60Warning.__name__, text, text, eOrig)
|
||||
msg = msg.format(RemovedInSphinx70Warning.__name__, text, text, eOrig)
|
||||
logger.warning(msg, location=self.get_location())
|
||||
return [signode], []
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import inspect
|
||||
import re
|
||||
import sys
|
||||
import typing
|
||||
import warnings
|
||||
from inspect import Parameter
|
||||
from typing import Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Type, cast
|
||||
|
||||
@@ -18,7 +17,6 @@ from sphinx import addnodes
|
||||
from sphinx.addnodes import desc_signature, pending_xref, pending_xref_condition
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.domains import Domain, Index, IndexEntry, ObjType
|
||||
from sphinx.environment import BuildEnvironment
|
||||
@@ -509,14 +507,10 @@ class PyObject(ObjectDescription[Tuple[str, str]]):
|
||||
sig_prefix = self.get_signature_prefix(sig)
|
||||
if sig_prefix:
|
||||
if type(sig_prefix) is str:
|
||||
warnings.warn(
|
||||
raise TypeError(
|
||||
"Python directive method get_signature_prefix()"
|
||||
" returning a string is deprecated."
|
||||
" It must now return a list of nodes."
|
||||
" Return value was '{}'.".format(sig_prefix),
|
||||
RemovedInSphinx60Warning)
|
||||
signode += addnodes.desc_annotation(sig_prefix, '', # type: ignore
|
||||
nodes.Text(sig_prefix)) # type: ignore
|
||||
" must return a list of nodes."
|
||||
f" Return value was '{sig_prefix}'.")
|
||||
else:
|
||||
signode += addnodes.desc_annotation(str(sig_prefix), '', *sig_prefix)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import os
|
||||
import pickle
|
||||
import warnings
|
||||
from collections import defaultdict
|
||||
from copy import copy
|
||||
from datetime import datetime
|
||||
@@ -16,7 +15,6 @@ from docutils.nodes import Node
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.domains import Domain
|
||||
from sphinx.environment.adapters.toctree import TocTree
|
||||
from sphinx.errors import BuildEnvironmentError, DocumentError, ExtensionError, SphinxError
|
||||
@@ -91,7 +89,7 @@ class BuildEnvironment:
|
||||
|
||||
# --------- ENVIRONMENT INITIALIZATION -------------------------------------
|
||||
|
||||
def __init__(self, app: "Sphinx" = None):
|
||||
def __init__(self, app: "Sphinx"):
|
||||
self.app: Sphinx = None
|
||||
self.doctreedir: str = None
|
||||
self.srcdir: str = None
|
||||
@@ -179,11 +177,7 @@ class BuildEnvironment:
|
||||
self.ref_context: Dict[str, Any] = {}
|
||||
|
||||
# set up environment
|
||||
if app:
|
||||
self.setup(app)
|
||||
else:
|
||||
warnings.warn("The 'app' argument for BuildEnvironment() becomes required now.",
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
self.setup(app)
|
||||
|
||||
def __getstate__(self) -> Dict:
|
||||
"""Obtains serializable data for pickling."""
|
||||
|
||||
@@ -6,7 +6,6 @@ for those who like elaborate docstrings.
|
||||
"""
|
||||
|
||||
import re
|
||||
import warnings
|
||||
from inspect import Parameter, Signature
|
||||
from types import ModuleType
|
||||
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Sequence,
|
||||
@@ -17,10 +16,8 @@ from docutils.statemachine import StringList
|
||||
import sphinx
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.config import ENUM, Config
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.ext.autodoc.importer import (get_class_members, get_object_members, import_module,
|
||||
import_object)
|
||||
from sphinx.ext.autodoc.importer import get_class_members, import_module, import_object
|
||||
from sphinx.ext.autodoc.mock import ismock, mock, undecorate
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.pycode import ModuleAnalyzer, PycodeError
|
||||
@@ -245,7 +242,7 @@ class Options(dict):
|
||||
class ObjectMember(tuple):
|
||||
"""A member of object.
|
||||
|
||||
This is used for the result of `Documenter.get_object_members()` to
|
||||
This is used for the result of `Documenter.get_module_members()` to
|
||||
represent each member of the object.
|
||||
|
||||
.. Note::
|
||||
@@ -615,26 +612,7 @@ class Documenter:
|
||||
If *want_all* is True, return all members. Else, only return those
|
||||
members given by *self.options.members* (which may also be None).
|
||||
"""
|
||||
warnings.warn('The implementation of Documenter.get_object_members() will be '
|
||||
'removed from Sphinx-6.0.', RemovedInSphinx60Warning)
|
||||
members = get_object_members(self.object, self.objpath, self.get_attr, self.analyzer)
|
||||
if not want_all:
|
||||
if not self.options.members:
|
||||
return False, [] # type: ignore
|
||||
# specific members given
|
||||
selected = []
|
||||
for name in self.options.members: # type: str
|
||||
if name in members:
|
||||
selected.append((name, members[name].value))
|
||||
else:
|
||||
logger.warning(__('missing attribute %s in object %s') %
|
||||
(name, self.fullname), type='autodoc')
|
||||
return False, selected
|
||||
elif self.options.inherited_members:
|
||||
return False, [(m.name, m.value) for m in members.values()]
|
||||
else:
|
||||
return False, [(m.name, m.value) for m in members.values()
|
||||
if m.directly_defined]
|
||||
raise NotImplementedError('must be implemented in subclasses')
|
||||
|
||||
def filter_members(self, members: ObjectMembers, want_all: bool
|
||||
) -> List[Tuple[str, Any, bool]]:
|
||||
@@ -2386,15 +2364,6 @@ class SlotsMixin(DataDocumenterMixinBase):
|
||||
else:
|
||||
return super().get_doc() # type: ignore
|
||||
|
||||
@property
|
||||
def _datadescriptor(self) -> bool:
|
||||
warnings.warn('AttributeDocumenter._datadescriptor() is deprecated.',
|
||||
RemovedInSphinx60Warning)
|
||||
if self.object is SLOTSATTR:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class RuntimeInstanceAttributeMixin(DataDocumenterMixinBase):
|
||||
"""
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import warnings
|
||||
from typing import Any, Callable, Dict, List, Set, Type
|
||||
|
||||
from docutils import nodes
|
||||
@@ -8,7 +7,6 @@ from docutils.statemachine import StringList
|
||||
from docutils.utils import Reporter, assemble_option_dict
|
||||
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.ext.autodoc import Documenter, Options
|
||||
from sphinx.util import logging
|
||||
@@ -52,18 +50,6 @@ class DocumenterBridge:
|
||||
self.result = StringList()
|
||||
self.state = state
|
||||
|
||||
def warn(self, msg: str) -> None:
|
||||
warnings.warn('DocumenterBridge.warn is deprecated. Please use sphinx.util.logging '
|
||||
'module instead.',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
logger.warning(msg, location=(self.env.docname, self.lineno))
|
||||
|
||||
@property
|
||||
def filename_set(self) -> Set:
|
||||
warnings.warn('DocumenterBridge.filename_set is deprecated.',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
return self.record_dependencies
|
||||
|
||||
|
||||
def process_documenter_options(documenter: Type[Documenter], config: Config, options: Dict
|
||||
) -> Options:
|
||||
|
||||
@@ -67,8 +67,7 @@ import sphinx
|
||||
from sphinx import addnodes
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import (RemovedInSphinx60Warning, RemovedInSphinx70Warning,
|
||||
deprecated_alias)
|
||||
from sphinx.deprecation import RemovedInSphinx70Warning
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.ext.autodoc import INSTANCEATTR, Documenter
|
||||
from sphinx.ext.autodoc.directive import DocumenterBridge, Options
|
||||
@@ -135,14 +134,6 @@ def autosummary_table_visit_html(self: HTMLTranslator, node: autosummary_table)
|
||||
|
||||
|
||||
# -- autodoc integration -------------------------------------------------------
|
||||
deprecated_alias('sphinx.ext.autosummary',
|
||||
{
|
||||
'_app': None,
|
||||
},
|
||||
RemovedInSphinx60Warning,
|
||||
{
|
||||
})
|
||||
|
||||
|
||||
class FakeApplication:
|
||||
def __init__(self):
|
||||
|
||||
@@ -84,22 +84,6 @@ def make_link_role(name: str, base_url: str, caption: str) -> RoleFunction:
|
||||
# a prefix.
|
||||
# Remark: It is an implementation detail that we use Pythons %-formatting.
|
||||
# So far we only expose ``%s`` and require quoting of ``%`` using ``%%``.
|
||||
try:
|
||||
base_url % 'dummy'
|
||||
except (TypeError, ValueError):
|
||||
logger.warn(__('extlinks: Sphinx-6.0 will require base URL to '
|
||||
'contain exactly one \'%s\' and all other \'%\' need '
|
||||
'to be escaped as \'%%\'.')) # RemovedInSphinx60Warning
|
||||
base_url = base_url.replace('%', '%%') + '%s'
|
||||
if caption is not None:
|
||||
try:
|
||||
caption % 'dummy'
|
||||
except (TypeError, ValueError):
|
||||
logger.warning(__('extlinks: Sphinx-6.0 will require a caption string to '
|
||||
'contain exactly one \'%s\' and all other \'%\' need '
|
||||
'to be escaped as \'%%\'.')) # RemovedInSphinx60Warning
|
||||
caption = caption.replace('%', '%%') + '%s'
|
||||
|
||||
def role(typ: str, rawtext: str, text: str, lineno: int,
|
||||
inliner: Inliner, options: Dict = {}, content: List[str] = []
|
||||
) -> Tuple[List[Node], List[system_message]]:
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
import collections
|
||||
import inspect
|
||||
import re
|
||||
import warnings
|
||||
from functools import partial
|
||||
from typing import Any, Callable, Dict, List, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, List, Tuple, Union
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.config import Config as SphinxConfig
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.ext.napoleon.iterators import modify_iter
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.util import logging
|
||||
@@ -815,19 +813,6 @@ class GoogleDocstring:
|
||||
colon,
|
||||
"".join(after_colon).strip())
|
||||
|
||||
def _qualify_name(self, attr_name: str, klass: Type) -> str:
|
||||
warnings.warn('%s._qualify_name() is deprecated.' %
|
||||
self.__class__.__name__, RemovedInSphinx60Warning)
|
||||
if klass and '.' not in attr_name:
|
||||
if attr_name.startswith('~'):
|
||||
attr_name = attr_name[1:]
|
||||
try:
|
||||
q = klass.__qualname__
|
||||
except AttributeError:
|
||||
q = klass.__name__
|
||||
return '~%s.%s' % (q, attr_name)
|
||||
return attr_name
|
||||
|
||||
def _strip_empty(self, lines: List[str]) -> List[str]:
|
||||
if lines:
|
||||
start = -1
|
||||
|
||||
+2
-3
@@ -17,8 +17,7 @@ from docutils.writers import UnfilteredWriter
|
||||
from sphinx import addnodes
|
||||
from sphinx.deprecation import RemovedInSphinx70Warning
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.transforms import (AutoIndexUpgrader, DoctreeReadEvent, FigureAligner,
|
||||
SphinxTransformer)
|
||||
from sphinx.transforms import AutoIndexUpgrader, DoctreeReadEvent, SphinxTransformer
|
||||
from sphinx.transforms.i18n import (Locale, PreserveTranslatableMessages,
|
||||
RemoveTranslatableInline)
|
||||
from sphinx.transforms.references import SphinxDomains
|
||||
@@ -127,7 +126,7 @@ class SphinxI18nReader(SphinxBaseReader):
|
||||
|
||||
self.transforms = self.transforms + app.registry.get_transforms()
|
||||
unused = [PreserveTranslatableMessages, Locale, RemoveTranslatableInline,
|
||||
AutoIndexUpgrader, FigureAligner, SphinxDomains, DoctreeReadEvent,
|
||||
AutoIndexUpgrader, SphinxDomains, DoctreeReadEvent,
|
||||
UIDTransform]
|
||||
for transform in unused:
|
||||
if transform in self.transforms:
|
||||
|
||||
+1
-21
@@ -1,15 +1,12 @@
|
||||
"""Sphinx component registry."""
|
||||
|
||||
import traceback
|
||||
import warnings
|
||||
from importlib import import_module
|
||||
from types import MethodType
|
||||
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Tuple, Type,
|
||||
Union)
|
||||
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Tuple, Type, Union
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.core import Publisher
|
||||
from docutils.io import Input
|
||||
from docutils.nodes import Element, Node, TextElement
|
||||
from docutils.parsers import Parser
|
||||
from docutils.parsers.rst import Directive
|
||||
@@ -22,7 +19,6 @@ except ImportError:
|
||||
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.domains import Domain, Index, ObjType
|
||||
from sphinx.domains.std import GenericObject, Target
|
||||
from sphinx.environment import BuildEnvironment
|
||||
@@ -111,9 +107,6 @@ class SphinxComponentRegistry:
|
||||
#: source paresrs; file type -> parser class
|
||||
self.source_parsers: Dict[str, Type[Parser]] = {}
|
||||
|
||||
#: source inputs; file type -> input class
|
||||
self.source_inputs: Dict[str, Type[Input]] = {}
|
||||
|
||||
#: source suffix: suffix -> file type
|
||||
self.source_suffix: Dict[str, str] = {}
|
||||
|
||||
@@ -294,19 +287,6 @@ class SphinxComponentRegistry:
|
||||
parser.set_application(app)
|
||||
return parser
|
||||
|
||||
def get_source_input(self, filetype: str) -> Optional[Type[Input]]:
|
||||
warnings.warn('SphinxComponentRegistry.get_source_input() is deprecated.',
|
||||
RemovedInSphinx60Warning)
|
||||
|
||||
try:
|
||||
return self.source_inputs[filetype]
|
||||
except KeyError:
|
||||
try:
|
||||
# use special source_input for unknown filetype
|
||||
return self.source_inputs['*']
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
def add_translator(self, name: str, translator: Type[nodes.NodeVisitor],
|
||||
override: bool = False) -> None:
|
||||
logger.debug('[app] Change of translator for the %s builder.', name)
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* _sphinx_javascript_frameworks_compat.js
|
||||
* ~~~~~~~~~~
|
||||
*
|
||||
* Compatability shim for jQuery and underscores.js.
|
||||
*
|
||||
* WILL BE REMOVED IN Sphinx 6.0
|
||||
* xref RemovedInSphinx60Warning
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* select a different prefix for underscore
|
||||
*/
|
||||
$u = _.noConflict();
|
||||
|
||||
|
||||
/**
|
||||
* small helper function to urldecode strings
|
||||
*
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
|
||||
*/
|
||||
jQuery.urldecode = function(x) {
|
||||
if (!x) {
|
||||
return x
|
||||
}
|
||||
return decodeURIComponent(x.replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
/**
|
||||
* small helper function to urlencode strings
|
||||
*/
|
||||
jQuery.urlencode = encodeURIComponent;
|
||||
|
||||
/**
|
||||
* This function returns the parsed url parameters of the
|
||||
* current request. Multiple values per key are supported,
|
||||
* it will always return arrays of strings for the value parts.
|
||||
*/
|
||||
jQuery.getQueryParameters = function(s) {
|
||||
if (typeof s === 'undefined')
|
||||
s = document.location.search;
|
||||
var parts = s.substr(s.indexOf('?') + 1).split('&');
|
||||
var result = {};
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var tmp = parts[i].split('=', 2);
|
||||
var key = jQuery.urldecode(tmp[0]);
|
||||
var value = jQuery.urldecode(tmp[1]);
|
||||
if (key in result)
|
||||
result[key].push(value);
|
||||
else
|
||||
result[key] = [value];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* highlight a given string on a jquery object by wrapping it in
|
||||
* span elements with the given class name.
|
||||
*/
|
||||
jQuery.fn.highlightText = function(text, className) {
|
||||
function highlight(node, addItems) {
|
||||
if (node.nodeType === 3) {
|
||||
var val = node.nodeValue;
|
||||
var pos = val.toLowerCase().indexOf(text);
|
||||
if (pos >= 0 &&
|
||||
!jQuery(node.parentNode).hasClass(className) &&
|
||||
!jQuery(node.parentNode).hasClass("nohighlight")) {
|
||||
var span;
|
||||
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
|
||||
if (isInSVG) {
|
||||
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
||||
} else {
|
||||
span = document.createElement("span");
|
||||
span.className = className;
|
||||
}
|
||||
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
|
||||
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
|
||||
document.createTextNode(val.substr(pos + text.length)),
|
||||
node.nextSibling));
|
||||
node.nodeValue = val.substr(0, pos);
|
||||
if (isInSVG) {
|
||||
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||||
var bbox = node.parentElement.getBBox();
|
||||
rect.x.baseVal.value = bbox.x;
|
||||
rect.y.baseVal.value = bbox.y;
|
||||
rect.width.baseVal.value = bbox.width;
|
||||
rect.height.baseVal.value = bbox.height;
|
||||
rect.setAttribute('class', className);
|
||||
addItems.push({
|
||||
"parent": node.parentNode,
|
||||
"target": rect});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!jQuery(node).is("button, select, textarea")) {
|
||||
jQuery.each(node.childNodes, function() {
|
||||
highlight(this, addItems);
|
||||
});
|
||||
}
|
||||
}
|
||||
var addItems = [];
|
||||
var result = this.each(function() {
|
||||
highlight(this, addItems);
|
||||
});
|
||||
for (var i = 0; i < addItems.length; ++i) {
|
||||
jQuery(addItems[i].parent).before(addItems[i].target);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
* backward compatibility for jQuery.browser
|
||||
* This will be supported until firefox bug is fixed.
|
||||
*/
|
||||
if (!jQuery.browser) {
|
||||
jQuery.uaMatch = function(ua) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(msie) ([\w.]+)/.exec(ua) ||
|
||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
|
||||
[];
|
||||
|
||||
return {
|
||||
browser: match[ 1 ] || "",
|
||||
version: match[ 2 ] || "0"
|
||||
};
|
||||
};
|
||||
jQuery.browser = {};
|
||||
jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
|
||||
}
|
||||
-10881
File diff suppressed because it is too large.
Load diff
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */
|
||||
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),j=function(e,t){return e===t&&(l=!0),0},D={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^Line truncated
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +0,0 @@
|
||||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n="undefined"!=typeof globalThis?globalThis:n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){
|
||||
// Underscore.js 1.13.1
|
||||
// https://underscorejs.org
|
||||
// (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore may be freely distributed under the MIT license.
|
||||
var n="1.13.1",r="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},t=Array.prototype,e=Object.prototype,u="undefined"!=typeof Symbol?Symbol.prototype:null,o=t.push,i=t.slice,a=e.toString,f=e.hasOwnProperty,c="undefined"!=typeof ArrayBuffer,l="undefined"!=typeof DataView,s=Array.isArray,p=Object.keys,v=Object.create,h=c&&ArrayBuffer.isView,y=isNaN,d=isFinite,g=!{toString:null}.propertyIsEnumerable("toString"),b=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=Math.pow(2,53)-1;function j(n,r){return r=null==r?n.length-1:+r,function(){for(var t=Math.max(arguments.length-r,0),e=Array(t),u=0;u<t;u++)e[u]=arguments[u+r];switch(r){case 0:return n.call(this,e);case 1:return n.call(this,arguments[0],e);case 2:return n.call(this,arguments[0],arguments[1],e)}var o=Array(r+1);for(u=0;u<r;u++)o[u]=arguments[u];return o[r]=e,n.apply(this,o)}}function _(n){var r=typeof n;return"function"===r||"object"===r&&!!n}function w(n){return void 0===n}function A(n){return!0===n||!1===n||"[object Boolean]"===a.call(n)}function x(n){var r="[object "+n+"]";return function(n){return a.call(n)===r}}var S=x("String"),O=x("Number"),M=x("Date"),E=x("RegExp"),B=x("Error"),N=x("Symbol"),I=x("ArrayBuffer"),T=x("Function"),k=r.document&&r.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof k&&(T=function(n){return"function"==typeof n||!1});var D=T,R=x("Object"),F=l&&R(new DataView(new ArrayBuffer(8))),V="undefined"!=typeof Map&&R(new Map),P=x("DataView");var q=F?function(n){return null!=n&&D(n.getInt8)&&I(n.buffer)}:P,U=s||x("Array");function W(n,r){return null!=n&&f.call(n,r)}var z=x("Arguments");!function(){z(arguments)||(z=function(n){return W(n,"callee")})}();var L=z;function $(n){return O(n)&&y(n)}function C(n){return function(){return n}}function K(n){return function(r){var t=n(r);return"number"==typeof t&&t>=0&&t<=m}}function J(n){return function(r){return null==r?void 0:r[n]}}var G=J("byteLength"),H=K(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:C(!1),Y=J("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e<t;++e)r[n[e]]=!0;return{contains:function(n){return r[n]},push:function(t){return r[t]=!0,n.push(t)}}}(r);var t=b.length,u=n.constructor,o=D(u)&&u.prototype||e,i="constructor";for(W(n,i)&&!r.contains(i)&&r.push(i);t--;)(i=b[t])in n&&n[i]!==o[i]&&!r.contains(i)&&r.push(i)}function nn(n){if(!_(n))return[];if(p)return p(n);var r=[];for(var t in n)W(n,t)&&r.push(t);return g&&Z(n,r),r}function rn(n,r){var t=nn(r),e=t.length;if(null==n)return!e;for(var u=Object(n),o=0;o<e;o++){var i=t[o];if(r[i]!==u[i]||!(i in u))return!1}return!0}function tn(n){return n instanceof tn?n:this instanceof tn?void(this._wrapped=n):new tn(n)}function en(n){return new Uint8Array(n.buffer||n,n.byteOffset||0,G(n))}tn.VERSION=n,tn.prototype.value=function(){return this._wrapped},tn.prototype.valueOf=tn.prototype.toJSON=tn.prototype.value,tn.prototype.toString=function(){return String(this._wrapped)};var un="[object DataView]";function on(n,r,t,e){if(n===r)return 0!==n||1/n==1/r;if(null==n||null==r)return!1;if(n!=n)return r!=r;var o=typeof n;return("function"===o||"object"===o||"object"==typeof r)&&function n(r,t,e,o){r instanceof tn&&(r=r._wrapped);t instanceof tn&&(t=t._wrapped);var i=a.call(r);if(i!==a.call(t))return!1;if(F&&"[object Object]"==i&&q(r)){if(!q(t))return!1;i=un}switch(i){case"[object RegExp]":case"[object String]":return""+r==""+t;case"[object Number]":return+r!=+r?+t!=+t:0==+r?1/+r==1/t:+r==+t;case"[object Date]":case"[object Boolean]":return+r==+t;case"[object Symbol]":return u.valueOf.call(r)===u.valueOf.call(t);case"[object ArrayBuffer]":case un:return n(en(r),en(t),e,o)}var f="[object Array]"===i;if(!f&&X(r)){if(G(r)!==G(t))return!1;if(r.buffer===t.buffer&&r.byteOffset===t.byteOffset)return!0;f=!0}if(!f){if("object"!=typeof r||"object"!=typeof t)return!1;var c=r.constructor,l=t.constructor;if(c!==l&&!(D(c)&&c instanceof c&&D(l)&&l instanceof l)&&"constructor"in r&&"constructor"in t)return!1}o=o||[];var s=(e=e||[]).length;for(;s--;)if(e[s]===r)return o[s]===t;if(e.push(r),o.push(t),f){if((s=r.length)!==t.length)return!1;for(;s--;)if(!on(r[s],t[s],e,o))return!1}else{var p,v=nn(r);if(s=v.length,nn(t).length!==s)return!1;for(;s--;)if(p=v[s],!W(t,p)||!on(r[p],t[p],e,o))return!1}return e.pop(),o.pop(),!0}(n,r,t,e)}function an(n){if(!_(n))return[];var r=[];for(var t in n)r.push(t);return g&&Z(n,r),r}function fn(n){var r=Y(n);return function(t){if(null==t)return!1;var e=an(t);if(Y(e))return!1;for(var u=0;u<r;u++)if(!D(t[n[u]]))return!1;return n!==hn||!D(t[cn])}}var cn="forEach",ln="has",sn=["clear","delete"],pn=["get",ln,"set"],vn=sn.concat(cn,pn),hn=sn.concat(pn),yn=["add"].concat(sn,cn,ln),dn=V?fn(vn):x("Map"),gn=V?fn(hn):x("WeakMap"),bn=V?fn(yn):x("Set"),mn=x("Line truncated
|
||||
@@ -181,15 +181,6 @@ class HTMLThemeFactory:
|
||||
import alabaster
|
||||
self.themes['alabaster'] = path.join(alabaster.get_path(), 'alabaster')
|
||||
|
||||
def load_sphinx_rtd_theme(self) -> None:
|
||||
"""Load sphinx_rtd_theme theme (if installed)."""
|
||||
try:
|
||||
import sphinx_rtd_theme
|
||||
theme_path = sphinx_rtd_theme.get_html_theme_path()
|
||||
self.themes['sphinx_rtd_theme'] = path.join(theme_path, 'sphinx_rtd_theme')
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def load_external_theme(self, name: str) -> None:
|
||||
"""Try to load a theme using entry_points.
|
||||
|
||||
@@ -231,12 +222,6 @@ class HTMLThemeFactory:
|
||||
if name not in self.themes:
|
||||
self.load_extra_theme(name)
|
||||
|
||||
if name not in self.themes and name == 'sphinx_rtd_theme':
|
||||
# sphinx_rtd_theme (< 0.2.5) # RemovedInSphinx60Warning
|
||||
logger.warning(__('sphinx_rtd_theme (< 0.3.0) found. '
|
||||
'It will not be available since Sphinx-6.0'))
|
||||
self.load_sphinx_rtd_theme()
|
||||
|
||||
if name not in self.themes:
|
||||
raise ThemeError(__('no theme named %r found (missing theme.conf?)') % name)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import re
|
||||
import unicodedata
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Tuple, cast
|
||||
|
||||
import docutils
|
||||
@@ -16,12 +15,11 @@ from docutils.utils.smartquotes import smartchars
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.docutils import new_document
|
||||
from sphinx.util.i18n import format_date
|
||||
from sphinx.util.nodes import NodeMatcher, apply_source_workaround, is_smartquotable
|
||||
from sphinx.util.nodes import apply_source_workaround, is_smartquotable
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
@@ -274,23 +272,6 @@ class DoctestTransform(SphinxTransform):
|
||||
node['classes'].append('doctest')
|
||||
|
||||
|
||||
class FigureAligner(SphinxTransform):
|
||||
"""
|
||||
Align figures to center by default.
|
||||
"""
|
||||
default_priority = 700
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
warnings.warn('FigureAilgner is deprecated.',
|
||||
RemovedInSphinx60Warning)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def apply(self, **kwargs: Any) -> None:
|
||||
matcher = NodeMatcher(nodes.table, nodes.figure)
|
||||
for node in self.document.findall(matcher): # type: Element
|
||||
node.setdefault('align', 'default')
|
||||
|
||||
|
||||
class FilterSystemMessages(SphinxTransform):
|
||||
"""Filter system messages from a doctree."""
|
||||
default_priority = 999
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from docutils.parsers.rst.states import Body
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
|
||||
field_list_item_re = re.compile(Body.patterns['field_marker'])
|
||||
|
||||
|
||||
@@ -41,14 +38,6 @@ def separate_metadata(s: str) -> Tuple[str, Dict[str, str]]:
|
||||
return '\n'.join(lines), metadata
|
||||
|
||||
|
||||
def extract_metadata(s: str) -> Dict[str, str]:
|
||||
warnings.warn("extract_metadata() is deprecated.",
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
|
||||
docstring, metadata = separate_metadata(s)
|
||||
return metadata
|
||||
|
||||
|
||||
def prepare_docstring(s: str, tabsize: int = 8) -> List[str]:
|
||||
"""Convert a docstring into lines of parseable reST. Remove common leading
|
||||
indentation, where the indentation of the first line is ignored.
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
"""Stuff for Python version compatibility."""
|
||||
|
||||
import warnings
|
||||
from typing import Any, Callable
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Python 2/3 compatibility
|
||||
|
||||
|
||||
# convert_with_2to3():
|
||||
# support for running 2to3 over config files
|
||||
def convert_with_2to3(filepath: str) -> str:
|
||||
warnings.warn('convert_with_2to3() is deprecated',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
|
||||
try:
|
||||
from lib2to3.pgen2.parse import ParseError
|
||||
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
|
||||
except ImportError as exc:
|
||||
# python 3.9.0a6+ emits PendingDeprecationWarning for lib2to3.
|
||||
# Additionally, removal of the module is still discussed at PEP-594.
|
||||
# To support future python, this catches ImportError for lib2to3.
|
||||
raise SyntaxError from exc
|
||||
|
||||
fixers = get_fixers_from_package('lib2to3.fixes')
|
||||
refactoring_tool = RefactoringTool(fixers)
|
||||
source = refactoring_tool._read_python_source(filepath)[0]
|
||||
try:
|
||||
tree = refactoring_tool.refactor_string(source, 'conf.py')
|
||||
except ParseError as err:
|
||||
# do not propagate lib2to3 exceptions
|
||||
lineno, offset = err.context[1]
|
||||
# try to match ParseError details with SyntaxError details
|
||||
|
||||
raise SyntaxError(err.msg, (filepath, lineno, offset, err.value)) from err
|
||||
return str(tree)
|
||||
|
||||
|
||||
def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None:
|
||||
warnings.warn('execfile_() is deprecated',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
from sphinx.util.osutil import fs_encoding
|
||||
with open(filepath, 'rb') as f:
|
||||
source = f.read()
|
||||
|
||||
# compile to a code object, handle syntax errors
|
||||
filepath_enc = filepath.encode(fs_encoding)
|
||||
code = compile(source, filepath_enc, 'exec')
|
||||
exec(code, _globals)
|
||||
@@ -1,374 +0,0 @@
|
||||
"""Deprecated backport of docutils.utils.smartquotes.
|
||||
|
||||
This is extracted (with minor adaptations for flake8 compliance) from
|
||||
docutils’ docutils/utils/smartquotes.py as of revision 8097 (30 May 2017),
|
||||
in order to backport for Sphinx usage with Docutils < 0.14 extra language
|
||||
configurations and fixes. Replaces earlier smartypants version as used up
|
||||
to Sphinx 1.5.6.
|
||||
|
||||
:copyright: © 2010 Günter Milde,
|
||||
original `SmartyPants`_: © 2003 John Gruber
|
||||
smartypants.py: © 2004, 2007 Chad Miller
|
||||
:license: Released under the terms of the `2-Clause BSD license`_, in short:
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notices and this notice are preserved.
|
||||
This file is offered as-is, without any warranty.
|
||||
|
||||
.. _SmartyPants: https://daringfireball.net/projects/smartypants/
|
||||
.. _2-Clause BSD license: https://spdx.org/licenses/BSD-2-Clause
|
||||
|
||||
See the LICENSE file and the original docutils code for details.
|
||||
|
||||
"""
|
||||
|
||||
import re
|
||||
import warnings
|
||||
from typing import Generator, Iterable, Tuple
|
||||
|
||||
from docutils.utils import smartquotes
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
|
||||
warnings.warn('sphinx.util.smartypants is deprecated.',
|
||||
RemovedInSphinx60Warning)
|
||||
|
||||
langquotes = {'af': '“”‘’',
|
||||
'af-x-altquot': '„”‚’',
|
||||
'bg': '„“‚‘', # Bulgarian, https://bg.wikipedia.org/wiki/Кавички
|
||||
'ca': '«»“”',
|
||||
'ca-x-altquot': '“”‘’',
|
||||
'cs': '„“‚‘',
|
||||
'cs-x-altquot': '»«›‹',
|
||||
'da': '»«›‹',
|
||||
'da-x-altquot': '„“‚‘',
|
||||
# 'da-x-altquot2': '””’’',
|
||||
'de': '„“‚‘',
|
||||
'de-x-altquot': '»«›‹',
|
||||
'de-ch': '«»‹›',
|
||||
'el': '«»“”',
|
||||
'en': '“”‘’',
|
||||
'en-uk-x-altquot': '‘’“”', # Attention: " → ‘ and ' → “ !
|
||||
'eo': '“”‘’',
|
||||
'es': '«»“”',
|
||||
'es-x-altquot': '“”‘’',
|
||||
'et': '„“‚‘', # no secondary quote listed in
|
||||
'et-x-altquot': '«»‹›', # the sources above (wikipedia.org)
|
||||
'eu': '«»‹›',
|
||||
'fi': '””’’',
|
||||
'fi-x-altquot': '»»››',
|
||||
'fr': ('« ', ' »', '“', '”'), # full no-break space
|
||||
'fr-x-altquot': ('« ', ' »', '“', '”'), # narrow no-break space
|
||||
'fr-ch': '«»‹›',
|
||||
'fr-ch-x-altquot': ('« ', ' »', '‹ ', ' ›'), # narrow no-break space
|
||||
# http://typoguide.ch/
|
||||
'gl': '«»“”',
|
||||
'he': '”“»«', # Hebrew is RTL, test position:
|
||||
'he-x-altquot': '„”‚’', # low quotation marks are opening.
|
||||
# 'he-x-altquot': '“„‘‚', # RTL: low quotation marks opening
|
||||
'hr': '„”‘’', # https://hrvatska-tipografija.com/polunavodnici/
|
||||
'hr-x-altquot': '»«›‹',
|
||||
'hsb': '„“‚‘',
|
||||
'hsb-x-altquot': '»«›‹',
|
||||
'hu': '„”«»',
|
||||
'is': '„“‚‘',
|
||||
'it': '«»“”',
|
||||
'it-ch': '«»‹›',
|
||||
'it-x-altquot': '“”‘’',
|
||||
# 'it-x-altquot2': '“„‘‚', # [7] in headlines
|
||||
'ja': '「」『』',
|
||||
'lt': '„“‚‘',
|
||||
'lv': '„“‚‘',
|
||||
'mk': '„“‚‘', # Macedonian,
|
||||
# https://mk.wikipedia.org/wiki/Правопис_и_правоговор_на_македонскиот_јазик
|
||||
'nl': '“”‘’',
|
||||
'nl-x-altquot': '„”‚’',
|
||||
# 'nl-x-altquot2': '””’’',
|
||||
'nb': '«»’’', # Norsk bokmål (canonical form 'no')
|
||||
'nn': '«»’’', # Nynorsk [10]
|
||||
'nn-x-altquot': '«»‘’', # [8], [10]
|
||||
# 'nn-x-altquot2': '«»«»', # [9], [10]
|
||||
# 'nn-x-altquot3': '„“‚‘', # [10]
|
||||
'no': '«»’’', # Norsk bokmål [10]
|
||||
'no-x-altquot': '«»‘’', # [8], [10]
|
||||
# 'no-x-altquot2': '«»«»', # [9], [10]
|
||||
# 'no-x-altquot3': '„“‚‘', # [10]
|
||||
'pl': '„”«»',
|
||||
'pl-x-altquot': '«»‚’',
|
||||
# 'pl-x-altquot2': '„”‚’',
|
||||
# https://pl.wikipedia.org/wiki/Cudzys%C5%82%C3%B3w
|
||||
'pt': '«»“”',
|
||||
'pt-br': '“”‘’',
|
||||
'ro': '„”«»',
|
||||
'ru': '«»„“',
|
||||
'sh': '„”‚’', # Serbo-Croatian
|
||||
'sh-x-altquot': '»«›‹',
|
||||
'sk': '„“‚‘', # Slovak
|
||||
'sk-x-altquot': '»«›‹',
|
||||
'sl': '„“‚‘', # Slovenian
|
||||
'sl-x-altquot': '»«›‹',
|
||||
'sq': '«»‹›', # Albanian
|
||||
'sq-x-altquot': '“„‘‚',
|
||||
'sr': '„”’’',
|
||||
'sr-x-altquot': '»«›‹',
|
||||
'sv': '””’’',
|
||||
'sv-x-altquot': '»»››',
|
||||
'tr': '“”‘’',
|
||||
'tr-x-altquot': '«»‹›',
|
||||
# 'tr-x-altquot2': '“„‘‚', # [7] antiquated?
|
||||
'uk': '«»„“',
|
||||
'uk-x-altquot': '„“‚‘',
|
||||
'zh-cn': '“”‘’',
|
||||
'zh-tw': '「」『』',
|
||||
}
|
||||
|
||||
|
||||
def educateQuotes(text: str, language: str = 'en') -> str:
|
||||
"""
|
||||
Parameter: - text string (unicode or bytes).
|
||||
- language (`BCP 47` language tag.)
|
||||
Returns: The `text`, with "educated" curly quote characters.
|
||||
|
||||
Example input: "Isn't this fun?"
|
||||
Example output: “Isn’t this fun?“;
|
||||
"""
|
||||
|
||||
smart = smartquotes.smartchars(language)
|
||||
try:
|
||||
apostrophe = smart.apostrophe
|
||||
except Exception:
|
||||
apostrophe = '’'
|
||||
|
||||
# oldtext = text
|
||||
punct_class = r"""[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]"""
|
||||
|
||||
# Special case if the very first character is a quote
|
||||
# followed by punctuation at a non-word-break.
|
||||
# Close the quotes by brute force:
|
||||
text = re.sub(r"""^'(?=%s\\B)""" % (punct_class,), smart.csquote, text)
|
||||
text = re.sub(r"""^"(?=%s\\B)""" % (punct_class,), smart.cpquote, text)
|
||||
|
||||
# Special case for double sets of quotes, e.g.:
|
||||
# <p>He said, "'Quoted' words in a larger quote."</p>
|
||||
text = re.sub(r""""'(?=\w)""", smart.opquote + smart.osquote, text)
|
||||
text = re.sub(r"""'"(?=\w)""", smart.osquote + smart.opquote, text)
|
||||
|
||||
# Special case for decade abbreviations (the '80s):
|
||||
if language.startswith('en'): # TODO similar cases in other languages?
|
||||
text = re.sub(r"""'(?=\d{2}s)""", apostrophe, text, flags=re.UNICODE)
|
||||
|
||||
close_class = r"""[^\ \t\r\n\[\{\(\-]"""
|
||||
dec_dashes = r"""–|—"""
|
||||
|
||||
# Get most opening single quotes:
|
||||
opening_single_quotes_regex = re.compile(r"""
|
||||
(
|
||||
\s | # a whitespace char, or
|
||||
| # a non-breaking space entity, or
|
||||
-- | # dashes, or
|
||||
&[mn]dash; | # named dash entities
|
||||
%s | # or decimal entities
|
||||
&\#x201[34]; # or hex
|
||||
)
|
||||
' # the quote
|
||||
(?=\w) # followed by a word character
|
||||
""" % (dec_dashes,), re.VERBOSE | re.UNICODE)
|
||||
text = opening_single_quotes_regex.sub(r'\1' + smart.osquote, text)
|
||||
|
||||
# In many locales, single closing quotes are different from apostrophe:
|
||||
if smart.csquote != apostrophe:
|
||||
apostrophe_regex = re.compile(r"(?<=(\w|\d))'(?=\w)", re.UNICODE)
|
||||
text = apostrophe_regex.sub(apostrophe, text)
|
||||
# TODO: keep track of quoting level to recognize apostrophe in, e.g.,
|
||||
# "Ich fass' es nicht."
|
||||
|
||||
closing_single_quotes_regex = re.compile(r"""
|
||||
(%s)
|
||||
'
|
||||
(?!\s | # whitespace
|
||||
s\b |
|
||||
\d # digits ('80s)
|
||||
)
|
||||
""" % (close_class,), re.VERBOSE | re.UNICODE)
|
||||
text = closing_single_quotes_regex.sub(r'\1' + smart.csquote, text)
|
||||
|
||||
closing_single_quotes_regex = re.compile(r"""
|
||||
(%s)
|
||||
'
|
||||
(\s | s\b)
|
||||
""" % (close_class,), re.VERBOSE | re.UNICODE)
|
||||
text = closing_single_quotes_regex.sub(r'\1%s\2' % smart.csquote, text)
|
||||
|
||||
# Any remaining single quotes should be opening ones:
|
||||
text = re.sub(r"""'""", smart.osquote, text)
|
||||
|
||||
# Get most opening double quotes:
|
||||
opening_double_quotes_regex = re.compile(r"""
|
||||
(
|
||||
\s | # a whitespace char, or
|
||||
| # a non-breaking space entity, or
|
||||
-- | # dashes, or
|
||||
&[mn]dash; | # named dash entities
|
||||
%s | # or decimal entities
|
||||
&\#x201[34]; # or hex
|
||||
)
|
||||
" # the quote
|
||||
(?=\w) # followed by a word character
|
||||
""" % (dec_dashes,), re.VERBOSE)
|
||||
text = opening_double_quotes_regex.sub(r'\1' + smart.opquote, text)
|
||||
|
||||
# Double closing quotes:
|
||||
closing_double_quotes_regex = re.compile(r"""
|
||||
#(%s)? # character that indicates the quote should be closing
|
||||
"
|
||||
(?=\s)
|
||||
""" % (close_class,), re.VERBOSE)
|
||||
text = closing_double_quotes_regex.sub(smart.cpquote, text)
|
||||
|
||||
closing_double_quotes_regex = re.compile(r"""
|
||||
(%s) # character that indicates the quote should be closing
|
||||
"
|
||||
""" % (close_class,), re.VERBOSE)
|
||||
text = closing_double_quotes_regex.sub(r'\1' + smart.cpquote, text)
|
||||
|
||||
# Any remaining quotes should be opening ones.
|
||||
text = re.sub(r'"', smart.opquote, text)
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def educate_tokens(text_tokens: Iterable[Tuple[str, str]],
|
||||
attr: str = smartquotes.default_smartypants_attr,
|
||||
language: str = 'en'
|
||||
) -> Generator[str, None, None]:
|
||||
"""Return iterator that "educates" the items of `text_tokens`.
|
||||
|
||||
This is modified to intercept the ``attr='2'`` as it was used by the
|
||||
Docutils 0.13.1 SmartQuotes transform in a hard coded way. Docutils 0.14
|
||||
uses ``'qDe'``` and is configurable, and its choice is backported here
|
||||
for use by Sphinx with earlier Docutils releases. Similarly ``'1'`` is
|
||||
replaced by ``'qde'``.
|
||||
|
||||
Use ``attr='qDbe'``, resp. ``'qdbe'`` to recover Docutils effect of ``'2'``,
|
||||
resp. ``'1'``.
|
||||
|
||||
refs: https://sourceforge.net/p/docutils/mailman/message/35869025/
|
||||
"""
|
||||
|
||||
# Parse attributes:
|
||||
# 0 : do nothing
|
||||
# 1 : set all (but backticks)
|
||||
# 2 : set all (but backticks), using old school en- and em- dash shortcuts
|
||||
# 3 : set all, using inverted old school en and em- dash shortcuts
|
||||
#
|
||||
# q : quotes
|
||||
# b : backtick quotes (``double'' only)
|
||||
# B : backtick quotes (``double'' and `single')
|
||||
# d : dashes
|
||||
# D : old school dashes
|
||||
# i : inverted old school dashes
|
||||
# e : ellipses
|
||||
# w : convert " entities to " for Dreamweaver users
|
||||
|
||||
convert_quot = False # translate " entities into normal quotes?
|
||||
do_dashes = 0
|
||||
do_backticks = 0
|
||||
do_quotes = False
|
||||
do_ellipses = False
|
||||
do_stupefy = False
|
||||
|
||||
if attr == "1": # Do everything, turn all options on.
|
||||
do_quotes = True
|
||||
# do_backticks = 1
|
||||
do_dashes = 1
|
||||
do_ellipses = True
|
||||
elif attr == "2":
|
||||
# Do everything, turn all options on, use old school dash shorthand.
|
||||
do_quotes = True
|
||||
# do_backticks = 1
|
||||
do_dashes = 2
|
||||
do_ellipses = True
|
||||
elif attr == "3":
|
||||
# Do everything, use inverted old school dash shorthand.
|
||||
do_quotes = True
|
||||
do_backticks = 1
|
||||
do_dashes = 3
|
||||
do_ellipses = True
|
||||
elif attr == "-1": # Special "stupefy" mode.
|
||||
do_stupefy = True
|
||||
else:
|
||||
if "q" in attr:
|
||||
do_quotes = True
|
||||
if "b" in attr:
|
||||
do_backticks = 1
|
||||
if "B" in attr:
|
||||
do_backticks = 2
|
||||
if "d" in attr:
|
||||
do_dashes = 1
|
||||
if "D" in attr:
|
||||
do_dashes = 2
|
||||
if "i" in attr:
|
||||
do_dashes = 3
|
||||
if "e" in attr:
|
||||
do_ellipses = True
|
||||
if "w" in attr:
|
||||
convert_quot = True
|
||||
|
||||
prev_token_last_char = " "
|
||||
# Last character of the previous text token. Used as
|
||||
# context to curl leading quote characters correctly.
|
||||
|
||||
for (ttype, text) in text_tokens:
|
||||
|
||||
# skip HTML and/or XML tags as well as empty text tokens
|
||||
# without updating the last character
|
||||
if ttype == 'tag' or not text:
|
||||
yield text
|
||||
continue
|
||||
|
||||
# skip literal text (math, literal, raw, ...)
|
||||
if ttype == 'literal':
|
||||
prev_token_last_char = text[-1:]
|
||||
yield text
|
||||
continue
|
||||
|
||||
last_char = text[-1:] # Remember last char before processing.
|
||||
|
||||
text = smartquotes.processEscapes(text)
|
||||
|
||||
if convert_quot:
|
||||
text = re.sub('"', '"', text)
|
||||
|
||||
if do_dashes == 1:
|
||||
text = smartquotes.educateDashes(text)
|
||||
elif do_dashes == 2:
|
||||
text = smartquotes.educateDashesOldSchool(text)
|
||||
elif do_dashes == 3:
|
||||
text = smartquotes.educateDashesOldSchoolInverted(text)
|
||||
|
||||
if do_ellipses:
|
||||
text = smartquotes.educateEllipses(text)
|
||||
|
||||
# Note: backticks need to be processed before quotes.
|
||||
if do_backticks:
|
||||
text = smartquotes.educateBackticks(text, language)
|
||||
|
||||
if do_backticks == 2:
|
||||
text = smartquotes.educateSingleBackticks(text, language)
|
||||
|
||||
if do_quotes:
|
||||
# Replace plain quotes to prevent conversion to
|
||||
# 2-character sequence in French.
|
||||
context = prev_token_last_char.replace('"', ';').replace("'", ';')
|
||||
text = educateQuotes(context + text, language)[1:]
|
||||
|
||||
if do_stupefy:
|
||||
text = smartquotes.stupefyEntities(text, language)
|
||||
|
||||
# Remember last char as context for the next token
|
||||
prev_token_last_char = last_char
|
||||
|
||||
text = smartquotes.processEscapes(text, restore=True)
|
||||
|
||||
yield text
|
||||
@@ -10,8 +10,7 @@ from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Type,
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst.states import Inliner
|
||||
|
||||
from sphinx.deprecation import (RemovedInSphinx60Warning, RemovedInSphinx70Warning,
|
||||
deprecated_alias)
|
||||
from sphinx.deprecation import RemovedInSphinx70Warning
|
||||
|
||||
if sys.version_info > (3, 7):
|
||||
from typing import ForwardRef
|
||||
@@ -536,10 +535,3 @@ def _stringify_py36(annotation: Any, mode: str = 'fully-qualified-except-typing'
|
||||
return '%sUnion[%s]' % (modprefix, param_str)
|
||||
|
||||
return modprefix + qualname
|
||||
|
||||
|
||||
deprecated_alias('sphinx.util.typing',
|
||||
{
|
||||
'DirectiveOption': Callable[[str], Any],
|
||||
},
|
||||
RemovedInSphinx60Warning)
|
||||
+1
-18
@@ -4,7 +4,6 @@ import os
|
||||
import posixpath
|
||||
import re
|
||||
import urllib.parse
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Iterable, Optional, Tuple, cast
|
||||
|
||||
from docutils import nodes
|
||||
@@ -14,7 +13,6 @@ from docutils.writers.html4css1 import Writer
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.locale import _, __, admonitionlabels
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.docutils import SphinxTranslator
|
||||
@@ -447,14 +445,11 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
return super().visit_literal_block(node)
|
||||
|
||||
lang = node.get('language', 'default')
|
||||
linenos = node.get('linenos', False)
|
||||
linenos = node.get('linenos', False) and "inline"
|
||||
highlight_args = node.get('highlight_args', {})
|
||||
highlight_args['force'] = node.get('force', False)
|
||||
opts = self.config.highlight_options.get(lang, {})
|
||||
|
||||
if linenos and self.config.html_codeblock_linenos_style:
|
||||
linenos = self.config.html_codeblock_linenos_style
|
||||
|
||||
highlighted = self.highlighter.highlight_block(
|
||||
node.rawsource, lang, opts=opts, linenos=linenos,
|
||||
location=node, **highlight_args
|
||||
@@ -881,15 +876,3 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
_, depart = self.builder.app.registry.html_block_math_renderers[name]
|
||||
if depart:
|
||||
depart(self, node)
|
||||
|
||||
@property
|
||||
def _fieldlist_row_index(self):
|
||||
warnings.warn('_fieldlist_row_index is deprecated',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
return self._fieldlist_row_indices[-1]
|
||||
|
||||
@property
|
||||
def _table_row_index(self):
|
||||
warnings.warn('_table_row_index is deprecated',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
return self._table_row_indices[-1]
|
||||
+1
-33
@@ -4,7 +4,6 @@ import os
|
||||
import posixpath
|
||||
import re
|
||||
import urllib.parse
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Iterable, Optional, Set, Tuple, cast
|
||||
|
||||
from docutils import nodes
|
||||
@@ -13,7 +12,6 @@ from docutils.writers.html5_polyglot import HTMLTranslator as BaseTranslator
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.locale import _, __, admonitionlabels
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.docutils import SphinxTranslator
|
||||
@@ -406,14 +404,11 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
return super().visit_literal_block(node)
|
||||
|
||||
lang = node.get('language', 'default')
|
||||
linenos = node.get('linenos', False)
|
||||
linenos = node.get('linenos', False) and "inline"
|
||||
highlight_args = node.get('highlight_args', {})
|
||||
highlight_args['force'] = node.get('force', False)
|
||||
opts = self.config.highlight_options.get(lang, {})
|
||||
|
||||
if linenos and self.config.html_codeblock_linenos_style:
|
||||
linenos = self.config.html_codeblock_linenos_style
|
||||
|
||||
highlighted = self.highlighter.highlight_block(
|
||||
node.rawsource, lang, opts=opts, linenos=linenos,
|
||||
location=node, **highlight_args
|
||||
@@ -820,30 +815,3 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
_, depart = self.builder.app.registry.html_block_math_renderers[name]
|
||||
if depart:
|
||||
depart(self, node)
|
||||
|
||||
def generate_targets_for_table(self, node: Element) -> None:
|
||||
"""Generate hyperlink targets for tables.
|
||||
|
||||
Original visit_table() generates hyperlink targets inside table tags
|
||||
(<table>) if multiple IDs are assigned to listings.
|
||||
That is invalid DOM structure. (This is a bug of docutils <= 0.13.1)
|
||||
|
||||
This exports hyperlink targets before tables to make valid DOM structure.
|
||||
"""
|
||||
warnings.warn('generate_targets_for_table() is deprecated',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
for id in node['ids'][1:]:
|
||||
self.body.append('<span id="%s"></span>' % id)
|
||||
node['ids'].remove(id)
|
||||
|
||||
@property
|
||||
def _fieldlist_row_index(self):
|
||||
warnings.warn('_fieldlist_row_index is deprecated',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
return self._fieldlist_row_indices[-1]
|
||||
|
||||
@property
|
||||
def _table_row_index(self):
|
||||
warnings.warn('_table_row_index is deprecated',
|
||||
RemovedInSphinx60Warning, stacklevel=2)
|
||||
return self._table_row_indices[-1]
|
||||
@@ -1226,7 +1226,7 @@ def test_assets_order(app):
|
||||
assert re.search(pattern, content, re.S)
|
||||
|
||||
# js_files
|
||||
expected = ['_static/early.js', '_static/jquery.js', '_static/underscore.js',
|
||||
expected = ['_static/early.js',
|
||||
'_static/doctools.js', 'https://example.com/script.js', '_static/normal.js',
|
||||
'_static/late.js', '_static/js/custom.js', '_static/lazy.js']
|
||||
pattern = '.*'.join('src="%s"' % f for f in expected)
|
||||
@@ -1625,24 +1625,8 @@ def test_html_scaled_image_link(app):
|
||||
context)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='reST-code-block',
|
||||
confoverrides={'html_codeblock_linenos_style': 'table'})
|
||||
def test_html_codeblock_linenos_style_table(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
if PYGMENTS_VERSION >= (2, 8):
|
||||
assert ('<div class="linenodiv"><pre><span class="normal">1</span>\n'
|
||||
'<span class="normal">2</span>\n'
|
||||
'<span class="normal">3</span>\n'
|
||||
'<span class="normal">4</span></pre></div>') in content
|
||||
else:
|
||||
assert '<div class="linenodiv"><pre>1\n2\n3\n4</pre></div>' in content
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='reST-code-block',
|
||||
confoverrides={'html_codeblock_linenos_style': 'inline'})
|
||||
def test_html_codeblock_linenos_style_inline(app):
|
||||
@pytest.mark.sphinx('html', testroot='reST-code-block')
|
||||
def test_html_codeblock_linenos_style(app):
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
|
||||
@@ -57,30 +57,6 @@ def test_theme_api(app, status, warning):
|
||||
assert not os.path.exists(themedir)
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='tocdepth') # a minimal root
|
||||
def test_js_source(app, status, warning):
|
||||
# Now sphinx provides non-minified JS files for jquery.js and underscore.js
|
||||
# to clarify the source of the minified files. see also #1434.
|
||||
# If you update the version of the JS file, please update the source of the
|
||||
# JS file and version number in this test.
|
||||
|
||||
app.builder.build(['contents'])
|
||||
|
||||
v = '3.6.0'
|
||||
msg = 'jquery.js version does not match to {v}'.format(v=v)
|
||||
jquery_min = (app.outdir / '_static' / 'jquery.js').read_text(encoding='utf8')
|
||||
assert 'jQuery v{v}'.format(v=v) in jquery_min, msg
|
||||
jquery_src = (app.outdir / '_static' / 'jquery-{v}.js'.format(v=v)).read_text(encoding='utf8')
|
||||
assert 'jQuery JavaScript Library v{v}'.format(v=v) in jquery_src, msg
|
||||
|
||||
v = '1.13.1'
|
||||
msg = 'underscore.js version does not match to {v}'.format(v=v)
|
||||
underscore_min = (app.outdir / '_static' / 'underscore.js').read_text(encoding='utf8')
|
||||
assert 'Underscore.js {v}'.format(v=v) in underscore_min, msg
|
||||
underscore_src = (app.outdir / '_static' / 'underscore-{v}.js'.format(v=v)).read_text(encoding='utf8')
|
||||
assert 'Underscore.js {v}'.format(v=v) in underscore_src, msg
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='double-inheriting-theme')
|
||||
def test_double_inheriting_theme(app, status, warning):
|
||||
assert app.builder.theme.name == 'base_theme2'
|
||||
|
||||
Reference in new issue
Block a user