summaryrefslogtreecommitdiff
path: root/sphinx/ext/autodoc/deprecated.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-01-24 16:34:47 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-01-24 16:34:47 +0900
commit51d500833e391c182f536e83a5d62d5e90ce8ca9 (patch)
treefb854309b759773feb83e7e4bbc91e3ed3cb2b00 /sphinx/ext/autodoc/deprecated.py
parent375fb52fe402d46d633e321ce8f20c1aa61c49b9 (diff)
parent41ee2d6e6595d0eefb4a2b752fd79a3451382d5a (diff)
downloadsphinx-git-51d500833e391c182f536e83a5d62d5e90ce8ca9.tar.gz
Merge branch '3.x' into 7774_remove_develop.rst
Diffstat (limited to 'sphinx/ext/autodoc/deprecated.py')
-rw-r--r--sphinx/ext/autodoc/deprecated.py126
1 files changed, 126 insertions, 0 deletions
diff --git a/sphinx/ext/autodoc/deprecated.py b/sphinx/ext/autodoc/deprecated.py
new file mode 100644
index 000000000..80a94f0ea
--- /dev/null
+++ b/sphinx/ext/autodoc/deprecated.py
@@ -0,0 +1,126 @@
+"""
+ sphinx.ext.autodoc.deprecated
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ The deprecated Documenters for autodoc.
+
+ :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import warnings
+from typing import Any
+
+from sphinx.deprecation import RemovedInSphinx50Warning
+from sphinx.ext.autodoc import (AttributeDocumenter, DataDocumenter, FunctionDocumenter,
+ MethodDocumenter)
+
+
+class SingledispatchFunctionDocumenter(FunctionDocumenter):
+ """
+ Used to be a specialized Documenter subclass for singledispatch'ed functions.
+
+ Retained for backwards compatibility, now does the same as the FunctionDocumenter
+ """
+
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ warnings.warn("%s is deprecated." % self.__class__.__name__,
+ RemovedInSphinx50Warning, stacklevel=2)
+ super().__init__(*args, **kwargs)
+
+
+class DataDeclarationDocumenter(DataDocumenter):
+ """
+ Specialized Documenter subclass for data that cannot be imported
+ because they are declared without initial value (refs: PEP-526).
+ """
+ objtype = 'datadecl'
+ directivetype = 'data'
+ member_order = 60
+
+ # must be higher than AttributeDocumenter
+ priority = 11
+
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ warnings.warn("%s is deprecated." % self.__class__.__name__,
+ RemovedInSphinx50Warning, stacklevel=2)
+ super().__init__(*args, **kwargs)
+
+
+class TypeVarDocumenter(DataDocumenter):
+ """
+ Specialized Documenter subclass for TypeVars.
+ """
+
+ objtype = 'typevar'
+ directivetype = 'data'
+ priority = DataDocumenter.priority + 1 # type: ignore
+
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ warnings.warn("%s is deprecated." % self.__class__.__name__,
+ RemovedInSphinx50Warning, stacklevel=2)
+ super().__init__(*args, **kwargs)
+
+
+class SingledispatchMethodDocumenter(MethodDocumenter):
+ """
+ Used to be a specialized Documenter subclass for singledispatch'ed methods.
+
+ Retained for backwards compatibility, now does the same as the MethodDocumenter
+ """
+
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ warnings.warn("%s is deprecated." % self.__class__.__name__,
+ RemovedInSphinx50Warning, stacklevel=2)
+ super().__init__(*args, **kwargs)
+
+
+class InstanceAttributeDocumenter(AttributeDocumenter):
+ """
+ Specialized Documenter subclass for attributes that cannot be imported
+ because they are instance attributes (e.g. assigned in __init__).
+ """
+ objtype = 'instanceattribute'
+ directivetype = 'attribute'
+ member_order = 60
+
+ # must be higher than AttributeDocumenter
+ priority = 11
+
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ warnings.warn("%s is deprecated." % self.__class__.__name__,
+ RemovedInSphinx50Warning, stacklevel=2)
+ super().__init__(*args, **kwargs)
+
+
+class SlotsAttributeDocumenter(AttributeDocumenter):
+ """
+ Specialized Documenter subclass for attributes that cannot be imported
+ because they are attributes in __slots__.
+ """
+ objtype = 'slotsattribute'
+ directivetype = 'attribute'
+ member_order = 60
+
+ # must be higher than AttributeDocumenter
+ priority = 11
+
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ warnings.warn("%s is deprecated." % self.__class__.__name__,
+ RemovedInSphinx50Warning, stacklevel=2)
+ super().__init__(*args, **kwargs)
+
+
+class GenericAliasDocumenter(DataDocumenter):
+ """
+ Specialized Documenter subclass for GenericAliases.
+ """
+
+ objtype = 'genericalias'
+ directivetype = 'data'
+ priority = DataDocumenter.priority + 1 # type: ignore
+
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ warnings.warn("%s is deprecated." % self.__class__.__name__,
+ RemovedInSphinx50Warning, stacklevel=2)
+ super().__init__(*args, **kwargs)