|
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 | + * ``:ignore-emptydoc:`` or ``:no-ignore-emptydoc:`` |
| 50 | + The global sphinx configuration option ``automodsumm_ignore_emptydoc`` |
| 51 | + decides if functions, classes, and class methods with empty |
| 52 | + ``__doc__`` attributes are included in the generated documentation. The flags |
| 53 | + ``:ignore-emptydoc:`` or ``:no-ignore-emptydoc:`` allows overrriding this |
| 54 | + global setting. |
| 55 | +
|
| 56 | +This extension also adds three sphinx configuration options: |
50 | 57 |
|
51 | 58 | * ``automodsumm_writereprocessed``
|
52 | 59 | Should be a bool, and if ``True``, will cause `automodsumm`_ to write files
|
|
56 | 63 | cause of sphinx warnings or other debugging. Defaults to ``False``.
|
57 | 64 |
|
58 | 65 | * ``automodsumm_inherited_members``
|
59 |
| - Should be a bool and if ``True``, will cause `automodsumm`_ to document |
| 66 | + Should be a bool, and if ``True``, will cause `automodsumm`_ to document |
60 | 67 | class members that are inherited from a base class. This value can be
|
61 | 68 | overriden for any particular automodsumm directive by including the
|
62 | 69 | ``:inherited-members:`` or ``:no-inherited-members:`` options. Defaults to
|
63 | 70 | ``False``.
|
64 | 71 |
|
| 72 | +* ``automodsumm_ignore_emptydoc`` |
| 73 | + Should be a bool, and if ``True``, will cause `automodsumm`_ to ignore |
| 74 | + functions, classes, and class methods with empty ``__doc__`` attributes. |
| 75 | + This value can be overridden for any particular automodsumm directive by including |
| 76 | + the ``:ignore-emptydoc:`` or ``:no-ignore-emptydoc:`` options. Defaults to |
| 77 | + ``False``. |
| 78 | +
|
65 | 79 | .. _sphinx.ext.autosummary: http://sphinx-doc.org/latest/ext/autosummary.html
|
66 | 80 | .. _autosummary: http://sphinx-doc.org/latest/ext/autosummary.html#directive-autosummary
|
67 | 81 |
|
@@ -124,6 +138,8 @@ class Automodsumm(Autosummary):
|
124 | 138 | option_spec['allowed-package-names'] = _str_list_converter
|
125 | 139 | option_spec['inherited-members'] = flag
|
126 | 140 | option_spec['no-inherited-members'] = flag
|
| 141 | + option_spec['ignore-emptydoc'] = flag |
| 142 | + option_spec['no-ignore-emptydoc'] = flag |
127 | 143 |
|
128 | 144 | def run(self):
|
129 | 145 | env = self.state.document.settings.env
|
@@ -269,6 +285,7 @@ def process_automodsumm_generation(app):
|
269 | 285 | generate_automodsumm_docs(
|
270 | 286 | lines, sfn, app=app, builder=app.builder,
|
271 | 287 | suffix=suffix, base_path=app.srcdir,
|
| 288 | + ignore_emptydoc=app.config.automodsumm_ignore_emptydoc, |
272 | 289 | inherited_members=app.config.automodsumm_inherited_members)
|
273 | 290 |
|
274 | 291 |
|
@@ -408,6 +425,7 @@ def automodsumm_to_autosummary_lines(fn, app):
|
408 | 425 | def generate_automodsumm_docs(lines, srcfn, app=None, suffix='.rst',
|
409 | 426 | base_path=None, builder=None,
|
410 | 427 | template_dir=None,
|
| 428 | + ignore_emptydoc=False, |
411 | 429 | inherited_members=False):
|
412 | 430 | """
|
413 | 431 | This function is adapted from
|
@@ -557,6 +575,12 @@ def get_members_class(obj, typ, include_public=[],
|
557 | 575 | documenter = get_documenter(app, safe_getattr(obj, name), obj)
|
558 | 576 | except AttributeError:
|
559 | 577 | continue
|
| 578 | + if ( |
| 579 | + ignore_emptydoc |
| 580 | + and documenter.objtype in ('method', 'class', 'function') |
| 581 | + and not getattr(safe_getattr(obj, name), '__doc__', '') |
| 582 | + ): |
| 583 | + continue |
560 | 584 | if typ is None or documenter.objtype == typ:
|
561 | 585 | items.append(name)
|
562 | 586 | elif typ == 'attribute' and documenter.objtype == 'property':
|
@@ -667,6 +691,7 @@ def setup(app):
|
667 | 691 |
|
668 | 692 | app.add_config_value('automodsumm_writereprocessed', False, True)
|
669 | 693 | app.add_config_value('automodsumm_inherited_members', False, 'env')
|
| 694 | + app.add_config_value('automodsumm_ignore_emptydoc', False, 'env') |
670 | 695 |
|
671 | 696 | return {'parallel_read_safe': True,
|
672 | 697 | 'parallel_write_safe': True}
|
0 commit comments