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
@@ -295,7 +301,8 @@ def process_automodsumm_generation(app):
295
301
generate_automodsumm_docs (
296
302
lines , sfn , app = app , builder = app .builder ,
297
303
base_path = app .srcdir ,
298
- inherited_members = app .config .automodsumm_inherited_members )
304
+ inherited_members = app .config .automodsumm_inherited_members ,
305
+ included_members = app .config .automodsumm_included_members )
299
306
300
307
301
308
# _automodsummrex = re.compile(r'^(\s*)\.\. automodsumm::\s*([A-Za-z0-9_.]+)\s*'
@@ -432,7 +439,8 @@ def automodsumm_to_autosummary_lines(fn, app):
432
439
def generate_automodsumm_docs (lines , srcfn , app = None , suffix = '.rst' ,
433
440
base_path = None , builder = None ,
434
441
template_dir = None ,
435
- inherited_members = False ):
442
+ inherited_members = False ,
443
+ included_members = ('__init__' , '__call__' )):
436
444
"""
437
445
This function is adapted from
438
446
`sphinx.ext.autosummary.generate.generate_autosummmary_docs` to
@@ -593,11 +601,10 @@ def get_members_class(obj, typ, include_public=[],
593
601
# use default value
594
602
include_base = inherited_members
595
603
596
- api_class_methods = ['__init__' , '__call__' ]
597
604
ns ['members' ] = get_members_class (obj , None ,
598
605
include_base = include_base )
599
606
ns ['methods' ], ns ['all_methods' ] = \
600
- get_members_class (obj , 'method' , api_class_methods ,
607
+ get_members_class (obj , 'method' , included_members ,
601
608
include_base = include_base )
602
609
ns ['attributes' ], ns ['all_attributes' ] = \
603
610
get_members_class (obj , 'attribute' ,
@@ -676,6 +683,8 @@ def setup(app):
676
683
677
684
app .add_config_value ('automodsumm_writereprocessed' , False , True )
678
685
app .add_config_value ('automodsumm_inherited_members' , False , 'env' )
686
+ app .add_config_value (
687
+ 'automodsumm_included_members' , ['__init__' , '__call__' ], 'env' )
679
688
680
689
return {'parallel_read_safe' : True ,
681
690
'parallel_write_safe' : True }
0 commit comments