mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5839 from jdufresne/description
Deprecate unused Exception attributes
This commit is contained in:
commit
6fe57436a8
3
CHANGES
3
CHANGES
@ -63,6 +63,9 @@ Deprecated
|
|||||||
* ``sphinx.cmd.quickstart.TERM_ENCODING``
|
* ``sphinx.cmd.quickstart.TERM_ENCODING``
|
||||||
* ``sphinx.config.check_unicode()``
|
* ``sphinx.config.check_unicode()``
|
||||||
* ``sphinx.config.string_classes``
|
* ``sphinx.config.string_classes``
|
||||||
|
* ``sphinx.domains.cpp.DefinitionError.description``
|
||||||
|
* ``sphinx.domains.cpp.NoOldIdError.description``
|
||||||
|
* ``sphinx.domains.cpp.UnsupportedMultiCharacterCharLiteral.decoded``
|
||||||
* ``sphinx.ext.autodoc.importer._MockImporter``
|
* ``sphinx.ext.autodoc.importer._MockImporter``
|
||||||
* ``sphinx.ext.autosummary.Autosummary.warn()``
|
* ``sphinx.ext.autosummary.Autosummary.warn()``
|
||||||
* ``sphinx.ext.autosummary.Autosummary.genopt``
|
* ``sphinx.ext.autosummary.Autosummary.genopt``
|
||||||
|
@ -172,6 +172,21 @@ The following is a list of deprecated interfaces.
|
|||||||
- 4.0
|
- 4.0
|
||||||
- ``[str]``
|
- ``[str]``
|
||||||
|
|
||||||
|
* - ``sphinx.domains.cpp.DefinitionError.description``
|
||||||
|
- 2.0
|
||||||
|
- 4.0
|
||||||
|
- ``str(exc)``
|
||||||
|
|
||||||
|
* - ``sphinx.domains.cpp.NoOldIdError.description``
|
||||||
|
- 2.0
|
||||||
|
- 4.0
|
||||||
|
- ``str(exc)``
|
||||||
|
|
||||||
|
* - ``sphinx.domains.cpp.UnsupportedMultiCharacterCharLiteral.decoded``
|
||||||
|
- 2.0
|
||||||
|
- 4.0
|
||||||
|
- ``str(exc)``
|
||||||
|
|
||||||
* - ``sphinx.ext.autosummary.Autosummary.warn()``
|
* - ``sphinx.ext.autosummary.Autosummary.warn()``
|
||||||
- 2.0
|
- 2.0
|
||||||
- 4.0
|
- 4.0
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import warnings
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from docutils import nodes, utils
|
from docutils import nodes, utils
|
||||||
@ -16,6 +17,7 @@ from docutils.parsers.rst import directives
|
|||||||
from six import text_type
|
from six import text_type
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
|
from sphinx.deprecation import RemovedInSphinx40Warning
|
||||||
from sphinx.directives import ObjectDescription
|
from sphinx.directives import ObjectDescription
|
||||||
from sphinx.domains import Domain, ObjType
|
from sphinx.domains import Domain, ObjType
|
||||||
from sphinx.environment import NoUri
|
from sphinx.environment import NoUri
|
||||||
@ -575,23 +577,23 @@ _id_explicit_cast = {
|
|||||||
|
|
||||||
class NoOldIdError(Exception):
|
class NoOldIdError(Exception):
|
||||||
# Used to avoid implementing unneeded id generation for old id schmes.
|
# Used to avoid implementing unneeded id generation for old id schmes.
|
||||||
def __init__(self, description=""):
|
@property
|
||||||
# type: (str) -> None
|
def description(self):
|
||||||
self.description = description
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
return self.description
|
warnings.warn('%s.description is deprecated. '
|
||||||
|
'Coerce the instance to a string instead.' % self.__class__.__name__,
|
||||||
|
RemovedInSphinx40Warning, stacklevel=2)
|
||||||
|
return str(self)
|
||||||
|
|
||||||
|
|
||||||
class DefinitionError(Exception):
|
class DefinitionError(Exception):
|
||||||
def __init__(self, description):
|
@property
|
||||||
# type: (str) -> None
|
def description(self):
|
||||||
self.description = description
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
return self.description
|
warnings.warn('%s.description is deprecated. '
|
||||||
|
'Coerce the instance to a string instead.' % self.__class__.__name__,
|
||||||
|
RemovedInSphinx40Warning, stacklevel=2)
|
||||||
|
return str(self)
|
||||||
|
|
||||||
|
|
||||||
class _DuplicateSymbolError(Exception):
|
class _DuplicateSymbolError(Exception):
|
||||||
@ -799,8 +801,13 @@ class ASTNumberLiteral(ASTBase):
|
|||||||
|
|
||||||
|
|
||||||
class UnsupportedMultiCharacterCharLiteral(Exception):
|
class UnsupportedMultiCharacterCharLiteral(Exception):
|
||||||
def __init__(self, decoded):
|
@property
|
||||||
self.decoded = decoded
|
def decoded(self):
|
||||||
|
# type: () -> str
|
||||||
|
warnings.warn('%s.decoded is deprecated. '
|
||||||
|
'Coerce the instance to a string instead.' % self.__class__.__name__,
|
||||||
|
RemovedInSphinx40Warning, stacklevel=2)
|
||||||
|
return str(self)
|
||||||
|
|
||||||
|
|
||||||
class ASTCharLiteral(ASTBase):
|
class ASTCharLiteral(ASTBase):
|
||||||
@ -4451,23 +4458,23 @@ class DefinitionParser:
|
|||||||
# type: (List[Any], str) -> DefinitionError
|
# type: (List[Any], str) -> DefinitionError
|
||||||
if len(errors) == 1:
|
if len(errors) == 1:
|
||||||
if len(header) > 0:
|
if len(header) > 0:
|
||||||
return DefinitionError(header + '\n' + errors[0][0].description)
|
return DefinitionError(header + '\n' + str(errors[0][0]))
|
||||||
else:
|
else:
|
||||||
return DefinitionError(errors[0][0].description)
|
return DefinitionError(str(errors[0][0]))
|
||||||
result = [header, '\n']
|
result = [header, '\n']
|
||||||
for e in errors:
|
for e in errors:
|
||||||
if len(e[1]) > 0:
|
if len(e[1]) > 0:
|
||||||
ident = ' '
|
ident = ' '
|
||||||
result.append(e[1])
|
result.append(e[1])
|
||||||
result.append(':\n')
|
result.append(':\n')
|
||||||
for line in e[0].description.split('\n'):
|
for line in str(e[0]).split('\n'):
|
||||||
if len(line) == 0:
|
if len(line) == 0:
|
||||||
continue
|
continue
|
||||||
result.append(ident)
|
result.append(ident)
|
||||||
result.append(line)
|
result.append(line)
|
||||||
result.append('\n')
|
result.append('\n')
|
||||||
else:
|
else:
|
||||||
result.append(e[0].description)
|
result.append(str(e[0]))
|
||||||
return DefinitionError(''.join(result))
|
return DefinitionError(''.join(result))
|
||||||
|
|
||||||
def status(self, msg):
|
def status(self, msg):
|
||||||
@ -5175,7 +5182,7 @@ class DefinitionParser:
|
|||||||
if not allow or not self.allowFallbackExpressionParsing:
|
if not allow or not self.allowFallbackExpressionParsing:
|
||||||
raise
|
raise
|
||||||
self.warn("Parsing of expression failed. Using fallback parser."
|
self.warn("Parsing of expression failed. Using fallback parser."
|
||||||
" Error was:\n%s" % e.description)
|
" Error was:\n%s" % e)
|
||||||
self.pos = prevPos
|
self.pos = prevPos
|
||||||
# and then the fallback scanning
|
# and then the fallback scanning
|
||||||
assert end is not None
|
assert end is not None
|
||||||
@ -6742,8 +6749,7 @@ class CPPExprRole:
|
|||||||
try:
|
try:
|
||||||
ast = parser.parse_expression()
|
ast = parser.parse_expression()
|
||||||
except DefinitionError as ex:
|
except DefinitionError as ex:
|
||||||
Warner().warn('Unparseable C++ expression: %r\n%s'
|
Warner().warn('Unparseable C++ expression: %r\n%s' % (text, ex))
|
||||||
% (text, text_type(ex.description)))
|
|
||||||
# see below
|
# see below
|
||||||
return [self.node_type(text, text, classes=classes)], []
|
return [self.node_type(text, text, classes=classes)], []
|
||||||
parentSymbol = env.temp_data.get('cpp:parent_symbol', None)
|
parentSymbol = env.temp_data.get('cpp:parent_symbol', None)
|
||||||
@ -6891,8 +6897,7 @@ class CPPDomain(Domain):
|
|||||||
# strange, that we don't get the error now, use the original
|
# strange, that we don't get the error now, use the original
|
||||||
return target, e
|
return target, e
|
||||||
t, ex = findWarning(e)
|
t, ex = findWarning(e)
|
||||||
warner.warn('Unparseable C++ cross-reference: %r\n%s'
|
warner.warn('Unparseable C++ cross-reference: %r\n%s' % (t, ex))
|
||||||
% (t, text_type(ex.description)))
|
|
||||||
return None, None
|
return None, None
|
||||||
parentKey = node.get("cpp:parent_key", None)
|
parentKey = node.get("cpp:parent_key", None)
|
||||||
rootSymbol = self.data['root_symbol']
|
rootSymbol = self.data['root_symbol']
|
||||||
|
Loading…
Reference in New Issue
Block a user