Skip to content

Commit

Permalink
Remove deprecated aliases in preparation for version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Apr 21, 2022
1 parent 5b74092 commit 8827a82
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 194 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Expand Up @@ -2,7 +2,6 @@ apeye>=0.4.0
autodocsumm>=0.2.0
beautifulsoup4>=4.9.1
cachecontrol[filecache]>=0.12.6
deprecation-alias>=0.2.0
dict2css>=0.2.3
docutils<0.18,>=0.16
domdf-python-tools>=2.9.0
Expand Down
54 changes: 0 additions & 54 deletions sphinx_toolbox/issues.py
Expand Up @@ -122,73 +122,19 @@
#

# 3rd party
from deprecation_alias import deprecated
from sphinx.application import Sphinx

# this package
import sphinx_toolbox.github.issues
from sphinx_toolbox.github.issues import issue_role, pull_role
from sphinx_toolbox.utils import SphinxExtMetadata, metadata_add_version

__all__ = [
"IssueNode",
"issue_role",
"pull_role",
"visit_issue_node",
"depart_issue_node",
"get_issue_title",
"setup",
]


class IssueNode(sphinx_toolbox.github.issues.IssueNode):
"""
Docutils Node to represent a link to a GitHub *Issue* or *Pull Request*.
:param issue_number: The number of the issue or pull request.
:param refuri: The URL of the issue / pull request on GitHub.
.. deprecated:: 2.4.0
This will be removed in 3.0.0. Import from 'sphinx_toolbox.github.issues' instead.
"""

@deprecated(
deprecated_in="2.4.0",
removed_in="3.0.0",
current_version="3.0.0a1",
details="Import from 'sphinx_toolbox.github.issues' instead.",
name="IssueNode",
)
def __init__(self, *args, **kwargs): # pragma: no cover
super().__init__(*args, **kwargs)


visit_issue_node = deprecated(
deprecated_in="2.4.0",
removed_in="3.0.0",
current_version="3.0.0a1",
details="Import from 'sphinx_toolbox.github.issues' instead.",
func=sphinx_toolbox.github.issues.visit_issue_node,
)

depart_issue_node = deprecated(
deprecated_in="2.4.0",
removed_in="3.0.0",
current_version="3.0.0a1",
details="Import from 'sphinx_toolbox.github.issues' instead.",
func=sphinx_toolbox.github.issues.depart_issue_node,
)

get_issue_title = deprecated(
deprecated_in="2.4.0",
removed_in="3.0.0",
current_version="3.0.0a1",
details="Import from 'sphinx_toolbox.github.issues' instead.",
func=sphinx_toolbox.github.issues.get_issue_title,
)


@metadata_add_version
def setup(app: Sphinx) -> SphinxExtMetadata:
"""
Expand Down
14 changes: 1 addition & 13 deletions sphinx_toolbox/tweaks/sphinx_panels_tabs.py
Expand Up @@ -44,7 +44,6 @@

# 3rd party
import dict2css
from deprecation_alias import deprecated
from docutils import nodes
from domdf_python_tools.paths import PathPlus
from sphinx.application import Sphinx
Expand Down Expand Up @@ -82,8 +81,7 @@ def copy_asset_files(app: Sphinx, exception: Optional[Exception] = None) -> None
.. versionchanged:: 2.7.0
Renamed from ``copy_assets``.
The old name is deprecated an will be removed in 3.0.0
Renamed from ``copy_assets``. The former name was kept as an alias until version 3.0.0
"""

if exception: # pragma: no cover
Expand Down Expand Up @@ -116,16 +114,6 @@ def copy_asset_files(app: Sphinx, exception: Optional[Exception] = None) -> None
dict2css.dump(_css.tweaks_sphinx_panels_tabs_styles, css_static_dir / "tabs_customise.css")


copy_assets = deprecated(
deprecated_in="2.7.0",
removed_in="3.0.0",
current_version=__version__,
details="Renamed to 'copy_asset_files'",
name="copy_assets",
func=copy_asset_files,
)


@metadata_add_version
def setup(app: Sphinx) -> SphinxExtMetadata:
"""
Expand Down
89 changes: 0 additions & 89 deletions sphinx_toolbox/utils.py
Expand Up @@ -55,7 +55,6 @@
# 3rd party
import sphinx.config
from apeye.requests_url import RequestsURL
from deprecation_alias import deprecated
from docutils.nodes import Node
from domdf_python_tools.doctools import prettify_docstrings
from sphinx.addnodes import desc_content
Expand All @@ -71,7 +70,6 @@
"add_nbsp_substitution",
"allow_subclass_add",
"baseclass_is_private",
"begin_generate",
"code_repr",
"escape_trailing__",
"filter_members_warning",
Expand Down Expand Up @@ -382,93 +380,6 @@ class SphinxExtMetadata(TypedDict, total=False):
"""


@deprecated(
deprecated_in="2.16.0",
removed_in="3.0.0",
current_version="3.0.0a1",
details="Users of this function should reimplement it in their own code.",
)
def begin_generate(
documenter: Documenter,
real_modname: Optional[str] = None,
check_module: bool = False,
) -> Optional[str]:
"""
Boilerplate for the top of ``generate`` in :class:`sphinx.ext.autodoc.Documenter` subclasses.
.. versionadded:: 0.2.0
:param documenter:
:param real_modname:
:param check_module:
:return: The ``sourcename``, or :py:obj:`None` if certain conditions are met,
to indicate that the Documenter class should exit early.
"""

# Do not pass real_modname and use the name from the __module__
# attribute of the class.
# If a class gets imported into the module real_modname
# the analyzer won't find the source of the class, if
# it looks in real_modname.

if not documenter.parse_name():
# need a module to import
unknown_module_warning(documenter)
return None

# now, import the module and get object to document
if not documenter.import_object():
return None

# If there is no real module defined, figure out which to use.
# The real module is used in the module analyzer to look up the module
# where the attribute documentation would actually be found in.
# This is used for situations where you have a module that collects the
# functions and classes of internal submodules.
guess_modname = documenter.get_real_modname()
documenter.real_modname = real_modname or guess_modname

# try to also get a source code analyzer for attribute docs
try:
documenter.analyzer = ModuleAnalyzer.for_module(documenter.real_modname)
# parse right now, to get PycodeErrors on parsing (results will
# be cached anyway)
documenter.analyzer.find_attr_docs()

except PycodeError as err:
logger.debug("[autodoc] module analyzer failed: %s", err)
# no source file -- e.g. for builtin and C modules
documenter.analyzer = None # type: ignore[assignment]
# at least add the module.__file__ as a dependency
if hasattr(documenter.module, "__file__") and documenter.module.__file__:
documenter.directive.filename_set.add(documenter.module.__file__)
else:
documenter.directive.filename_set.add(documenter.analyzer.srcname)

if documenter.real_modname != guess_modname:
# Add module to dependency list if target object is defined in other module.
try:
analyzer = ModuleAnalyzer.for_module(guess_modname)
documenter.directive.filename_set.add(analyzer.srcname)
except PycodeError:
pass

# check __module__ of object (for members not given explicitly)
if check_module:
if not documenter.check_module():
return None

sourcename = documenter.get_sourcename()

# make sure that the result starts with an empty line. This is
# necessary for some situations where another directive preprocesses
# reST and no starting newline is present
documenter.add_line('', sourcename)

return sourcename


def unknown_module_warning(documenter: Documenter) -> None:
"""
Log a warning that the module to import the object from is unknown.
Expand Down
37 changes: 0 additions & 37 deletions tests/test_issues.py
Expand Up @@ -2,7 +2,6 @@
import pytest
from apeye.requests_url import RequestsURL
from coincidence.params import count
from deprecation import fail_if_not_removed # type: ignore[import]
from docutils.nodes import system_message
from docutils.utils import Reporter

Expand All @@ -11,7 +10,6 @@
from sphinx_toolbox import issues
from sphinx_toolbox.github.issues import IssueNode, issue_role, pull_role
from sphinx_toolbox.testing import run_setup
from sphinx_toolbox.utils import make_github_url
from tests.common import AttrDict


Expand Down Expand Up @@ -194,41 +192,6 @@ def depart_reference(self, node):
pass


@fail_if_not_removed
def test_visit_issue_node():
node = IssueNode(7680, make_github_url("pytest-dev", "pytest") / "issues/7680")
translator = FakeTranslator()

assert not node.has_tooltip

with pytest.warns(DeprecationWarning):
issues.visit_issue_node(translator, node)

assert translator.body == ['<abbr title="Add --log-cli option">']
assert node.has_tooltip


@fail_if_not_removed
def test_depart_issue_node():
node = IssueNode(7680, make_github_url("pytest-dev", "pytest") / "issues/7680")
translator = FakeTranslator()
assert not node.has_tooltip

with pytest.warns(DeprecationWarning):
issues.depart_issue_node(translator, node)

assert translator.body == []

node = IssueNode(7680, make_github_url("pytest-dev", "pytest") / "issues/7680")
translator = FakeTranslator()
node.has_tooltip = True

with pytest.warns(DeprecationWarning):
issues.depart_issue_node(translator, node)

assert translator.body == ["</abbr>"]


#
# @pytest.fixture()
# def rootdir():
Expand Down

0 comments on commit 8827a82

Please sign in to comment.