diff --git a/CHANGES b/CHANGES index c1390f046..a1e3c0ed4 100644 --- a/CHANGES +++ b/CHANGES @@ -72,6 +72,8 @@ New features added - The `autodoc` extension now offers a ``show-inheritance`` option for autoclass that inserts a list of bases after the signature. + - The autodoc directives now support the ``noindex`` flag option. + Bugs fixed ---------- diff --git a/doc/ext/autodoc.rst b/doc/ext/autodoc.rst index cf4dd5614..50e9efc7f 100644 --- a/doc/ext/autodoc.rst +++ b/doc/ext/autodoc.rst @@ -114,6 +114,13 @@ directive. .. versionadded:: 0.4 + * All autodoc directives support the ``noindex`` flag option that has the + same effect as for standard :dir:`function` etc. directives: no index + entries are generated for the documented object (and all autodocumented + members). + + .. versionadded:: 0.4 + .. note:: In an :dir:`automodule` directive with the ``members`` option set, only diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 49180e611..aacd268f9 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -314,6 +314,8 @@ def generate_rst(what, name, members, options, add_content, document, lineno, # Be explicit about the module, this is necessary since .. class:: doesn't # support a prepended module name result.append(indent + u' :module: %s' % mod, '') + if options.noindex: + result.append(indent + u' :noindex:', '') result.append(u'', '') if options.show_inheritance and what in ('class', 'exception'): @@ -424,6 +426,7 @@ def _auto_directive(dirname, arguments, options, content, lineno, members = ['__all__'] genopt.undoc = 'undoc-members' in options genopt.show_inheritance = 'show-inheritance' in options + genopt.noindex = 'noindex' in options filename_set = set() warnings, result = generate_rst(what, name, members, genopt, content, state.document, @@ -469,9 +472,10 @@ def members_directive(arg): def setup(app): - mod_options = {'members': members_directive, 'undoc-members': directives.flag} + mod_options = {'members': members_directive, 'undoc-members': directives.flag, + 'noindex': directives.flag} cls_options = {'members': members_directive, 'undoc-members': directives.flag, - 'inherited-members': directives.flag, + 'noindex': directives.flag, 'inherited-members': directives.flag, 'show-inheritance': directives.flag} app.add_directive('automodule', auto_directive_withmembers, 1, (1, 0, 1), **mod_options) @@ -479,8 +483,11 @@ def setup(app): 1, (1, 0, 1), **cls_options) app.add_directive('autoexception', auto_directive_withmembers, 1, (1, 0, 1), **cls_options) - app.add_directive('autofunction', auto_directive, 1, (1, 0, 1)) - app.add_directive('automethod', auto_directive, 1, (1, 0, 1)) - app.add_directive('autoattribute', auto_directive, 1, (1, 0, 1)) + app.add_directive('autofunction', auto_directive, 1, (1, 0, 1) + noindex=directives.flag) + app.add_directive('automethod', auto_directive, 1, (1, 0, 1), + noindex=directives.flag) + app.add_directive('autoattribute', auto_directive, 1, (1, 0, 1), + noindex=directives.flag) app.add_config_value('automodule_skip_lines', 0, True) app.add_config_value('autoclass_content', 'class', True)