Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Autosummary.warn() calls with logger.warning() for Sphinx 4 compatibility #129

Merged
merged 1 commit into from May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 8 additions & 11 deletions sphinx_automodapi/automodsumm.py
Expand Up @@ -98,6 +98,7 @@ class members that are inherited from a base class. This value can be

__all__ = ['Automoddiagram', 'Automodsumm', 'automodsumm_to_autosummary_lines',
'generate_automodsumm_docs', 'process_automodsumm_generation']
logger = logging.getLogger(__name__)


def _str_list_converter(argument):
Expand Down Expand Up @@ -134,7 +135,7 @@ def run(self):
try:
localnames, fqns, objs = find_mod_objs(modname)
except ImportError:
self.warn("Couldn't import module " + modname)
logger.warning("Couldn't import module " + modname)
return []

try:
Expand All @@ -144,8 +145,8 @@ def run(self):
clsonly = 'classes-only' in self.options
varonly = 'variables-only' in self.options
if [clsonly, funconly, varonly].count(True) > 1:
self.warn('more than one of "functions-only", "classes-only", '
'or "variables-only" defined. Ignoring.')
logger.warning('more than one of "functions-only", "classes-only", '
'or "variables-only" defined. Ignoring.')
clsonly = funconly = varonly = False

skipnames = []
Expand All @@ -156,9 +157,9 @@ def run(self):
option_skipnames.remove(lnm)
skipnames.append(lnm)
if len(option_skipnames) > 0:
self.warn('Tried to skip objects {objs} in module {mod}, '
'but they were not present. Ignoring.'
.format(objs=option_skipnames, mod=modname))
logger.warning('Tried to skip objects {objs} in module {mod}, '
'but they were not present. Ignoring.'
.format(objs=option_skipnames, mod=modname))

if funconly:
cont = []
Expand Down Expand Up @@ -217,7 +218,7 @@ def run(self):

nms, objs = find_mod_objs(self.arguments[0], onlylocals=ols)[1:]
except ImportError:
self.warn("Couldn't import module " + self.arguments[0])
logger.warning("Couldn't import module " + self.arguments[0])
return []

# Check if some classes should be skipped
Expand Down Expand Up @@ -309,8 +310,6 @@ def automodsumm_to_autosummary_lines(fn, app):

"""

logger = logging.getLogger(__name__)

fullfn = os.path.join(app.builder.env.srcdir, fn)

with io.open(fullfn, encoding='utf8') as fr:
Expand Down Expand Up @@ -425,8 +424,6 @@ def generate_automodsumm_docs(lines, srcfn, app=None, suffix='.rst',

from .utils import find_autosummary_in_lines_for_automodsumm as find_autosummary_in_lines

logger = logging.getLogger(__name__)
JWCook marked this conversation as resolved.
Show resolved Hide resolved

# Create our own templating environment - here we use Astropy's
# templates rather than the default autosummary templates, in order to
# allow docstrings to be shown for methods.
Expand Down