46
46
in the generated documentation. The flags ``:inherited-members:`` or
47
47
``:no-inherited-members:`` allows overrriding this global setting.
48
48
49
- This extension also adds two sphinx configuration options:
49
+ This extension also adds three sphinx configuration options:
50
50
51
51
* ``automodsumm_writereprocessed``
52
52
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
62
62
``:inherited-members:`` or ``:no-inherited-members:`` options. Defaults to
63
63
``False``.
64
64
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
+
65
71
.. _sphinx.ext.autosummary: http://sphinx-doc.org/latest/ext/autosummary.html
66
72
.. _autosummary: http://sphinx-doc.org/latest/ext/autosummary.html#directive-autosummary
67
73
@@ -269,7 +275,8 @@ def process_automodsumm_generation(app):
269
275
generate_automodsumm_docs (
270
276
lines , sfn , app = app , builder = app .builder ,
271
277
base_path = app .srcdir ,
272
- inherited_members = app .config .automodsumm_inherited_members )
278
+ inherited_members = app .config .automodsumm_inherited_members ,
279
+ included_members = app .config .automodsumm_included_members )
273
280
274
281
275
282
# _automodsummrex = re.compile(r'^(\s*)\.\. automodsumm::\s*([A-Za-z0-9_.]+)\s*'
@@ -406,7 +413,8 @@ def automodsumm_to_autosummary_lines(fn, app):
406
413
def generate_automodsumm_docs (lines , srcfn , app = None , suffix = '.rst' ,
407
414
base_path = None , builder = None ,
408
415
template_dir = None ,
409
- inherited_members = False ):
416
+ inherited_members = False ,
417
+ included_members = ('__init__' , '__call__' )):
410
418
"""
411
419
This function is adapted from
412
420
`sphinx.ext.autosummary.generate.generate_autosummmary_docs` to
@@ -581,11 +589,10 @@ def get_members_class(obj, typ, include_public=[],
581
589
# use default value
582
590
include_base = inherited_members
583
591
584
- api_class_methods = ['__init__' , '__call__' ]
585
592
ns ['members' ] = get_members_class (obj , None ,
586
593
include_base = include_base )
587
594
ns ['methods' ], ns ['all_methods' ] = \
588
- get_members_class (obj , 'method' , api_class_methods ,
595
+ get_members_class (obj , 'method' , included_members ,
589
596
include_base = include_base )
590
597
ns ['attributes' ], ns ['all_attributes' ] = \
591
598
get_members_class (obj , 'attribute' ,
@@ -664,6 +671,8 @@ def setup(app):
664
671
665
672
app .add_config_value ('automodsumm_writereprocessed' , False , True )
666
673
app .add_config_value ('automodsumm_inherited_members' , False , 'env' )
674
+ app .add_config_value (
675
+ 'automodsumm_included_members' , ['__init__' , '__call__' ], 'env' )
667
676
668
677
return {'parallel_read_safe' : True ,
669
678
'parallel_write_safe' : True }
0 commit comments