File: config.rst

package info (click to toggle)
sphinx-autoapi 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 884 kB
  • sloc: python: 5,260; makefile: 7
file content (297 lines) | stat: -rw-r--r-- 9,992 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
Configuration Options
=====================

.. confval:: autoapi_dirs

   **Required**

   Paths (relative or absolute) to the source code that you wish to generate your API documentation from.
   The paths are searched recursively for files matching :confval:`autoapi_file_patterns`.
   Relative paths should be relative to the source directory of your documentation.

   For Python, if a package directory is specified,
   the package directory itself will be included in the relative path of the children.
   If an ordinary directory is specified,
   that directory will not be included in the relative path.

.. confval:: autoapi_template_dir

   Default: ``''``

   A directory that has user-defined templates to override our default templates.
   The path can either be absolute,
   or relative to the source directory of your documentation files.
   An path relative to where `sphinx-build` is run
   is allowed for backwards compatibility only
   and will be removed in a future version.

   You can view the default templates in the
   `autoapi/templates <https://github.com/readthedocs/sphinx-autoapi/tree/master/autoapi/templates>`_
   directory of the package.

.. confval:: autoapi_file_patterns

   Default: ``['*.py', '*.pyi']``

   A list containing the file patterns to look for when generating documentation.
   Patterns should be listed in order of preference.
   For example,
   if ``autoapi_file_patterns`` is set to the default value
   and a `.py` file and a `.pyi` file are found,
   then the `.py` will be read.

.. confval:: autoapi_generate_api_docs

   Default: ``True``

   Whether to generate API documentation.
   If this is ``False``, documentation should be generated though the
   :doc:`directives`.


Customisation Options
---------------------

.. confval:: autoapi_options

   Default: [
   ``'members'``,
   ``'undoc-members'``,
   ``'private-members'``,
   ``'show-inheritance'``,
   ``'show-module-summary'``,
   ``'special-members'``,
   ``'imported-members'``,
   ]

   Options for display of the generated documentation.

   * ``members``: Display children of an object
   * ``inherited-members``: Display children of an object
     that have been inherited from a base class.
     Members from standard library base classes are not included,
     unless the base class is abstract.
   * ``undoc-members``: Display objects that have no docstring
   * ``private-members``: Display private objects (eg. ``_foo`` in Python)
   * ``special-members``: Display special objects (eg. ``__foo__`` in Python)
   * ``show-inheritance``: Display a list of base classes below the class signature.
   * ``show-inheritance-diagram``: Display an inheritance diagram in
     generated class documentation.
     It makes use of the :mod:`sphinx.ext.inheritance_diagram` extension,
     and requires `Graphviz <https://graphviz.org/>`_ to be installed.
   * ``show-module-summary``: Whether to include autosummary directives
     in generated module documentation.
   * ``imported-members``: For objects imported into a package,
     display objects imported from the same top level package or module.
     This option does not effect objects imported into a module.


.. confval:: autoapi_ignore

   Default: ``['*migrations*']``

   A list of patterns to ignore when finding directories and files to document.

.. confval:: autoapi_root

   Default: ``autoapi``

   Path to output the generated AutoAPI files into,
   including the generated index page.
   This path must be relative to the source directory of your documentation files.
   This can be used to place the generated documentation
   anywhere in your documentation hierarchy.

.. confval:: autoapi_add_toctree_entry

   Default: ``True``

   Whether to insert the generated documentation into the TOC tree.
   If this is ``False``, the default AutoAPI index page is not generated
   and you will need to include the generated documentation
   in a TOC tree entry yourself.

.. confval:: autoapi_python_class_content

   Default: ``class``

   Which docstring to insert into the content of a class.

   * ``class``: Use only the class docstring.
   * ``both``: Use the concatenation of the class docstring and the
     ``__init__`` docstring.
   * ``init``: Use only the ``__init__`` docstring.

   If the class does not have an ``__init__`` or the ``__init__``
   docstring is empty and the class defines a ``__new__`` with a docstring,
   the ``__new__`` docstring is used instead of the ``__init__`` docstring.

.. confval:: autoapi_member_order

   Default: ``bysource``

   The order to document members. This option can have the following values:

   * ``alphabetical``: Order members by their name, case sensitively.

   * ``bysource``: Order members by the order that they were defined in the source code.

   * ``groupwise``: Order members by their type then alphabetically,
     ordering the types as follows:

     * Submodules and subpackages

     * Attributes

     * Exceptions

     * Classes

     * Functions

     * Methods


.. confval:: autoapi_python_use_implicit_namespaces

   Default: ``False``

   This changes the package detection behaviour to be compatible with :pep:`420`,
   but directories in :confval:`autoapi_dirs`
   are no longer searched recursively for packages.
   Instead, when this is ``True``,
   :confval:`autoapi_dirs` should point directly to
   the directories of implicit namespaces
   and the directories of packages.

   If searching is still required,
   this should be done manually in the ``conf.py``.


.. confval:: autoapi_prepare_jinja_env

   Default: ``None``

   A callback that is called shortly after the Jinja environment is created.
   The callback is passed the Jinja environment for editing before template rendering begins.

   The callback should have the following signature:

   .. py:function:: prepare_jinja_env(jinja_env: jinja2.Environment) -> None
      :noindex:


.. confval:: autoapi_own_page_level

   Default: ``'module'``

   This configuration value specifies the level at which objects are rendered on
   a single page. Valid levels, in descending order of hierarchy, are as
   follows:

   * ``module``: Packages, modules, subpackages, and submodules.

   * ``class``: Classes, exceptions, and all object types mentioned above.

   * ``function``: Functions, and all object types mentioned above.

   * ``method``: Methods, and all object types mentioned above.

   * ``attribute``: Class and module level attributes, properties,
     and all object types mentioned above.


Events
~~~~~~

The following events allow you to control the behaviour of AutoAPI.

.. event:: autoapi-skip-member (app, what, name, obj, skip, options)

   Emitted when a template has to decide whether a member should be included
   in the documentation.
   Usually the member is skipped if a handler returns ``True``,
   and included otherwise.
   Handlers should return ``None`` to fall back to the default skipping
   behaviour of AutoAPI or another attached handler.

   .. code-block:: python
      :caption: Example conf.py

      def skip_util_classes(app, what, name, obj, skip, options):
          if what == "class" and "util" in name:
             skip = True
          return skip

      def setup(sphinx):
         sphinx.connect("autoapi-skip-member", skip_util_classes)

   :param app: The Sphinx application object.
   :param what: The type of the object which the docstring belongs to.
      This can be one of:
      ``"attribute"``, ``"class"``, ``"data"``, ``"exception"``,
      ``"function"``, ``"method"``, ``"module"``, ``"package"``.
   :type what: str
   :param name: The fully qualified name of the object.
   :type name: str
   :param obj: The object itself.
   :type obj: PythonPythonMapper
   :param skip: Whether AutoAPI will skip this member if the handler
      does not override the decision.
   :type skip: bool
   :param options: The options given to the directive.


Advanced Options
-----------------

.. confval:: autoapi_keep_files

   Default: ``False``

   Keep the AutoAPI generated files on the filesystem after the run.
   Useful for debugging or transitioning to manual documentation.

   Keeping files will also allow AutoAPI to use incremental builds.
   Providing none of the source files have changed,
   AutoAPI will skip parsing the source code and regenerating the API documentation.


Suppressing Warnings
---------------------

.. confval:: suppress_warnings

   This is a sphinx builtin option that enables the granular filtering of AutoAPI
   generated warnings.

   Items in the ``suppress_warnings`` list are of the format ``"type.subtype"`` where
   ``".subtype"`` can be left out to cover all subtypes. To suppress all AutoAPI
   warnings add the type ``"autoapi"`` to the list:

   .. code-block:: python

      suppress_warnings = ["autoapi"]

   If narrower suppression is wanted, the available subtypes for AutoAPI are:

   * ``python_import_resolution``:
     Emitted if resolving references to objects in an imported module failed.
     Potential reasons include cyclical imports and missing (parent) modules.
   * ``not_readable``:
     Emitted if processing (opening, parsing, ...) an input file failed.
   * ``toc_reference``:
     Emitted if a reference to an entry in a table of content cannot be resolved.
   * ``nothing_rendered``:
     Emitted if nothing was found to be documented.
     Potential reasons include no files being found in :confval:`autoapi_dirs`
     that match :confval:`autoapi_file_patterns`,
     or all discovered modules and objects being excluded from rendering due to
     :confval:`autoapi_options` or :ref:`other rendering exclusions <customise-documented-api>`.

   So if all AutoAPI warnings concerning unreadable sources and failing Python imports should be
   filtered, but all other warnings should not, the option would be

   .. code-block:: python

      suppress_warnings = ["autoapi.python_import_resolution", "autoapi.not_readable"]