Skip to content

Commit 0286ca8

Browse files
authored
Merge pull request #100 from theOehrly/cleanup
Type hint mixin base class, fix some more minor style and typing issues
2 parents 5ef1b47 + 16bcd1c commit 0286ca8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

autodocsumm/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
__status__ = "Production"
4141

4242
from itertools import chain
43+
from typing import TYPE_CHECKING
4344

4445
from sphinx.util import logging
4546
import re
@@ -53,7 +54,7 @@
5354
from sphinx.ext.autodoc import (
5455
ClassDocumenter, ModuleDocumenter, ALL, PycodeError,
5556
ModuleAnalyzer, AttributeDocumenter, DataDocumenter, Options,
56-
prepare_docstring)
57+
Documenter, prepare_docstring)
5758
import sphinx.ext.autodoc as ad
5859

5960
signature = Signature = None
@@ -82,6 +83,12 @@ def force_decode(string: str, encoding: str) -> str:
8283
__version__ = _version.get_versions()['version']
8384

8485

86+
if TYPE_CHECKING: # pragma: no cover
87+
DOCUMENTER_MIXIN_BASE = Documenter
88+
else:
89+
DOCUMENTER_MIXIN_BASE = object
90+
91+
8592
logger = logging.getLogger(__name__)
8693

8794
#: Options of the :class:`sphinx.ext.autodoc.ModuleDocumenter` that have an
@@ -125,7 +132,7 @@ def _get_arg(param, pos, default, *args, **kwargs):
125132
return default
126133

127134

128-
class AutosummaryDocumenter(object):
135+
class AutosummaryDocumenter(DOCUMENTER_MIXIN_BASE):
129136
"""Abstract class for for extending Documenter methods
130137
131138
This classed is used as a base class for Documenters in order to provide
@@ -137,6 +144,8 @@ class AutosummaryDocumenter(object):
137144
#: Grouper functions
138145
grouper_funcs = []
139146

147+
member_sections: dict
148+
140149
def __init__(self):
141150
raise NotImplementedError
142151

@@ -287,7 +296,6 @@ def get_grouped_documenters(self, all_members=False):
287296
else:
288297
return documenters
289298

290-
291299
def add_autosummary(self, relative_ref_paths=False):
292300
"""Add the autosammary table of this documenter.
293301

0 commit comments

Comments
 (0)