mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-12 16:32:10 -05:00
doc: Rework "extensions" documents
This is mostly spacing and other "niceness" fixes. Signed-off-by: Stephen Finucane <stephen@that.guru>
This commit is contained in:
1 parent
b595c4a45b
commit
0b81af6a2e
15 files changed
+52
-47
No files matched your search
@@ -405,6 +405,7 @@ There are also new config values that you can set:
|
|||||||
|
|
||||||
.. versionadded:: 1.7
|
.. versionadded:: 1.7
|
||||||
|
|
||||||
|
|
||||||
Docstring preprocessing
|
Docstring preprocessing
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ default. The ``autosectionlabel_prefix_document`` configuration variable can be
|
|||||||
used to make headings which appear multiple times but in different documents
|
used to make headings which appear multiple times but in different documents
|
||||||
unique.
|
unique.
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ The :mod:`sphinx.ext.autosummary` extension does this in two parts:
|
|||||||
These files by default contain only the corresponding
|
These files by default contain only the corresponding
|
||||||
:mod:`sphinx.ext.autodoc` directive, but can be customized with templates.
|
:mod:`sphinx.ext.autodoc` directive, but can be customized with templates.
|
||||||
|
|
||||||
|
|
||||||
.. rst:directive:: autosummary
|
.. rst:directive:: autosummary
|
||||||
|
|
||||||
Insert a table that contains links to documented items, and a short summary
|
Insert a table that contains links to documented items, and a short summary
|
||||||
@@ -59,7 +58,6 @@ The :mod:`sphinx.ext.autosummary` extension does this in two parts:
|
|||||||
:event:`autodoc-process-docstring` and :event:`autodoc-process-signature`
|
:event:`autodoc-process-docstring` and :event:`autodoc-process-signature`
|
||||||
hooks as :mod:`~sphinx.ext.autodoc`.
|
hooks as :mod:`~sphinx.ext.autodoc`.
|
||||||
|
|
||||||
|
|
||||||
**Options**
|
**Options**
|
||||||
|
|
||||||
* If you want the :rst:dir:`autosummary` table to also serve as a
|
* If you want the :rst:dir:`autosummary` table to also serve as a
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
.. module:: sphinx.ext.coverage
|
.. module:: sphinx.ext.coverage
|
||||||
:synopsis: Check Python modules and C API for coverage in the documentation.
|
:synopsis: Check Python modules and C API for coverage in the documentation.
|
||||||
|
|
||||||
|
|
||||||
This extension features one additional builder, the :class:`CoverageBuilder`.
|
This extension features one additional builder, the :class:`CoverageBuilder`.
|
||||||
|
|
||||||
.. class:: CoverageBuilder
|
.. class:: CoverageBuilder
|
||||||
@@ -14,7 +13,6 @@ This extension features one additional builder, the :class:`CoverageBuilder`.
|
|||||||
|
|
||||||
.. todo:: Write this section.
|
.. todo:: Write this section.
|
||||||
|
|
||||||
|
|
||||||
Several new configuration values can be used to specify what the builder
|
Several new configuration values can be used to specify what the builder
|
||||||
should check:
|
should check:
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ a comma-separated list of group names.
|
|||||||
|
|
||||||
Output text.
|
Output text.
|
||||||
|
|
||||||
|
|
||||||
The following is an example for the usage of the directives. The test via
|
The following is an example for the usage of the directives. The test via
|
||||||
:rst:dir:`doctest` and the test via :rst:dir:`testcode` and
|
:rst:dir:`doctest` and the test via :rst:dir:`testcode` and
|
||||||
:rst:dir:`testoutput` are equivalent. ::
|
:rst:dir:`testoutput` are equivalent. ::
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
.. versionadded:: 1.0
|
.. versionadded:: 1.0
|
||||||
|
|
||||||
|
|
||||||
This extension is meant to help with the common pattern of having many external
|
This extension is meant to help with the common pattern of having many external
|
||||||
links that point to URLs on one and the same site, e.g. links to bug trackers,
|
links that point to URLs on one and the same site, e.g. links to bug trackers,
|
||||||
version control web interfaces, or simply subpages in other websites. It does
|
version control web interfaces, or simply subpages in other websites. It does
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
.. highlight:: rest
|
|
||||||
|
|
||||||
:mod:`sphinx.ext.githubpages` -- Publish HTML docs in GitHub Pages
|
:mod:`sphinx.ext.githubpages` -- Publish HTML docs in GitHub Pages
|
||||||
==================================================================
|
==================================================================
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ your documents.
|
|||||||
|
|
||||||
It adds these directives:
|
It adds these directives:
|
||||||
|
|
||||||
|
|
||||||
.. rst:directive:: graphviz
|
.. rst:directive:: graphviz
|
||||||
|
|
||||||
Directive to embed graphviz code. The input code for ``dot`` is given as the
|
Directive to embed graphviz code. The input code for ``dot`` is given as the
|
||||||
|
|||||||
+12
-10
@@ -1,28 +1,30 @@
|
|||||||
.. highlight:: rest
|
|
||||||
|
|
||||||
.. _sphinx.ext.imgconverter:
|
.. _sphinx.ext.imgconverter:
|
||||||
|
|
||||||
:mod:`sphinx.ext.imgconverter` -- A reference implementation for image converter using Imagemagick
|
:mod:`sphinx.ext.imgconverter` -- A reference image converter using Imagemagick
|
||||||
==================================================================================================
|
===============================================================================
|
||||||
|
|
||||||
.. module:: sphinx.ext.imgconverter
|
.. module:: sphinx.ext.imgconverter
|
||||||
:synopsis: Convert images to appropriate format for builders
|
:synopsis: Convert images to appropriate format for builders
|
||||||
|
|
||||||
.. versionadded:: 1.6
|
.. versionadded:: 1.6
|
||||||
|
|
||||||
This extension converts images in your document to appropriate format for builders.
|
This extension converts images in your document to appropriate format for
|
||||||
For example, it allows you to use SVG images with LaTeX builder.
|
builders. For example, it allows you to use SVG images with LaTeX builder.
|
||||||
As a result, you don't mind what image format the builder supports.
|
As a result, you don't mind what image format the builder supports.
|
||||||
|
|
||||||
Internally, this extension uses Imagemagick_ to convert images.
|
Internally, this extension uses Imagemagick_ to convert images.
|
||||||
|
|
||||||
.. _Imagemagick: https://www.imagemagick.org/script/index.php
|
.. _Imagemagick: https://www.imagemagick.org/script/index.php
|
||||||
|
|
||||||
.. note:: Imagemagick rasterizes a SVG image on conversion. As a result, the image
|
.. note::
|
||||||
becomes not scalable. To avoid that, please use other image converters
|
|
||||||
like sphinxcontrib-svg2pdfconverter_ (which uses Inkscape or rsvg-convert).
|
Imagemagick rasterizes a SVG image on conversion. As a result, the image
|
||||||
|
becomes not scalable. To avoid that, please use other image converters like
|
||||||
|
`sphinxcontrib-svg2pdfconverter`__ (which uses Inkscape or
|
||||||
|
``rsvg-convert``).
|
||||||
|
|
||||||
|
.. __: https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter
|
||||||
|
|
||||||
.. _sphinxcontrib-svg2pdfconverter: https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|||||||
@@ -91,7 +91,9 @@ It adds this directive:
|
|||||||
.. versionchanged:: 1.7
|
.. versionchanged:: 1.7
|
||||||
Added ``top-classes`` option to limit the scope of inheritance graphs.
|
Added ``top-classes`` option to limit the scope of inheritance graphs.
|
||||||
|
|
||||||
New config values are:
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
.. confval:: inheritance_graph_attrs
|
.. confval:: inheritance_graph_attrs
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ Behind the scenes, this works as follows:
|
|||||||
specified individually, e.g. if the docs should be buildable without Internet
|
specified individually, e.g. if the docs should be buildable without Internet
|
||||||
access.
|
access.
|
||||||
|
|
||||||
Configuring Intersphinx
|
|
||||||
-----------------------
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
To use Intersphinx linking, add ``'sphinx.ext.intersphinx'`` to your
|
To use Intersphinx linking, add ``'sphinx.ext.intersphinx'`` to your
|
||||||
:confval:`extensions` config value, and use these new config values to activate
|
:confval:`extensions` config value, and use these new config values to activate
|
||||||
@@ -136,12 +137,14 @@ linking:
|
|||||||
exception is raised if the server has not issued a response for timeout
|
exception is raised if the server has not issued a response for timeout
|
||||||
seconds.
|
seconds.
|
||||||
|
|
||||||
|
|
||||||
Showing all links of an Intersphinx mapping file
|
Showing all links of an Intersphinx mapping file
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
To show all Intersphinx links and their targets of an Intersphinx mapping file, run
|
To show all Intersphinx links and their targets of an Intersphinx mapping file,
|
||||||
``python -msphinx.ext.intersphinx url-or-path``. This is helpful when searching for the root cause of a broken
|
run ``python -msphinx.ext.intersphinx url-or-path``. This is helpful when
|
||||||
Intersphinx link in a documentation project. The following example prints the Intersphinx mapping of the Python 3
|
searching for the root cause of a broken Intersphinx link in a documentation
|
||||||
|
project. The following example prints the Intersphinx mapping of the Python 3
|
||||||
documentation::
|
documentation::
|
||||||
|
|
||||||
$ python -msphinx.ext.intersphinx https://docs.python.org/3/objects.inv
|
$ python -msphinx.ext.intersphinx https://docs.python.org/3/objects.inv
|
||||||
@@ -16,6 +16,10 @@ found somewhere on the Internet.
|
|||||||
In your configuration, you need to specify a :confval:`linkcode_resolve`
|
In your configuration, you need to specify a :confval:`linkcode_resolve`
|
||||||
function that returns an URL based on the object.
|
function that returns an URL based on the object.
|
||||||
|
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
.. confval:: linkcode_resolve
|
.. confval:: linkcode_resolve
|
||||||
|
|
||||||
This is a function ``linkcode_resolve(domain, info)``,
|
This is a function ``linkcode_resolve(domain, info)``,
|
||||||
|
|||||||
+12
-14
@@ -1,5 +1,5 @@
|
|||||||
:mod:`sphinx.ext.napoleon` -- Support for NumPy and Google style docstrings
|
:mod:`sphinx.ext.napoleon` -- Support for NumPy and Google style docstrings
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
===========================================================================
|
||||||
|
|
||||||
.. module:: sphinx.ext.napoleon
|
.. module:: sphinx.ext.napoleon
|
||||||
:synopsis: Support for NumPy and Google style docstrings
|
:synopsis: Support for NumPy and Google style docstrings
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
.. versionadded:: 1.3
|
.. versionadded:: 1.3
|
||||||
|
|
||||||
Napoleon - *Marching toward legible docstrings*
|
Overview
|
||||||
===============================================
|
--------
|
||||||
|
|
||||||
.. highlight:: text
|
.. highlight:: text
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ Are you tired of writing docstrings that look like this::
|
|||||||
:returns: A buffered writable file descriptor
|
:returns: A buffered writable file descriptor
|
||||||
:rtype: BufferedFileStorage
|
:rtype: BufferedFileStorage
|
||||||
|
|
||||||
`ReStructuredText`_ is great, but it creates visually dense, hard to read
|
`reStructuredText`_ is great, but it creates visually dense, hard to read
|
||||||
`docstrings`_. Compare the jumble above to the same thing rewritten
|
`docstrings`_. Compare the jumble above to the same thing rewritten
|
||||||
according to the `Google Python Style Guide`_::
|
according to the `Google Python Style Guide`_::
|
||||||
|
|
||||||
@@ -40,8 +40,8 @@ according to the `Google Python Style Guide`_::
|
|||||||
|
|
||||||
Much more legible, no?
|
Much more legible, no?
|
||||||
|
|
||||||
Napoleon is a :doc:`../extensions` that enables Sphinx to parse both `NumPy`_
|
Napoleon is a :term:`extension` that enables Sphinx to parse both `NumPy`_ and
|
||||||
and `Google`_ style docstrings - the style recommended by `Khan Academy`_.
|
`Google`_ style docstrings - the style recommended by `Khan Academy`_.
|
||||||
|
|
||||||
Napoleon is a pre-processor that parses `NumPy`_ and `Google`_ style
|
Napoleon is a pre-processor that parses `NumPy`_ and `Google`_ style
|
||||||
docstrings and converts them to reStructuredText before Sphinx attempts to
|
docstrings and converts them to reStructuredText before Sphinx attempts to
|
||||||
@@ -61,7 +61,7 @@ source code files.
|
|||||||
https://github.com/Khan/style-guides/blob/master/style/python.md#docstrings
|
https://github.com/Khan/style-guides/blob/master/style/python.md#docstrings
|
||||||
|
|
||||||
Getting Started
|
Getting Started
|
||||||
---------------
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
1. After :doc:`setting up Sphinx </usage/quickstart>` to build your docs,
|
1. After :doc:`setting up Sphinx </usage/quickstart>` to build your docs,
|
||||||
enable napoleon in the Sphinx `conf.py` file::
|
enable napoleon in the Sphinx `conf.py` file::
|
||||||
@@ -77,7 +77,7 @@ Getting Started
|
|||||||
|
|
||||||
|
|
||||||
Docstrings
|
Docstrings
|
||||||
----------
|
~~~~~~~~~~
|
||||||
|
|
||||||
Napoleon interprets every docstring that :mod:`autodoc <sphinx.ext.autodoc>`
|
Napoleon interprets every docstring that :mod:`autodoc <sphinx.ext.autodoc>`
|
||||||
can find, including docstrings on: ``modules``, ``classes``, ``attributes``,
|
can find, including docstrings on: ``modules``, ``classes``, ``attributes``,
|
||||||
@@ -91,7 +91,7 @@ All standard reStructuredText formatting still works as expected.
|
|||||||
.. _Sections:
|
.. _Sections:
|
||||||
|
|
||||||
Docstring Sections
|
Docstring Sections
|
||||||
------------------
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
All of the following section headers are supported:
|
All of the following section headers are supported:
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ All of the following section headers are supported:
|
|||||||
* ``Yields``
|
* ``Yields``
|
||||||
|
|
||||||
Google vs NumPy
|
Google vs NumPy
|
||||||
---------------
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Napoleon supports two styles of docstrings: `Google`_ and `NumPy`_. The
|
Napoleon supports two styles of docstrings: `Google`_ and `NumPy`_. The
|
||||||
main difference between the two styles is that Google uses indention to
|
main difference between the two styles is that Google uses indention to
|
||||||
@@ -188,7 +188,7 @@ not be mixed. Choose one style for your project and be consistent with it.
|
|||||||
|
|
||||||
|
|
||||||
Type Annotations
|
Type Annotations
|
||||||
----------------
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
`PEP 484`_ introduced a standard way to express types in Python code.
|
`PEP 484`_ introduced a standard way to express types in Python code.
|
||||||
This is an alternative to expressing types directly in docstrings.
|
This is an alternative to expressing types directly in docstrings.
|
||||||
@@ -242,7 +242,7 @@ Google style with types in docstrings::
|
|||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
=============
|
-------------
|
||||||
|
|
||||||
Listed below are all the settings used by napoleon and their default
|
Listed below are all the settings used by napoleon and their default
|
||||||
values. These settings can be changed in the Sphinx `conf.py` file. Make
|
values. These settings can be changed in the Sphinx `conf.py` file. Make
|
||||||
@@ -271,8 +271,6 @@ sure that "sphinx.ext.napoleon" is enabled in `conf.py`::
|
|||||||
.. _NumPy style:
|
.. _NumPy style:
|
||||||
https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
|
https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. confval:: napoleon_google_docstring
|
.. confval:: napoleon_google_docstring
|
||||||
|
|
||||||
True to parse `Google style`_ docstrings. False to disable support
|
True to parse `Google style`_ docstrings. False to disable support
|
||||||
|
|||||||
+4
-1
@@ -27,7 +27,10 @@ There are two additional directives when using this extension:
|
|||||||
documentation, if :confval:`todo_include_todos` is ``True``.
|
documentation, if :confval:`todo_include_todos` is ``True``.
|
||||||
|
|
||||||
|
|
||||||
There is also an additional config value:
|
These can be configured as seen below.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
.. confval:: todo_include_todos
|
.. confval:: todo_include_todos
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
|
|
||||||
.. versionadded:: 1.0
|
.. versionadded:: 1.0
|
||||||
|
|
||||||
|
This extension looks at your Python object descriptions (``.. class::``, ``..
|
||||||
This extension looks at your Python object descriptions (``.. class::``,
|
function::`` etc.) and tries to find the source files where the objects are
|
||||||
``.. function::`` etc.) and tries to find the source files where the objects are
|
|
||||||
contained. When found, a separate HTML page will be output for each module with
|
contained. When found, a separate HTML page will be output for each module with
|
||||||
a highlighted version of the source code, and a link will be added to all object
|
a highlighted version of the source code, and a link will be added to all object
|
||||||
descriptions that leads to the source code of the described object. A link back
|
descriptions that leads to the source code of the described object. A link back
|
||||||
@@ -33,14 +32,15 @@ This extension works only on HTML related builders like ``html``,
|
|||||||
``singlehtml``. By default ``epub`` builder doesn't
|
``singlehtml``. By default ``epub`` builder doesn't
|
||||||
support this extension (see :confval:`viewcode_enable_epub`).
|
support this extension (see :confval:`viewcode_enable_epub`).
|
||||||
|
|
||||||
There is an additional config value:
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
.. confval:: viewcode_follow_imported_members
|
.. confval:: viewcode_follow_imported_members
|
||||||
|
|
||||||
If this is ``True``, viewcode extension will follow alias objects that
|
If this is ``True``, viewcode extension will follow alias objects that
|
||||||
imported from another module such as functions, classes and attributes.
|
imported from another module such as functions, classes and attributes. As
|
||||||
As side effects, this option
|
side effects, this option else they produce nothing. The default is
|
||||||
else they produce nothing. The default is ``True``.
|
``True``.
|
||||||
|
|
||||||
.. versionadded:: 1.3
|
.. versionadded:: 1.3
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user