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,8 +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 )
273
-
278
+ inherited_members = app .config .automodsumm_inherited_members ,
279
+ included_members = app . config . automodsumm_included_members )
274
280
275
281
# _automodsummrex = re.compile(r'^(\s*)\.\. automodsumm::\s*([A-Za-z0-9_.]+)\s*'
276
282
# r'\n\1(\s*)(\S|$)', re.MULTILINE)
@@ -406,7 +412,8 @@ def automodsumm_to_autosummary_lines(fn, app):
406
412
def generate_automodsumm_docs (lines , srcfn , app = None , suffix = '.rst' ,
407
413
base_path = None , builder = None ,
408
414
template_dir = None ,
409
- inherited_members = False ):
415
+ inherited_members = False ,
416
+ included_members = ('__init__' , '__call__' )):
410
417
"""
411
418
This function is adapted from
412
419
`sphinx.ext.autosummary.generate.generate_autosummmary_docs` to
@@ -581,11 +588,10 @@ def get_members_class(obj, typ, include_public=[],
581
588
# use default value
582
589
include_base = inherited_members
583
590
584
- api_class_methods = ['__init__' , '__call__' ]
585
591
ns ['members' ] = get_members_class (obj , None ,
586
592
include_base = include_base )
587
593
ns ['methods' ], ns ['all_methods' ] = \
588
- get_members_class (obj , 'method' , api_class_methods ,
594
+ get_members_class (obj , 'method' , included_members ,
589
595
include_base = include_base )
590
596
ns ['attributes' ], ns ['all_attributes' ] = \
591
597
get_members_class (obj , 'attribute' ,
@@ -664,6 +670,8 @@ def setup(app):
664
670
665
671
app .add_config_value ('automodsumm_writereprocessed' , False , True )
666
672
app .add_config_value ('automodsumm_inherited_members' , False , 'env' )
673
+ app .add_config_value (
674
+ 'automodsumm_included_members' , ['__init__' , '__call__' ], 'env' )
667
675
668
676
return {'parallel_read_safe' : True ,
669
677
'parallel_write_safe' : True }
0 commit comments