Skip to content

Commit cf8abe5

Browse files
N-WoudaAWhetter
authored andcommitted
Import fallback for older versions of Sphinx
1 parent 0186a3c commit cf8abe5

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

autoapi/mappers/base.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
from sphinx.util.osutil import ensuredir
1212
import sphinx.util.logging
1313

14+
try:
15+
from sphinx.util.display import status_iterator
16+
except ImportError:
17+
# This method was moved into sphinx.util.display in Sphinx 6.1.0. Before
18+
# that it resided in sphinx.util.
19+
from sphinx.util import status_iterator
20+
1421
from ..settings import API_ROOT, TEMPLATE_DIR
1522

1623
LOGGER = sphinx.util.logging.getLogger(__name__)
@@ -207,7 +214,7 @@ def _wrapped_prepare(value):
207214
def load(self, patterns, dirs, ignore=None):
208215
"""Load objects from the filesystem into the ``paths`` dictionary."""
209216
paths = list(self.find_files(patterns=patterns, dirs=dirs, ignore=ignore))
210-
for path in sphinx.util.display.status_iterator(
217+
for path in status_iterator(
211218
paths,
212219
colorize("bold", "[AutoAPI] Reading files... "),
213220
"darkgreen",
@@ -290,7 +297,7 @@ def add_object(self, obj):
290297

291298
def map(self, options=None):
292299
"""Trigger find of serialized sources and build objects"""
293-
for _, data in sphinx.util.display.status_iterator(
300+
for _, data in status_iterator(
294301
self.paths.items(),
295302
colorize("bold", "[AutoAPI] ") + "Mapping Data... ",
296303
length=len(self.paths),
@@ -308,7 +315,7 @@ def create_class(self, data, options=None, **kwargs):
308315
raise NotImplementedError
309316

310317
def output_rst(self, root, source_suffix):
311-
for _, obj in sphinx.util.display.status_iterator(
318+
for _, obj in status_iterator(
312319
self.objects.items(),
313320
colorize("bold", "[AutoAPI] ") + "Rendering Data... ",
314321
length=len(self.objects),

autoapi/mappers/python/mapper.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
import sphinx.util.docstrings
1212
import sphinx.util.logging
1313

14+
try:
15+
from sphinx.util.display import status_iterator
16+
except ImportError:
17+
# This method was moved into sphinx.util.display in Sphinx 6.1.0. Before
18+
# that it resided in sphinx.util.
19+
from sphinx.util import status_iterator
20+
1421
from ..base import SphinxMapperBase
1522
from .parser import Parser
1623
from .objects import (
@@ -291,7 +298,7 @@ def load(self, patterns, dirs, ignore=None):
291298
)
292299
return False
293300

294-
for dir_root, path in sphinx.util.display.status_iterator(
301+
for dir_root, path in status_iterator(
295302
dir_root_files,
296303
colorize("bold", "[AutoAPI] Reading files... "),
297304
length=len(dir_root_files),

0 commit comments

Comments
 (0)