Skip to content

Commit

Permalink
Merge pull request #129 from JWCook/sphinx-4-compat
Browse files Browse the repository at this point in the history
Replace Autosummary.warn() calls with logger.warning() for Sphinx 4 compatibility
  • Loading branch information
saimn committed May 20, 2021
2 parents 769ea19 + b49e6b2 commit 39609d0
Showing 1 changed file with 8 additions and 11 deletions.
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__)

# 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

0 comments on commit 39609d0

Please sign in to comment.