autodoc: allow specifying values to global arguments

Previously, users could specify a *list* of flags in their config files.
The flags were directive names that would otherwise be present in the
.rst files. However, as a list, it was not possible to specify values
to those flags, which *is* possible in .rst files.

For example, in .rst you could say

  :special-members: __init__, __iter__

And this would cause autodoc to generate documents for these methods that
it would otherwise ignore.

This commit changes the config option to instead accept a dictionary.
This is a dictionary whose keys can contain the same flag-names as before,
but whose values can contain the arguments as seen in .rst files.

The old list is still supported, for backwards compatibility, but the data
is transformed into a dictionary when the user's config is loaded.
This commit is contained in:
Lewis Haley
2018-08-08 16:26:11 +01:00
parent 87029392fd
commit 6e1e35c98a
5 changed files with 155 additions and 9 deletions

View File

@@ -353,8 +353,25 @@ There are also new config values that you can set:
the directive will be interpreted as if only ``:members:`` was given.
You can also set `autodoc_default_flags` to a dictionary, mapping option
names to the values which can used in .rst files. For example::
autodoc_default_flags = {
'members': 'var1, var2',
'member-order': 'bysource',
'special-members': '__init__',
'undoc-members': None,
}
Setting ``None`` is equivalent to giving the option name in the list format
(i.e. it means "yes/true/on").
.. versionadded:: 1.0
.. versionchanged:: 1.8
Specifying in dictionary format added.
.. confval:: autodoc_docstring_signature
Functions imported from C modules cannot be introspected, and therefore the