4646 in the generated documentation. The flags ``:inherited-members:`` or
4747 ``:no-inherited-members:`` allows overrriding this global setting.
4848
49- This extension also adds two sphinx configuration options:
49+ This extension also adds three sphinx configuration options:
5050
5151* ``automodsumm_writereprocessed``
5252 Should be a bool, and if ``True``, will cause `automodsumm`_ to write files
@@ -62,6 +62,12 @@ class members that are inherited from a base class. This value can be
6262 ``:inherited-members:`` or ``:no-inherited-members:`` options. Defaults to
6363 ``False``.
6464
65+ * ``automodsumm_included_members``
66+ A list of strings containing the names of hidden class members that should be
67+ included in the documentation. This is most commonly used to add special class
68+ methods like ``__getitem__`` and ``__setitem__``. Defaults to
69+ ``['__init__', '__call__']``.
70+
6571.. _sphinx.ext.autosummary: http://sphinx-doc.org/latest/ext/autosummary.html
6672.. _autosummary: http://sphinx-doc.org/latest/ext/autosummary.html#directive-autosummary
6773
@@ -269,8 +275,8 @@ def process_automodsumm_generation(app):
269275 generate_automodsumm_docs (
270276 lines , sfn , app = app , builder = app .builder ,
271277 base_path = app .srcdir ,
272- inherited_members = app .config .automodsumm_inherited_members )
273-
278+ inherited_members = app .config .automodsumm_inherited_members ,
279+ included_members = app . config . automodsumm_included_members )
274280
275281# _automodsummrex = re.compile(r'^(\s*)\.\. automodsumm::\s*([A-Za-z0-9_.]+)\s*'
276282# r'\n\1(\s*)(\S|$)', re.MULTILINE)
@@ -406,7 +412,8 @@ def automodsumm_to_autosummary_lines(fn, app):
406412def generate_automodsumm_docs (lines , srcfn , app = None , suffix = '.rst' ,
407413 base_path = None , builder = None ,
408414 template_dir = None ,
409- inherited_members = False ):
415+ inherited_members = False ,
416+ included_members = ('__init__' , '__call__' )):
410417 """
411418 This function is adapted from
412419 `sphinx.ext.autosummary.generate.generate_autosummmary_docs` to
@@ -581,11 +588,10 @@ def get_members_class(obj, typ, include_public=[],
581588 # use default value
582589 include_base = inherited_members
583590
584- api_class_methods = ['__init__' , '__call__' ]
585591 ns ['members' ] = get_members_class (obj , None ,
586592 include_base = include_base )
587593 ns ['methods' ], ns ['all_methods' ] = \
588- get_members_class (obj , 'method' , api_class_methods ,
594+ get_members_class (obj , 'method' , included_members ,
589595 include_base = include_base )
590596 ns ['attributes' ], ns ['all_attributes' ] = \
591597 get_members_class (obj , 'attribute' ,
@@ -664,6 +670,8 @@ def setup(app):
664670
665671 app .add_config_value ('automodsumm_writereprocessed' , False , True )
666672 app .add_config_value ('automodsumm_inherited_members' , False , 'env' )
673+ app .add_config_value (
674+ 'automodsumm_included_members' , ['__init__' , '__call__' ], 'env' )
667675
668676 return {'parallel_read_safe' : True ,
669677 'parallel_write_safe' : True }
0 commit comments