Skip to content

Commit

Permalink
Merge branch '4.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jun 30, 2021
2 parents 60203e3 + ec351bd commit e1d4e03
Show file tree
Hide file tree
Showing 143 changed files with 1,888 additions and 1,342 deletions.
33 changes: 33 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Features added
* #9272: autodoc: Render enum values for the default argument value better
* #3257: autosummary: Support instance attributes for classes
* #9129: html search: Show search summaries when html_copy_source = False
* #9307: html search: Prevent corrections and completions in search field
* #9120: html theme: Eliminate prompt characters of code-block from copyable
text
* #9176: i18n: Emit a debug message if message catalog file not found under
Expand All @@ -73,6 +74,18 @@ Features added
* #9097: Optimize the paralell build
* #9131: Add :confval:`nitpick_ignore_regex` to ignore nitpicky warnings using
regular expressions
* C++, add support for

- ``inline`` variables,
- ``consteval`` functions,
- ``constinit`` variables,
- ``char8_t``,
- ``explicit(<constant expression>)`` specifier,
- digit separators in literals, and
- constraints in placeholder type specifiers, aka. adjective syntax
(e.g., ``Sortable auto &v``).

* C, add support for digit separators in literals.


Bugs fixed
Expand All @@ -85,9 +98,14 @@ Bugs fixed
* #9250: autodoc: The inherited method not having docstring is wrongly parsed
* #9283: autodoc: autoattribute directive failed to generate document for an
attribute not having any comment
* #9317: html: Pushing left key causes visiting the next page at the first page
* #9381: html: URL for html_favicon and html_log does not work
* #9270: html theme : pyramid theme generates incorrect logo links
* #9217: manpage: The name of manpage directory that is generated by
:confval:`man_make_section_directory` is not correct
* #9350: manpage: Fix font isn't reset after keyword at the top of samp role
* #9306: Linkcheck reports broken link when remote server closes the connection
on HEAD request
* #9280: py domain: "exceptions" module is not displayed
* #9224: ``:param:`` and ``:type:`` fields does not support a type containing
whitespace (ex. ``Dict[str, str]``)
Expand All @@ -112,9 +130,24 @@ Deprecated
Features added
--------------

* C, add C23 keywords ``_Decimal32``, ``_Decimal64``, and ``_Decimal128``.
* #9354: C, add :confval:`c_extra_keywords` to allow user-defined keywords
during parsing.
* Revert the removal of ``sphinx.util:force_decode()`` to become some 3rd party
extensions available again during 5.0

Bugs fixed
----------

* #9330: changeset domain: :rst:dir:`versionchanged` with contents being a list
will cause error during pdf build
* #9313: LaTeX: complex table with merged cells broken since 4.0
* #9305: LaTeX: backslash may cause Improper discretionary list pdf build error
with Japanese engines
* #9354: C, remove special macro names from the keyword list.
See also :confval:`c_extra_keywords`.
* #9322: KeyError is raised on PropagateDescDomain transform

Testing
--------

Expand Down
Binary file added doc/_static/tutorial/lumache-first-light.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions doc/_templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@ <h2 style="margin-bottom: 0">{%trans%}Documentation{%endtrans%}</h2>
<p class="biglink"><a class="biglink" href="{{ pathto("usage/quickstart") }}">{%trans%}First steps with Sphinx{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}overview of basic tasks{%endtrans%}</span></p>
</td><td>
{%- if hasdoc('search') %}<p class="biglink"><a class="biglink" href="{{ pathto("search") }}">{%trans%}Search page{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}search the documentation{%endtrans%}</span></p>{%- endif %}
<p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">{%trans%}Tutorial{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}beginners tutorial{%endtrans%}</span></p>
</td>
</tr><tr>
<td>
<p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">{%trans%}Contents{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}for a complete overview{%endtrans%}</span></p>
</td><td>
{%- if hasdoc('genindex') %}<p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">{%trans%}General Index{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}all functions, classes, terms{%endtrans%}</span></p>{%- endif %}
{%- if hasdoc('search') %}<p class="biglink"><a class="biglink" href="{{ pathto("search") }}">{%trans%}Search page{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}search the documentation{%endtrans%}</span></p>{%- endif %}
</td>
</tr><tr>
<td>
<p class="biglink"><a class="biglink" href="{{ pathto("changes") }}">{%trans%}Changes{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}release history{%endtrans%}</span></p>
</td><td>
</td>
{%- if hasdoc('genindex') %}<p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">{%trans%}General Index{%endtrans%}</a><br/>
<span class="linkdescr">{%trans%}all functions, classes, terms{%endtrans%}</span></p>{%- endif %}
</td><td>
</tr>
</table>

Expand Down
1 change: 1 addition & 0 deletions doc/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Sphinx documentation contents
:maxdepth: 2

usage/index
tutorial/index
development/index
man/index

Expand Down
5 changes: 3 additions & 2 deletions doc/extdev/deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,9 @@ The following is a list of deprecated interfaces.

* - ``sphinx.environment.NoUri``
- 2.1
- 4.0
- 3.0
- ``sphinx.errors.NoUri``

* - ``sphinx.ext.apidoc.format_directive()``
- 2.1
- 4.0
Expand Down Expand Up @@ -1035,7 +1036,7 @@ The following is a list of deprecated interfaces.

* - ``sphinx.util.force_decode()``
- 2.0
- 4.0
- 5.0
- N/A

* - ``sphinx.util.get_matching_docs()``
Expand Down
24 changes: 23 additions & 1 deletion doc/latex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,29 @@ Keys that don't need to be overridden unless in special cases are:
"inputenc" package inclusion.

Default: ``'\\usepackage[utf8]{inputenc}'`` when using pdflatex, else
``''``
``''``.

.. note::

If using ``utf8x`` in place of ``utf8`` it is mandatory to extend the
LaTeX preamble with suitable ``\PreloadUnicodePage{<number>}`` commands,
as per the ``utf8x`` documentation (``texdoc ucs`` on a TeXLive based
TeX installation). Else, unexpected and possibly hard-to-spot problems
(i.e. not causing a build crash) may arise in the PDF, in particular
regarding hyperlinks.

Even if these precautions are taken, PDF build via ``pdflatex`` engine
may crash due to upstream LaTeX not being fully compatible with
``utf8x``. For example, in certain circumstances related to
code-blocks, or attempting to include images whose filenames contain
Unicode characters. Indeed, starting in 2015, upstream LaTeX with
``pdflatex`` engine has somewhat enhanced native support for Unicode and
is becoming more and more incompatible with ``utf8x``. In particular,
since the October 2019 LaTeX release, filenames can use Unicode
characters, and even spaces. At Sphinx level this means e.g. that the
:dudir:`image` and :dudir:`figure` directives are now compatible with
such filenames for PDF via LaTeX output. But this is broken if
``utf8x`` is in use.

.. versionchanged:: 1.4.3
Previously ``'\\usepackage[utf8]{inputenc}'`` was used for all
Expand Down
192 changes: 192 additions & 0 deletions doc/tutorial/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
.. _tutorial:

===============
Sphinx tutorial
===============

In this tutorial you will build a simple documentation project using Sphinx, and
view it in your browser as HTML. The project will include narrative,
handwritten documentation, as well as autogenerated API documentation.

The tutorial is aimed towards Sphinx newcomers willing to learn the fundamentals
of how projects are created and structured. You will create a fictional
software library to generate random food recipes that will serve as a guide
throughout the process, with the objective of properly documenting it.

To showcase Sphinx capabilities for code documentation you will use Python,
which also supports *automatic* documentation generation.

.. note::

Several other languages are natively supported in Sphinx for *manual* code
documentation, however they require extensions for *automatic* code
documentation, like `Breathe <https://breathe.readthedocs.io/>`_.

To follow the instructions you will need access to a Linux-like command line and
a basic understanding of how it works, as well as a working Python installation
for development, since you will use *Python virtual environments* to create the
project.

Getting started
---------------

Setting up your project and development environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In a new directory, create a file called ``README.rst`` with the following
content.

.. code-block:: rest
Lumache
=======
**Lumache** (/lu'make/) is a Python library for cooks and food lovers that
creates recipes mixing random ingredients.
It is a good moment to create a Python virtual environment and install the
required tools. For that, open a command line terminal, ``cd`` into the
directory you just created, and run the following commands:

.. code-block:: console
$ python -m venv .venv
$ source .venv/bin/activate
(.venv) $ python -m pip install sphinx
.. note::

The installation method used above is described in more detail in
:ref:`install-pypi`. For the rest of this tutorial, the instructions will
assume a Python virtual environment.

If you executed these instructions correctly, you should have the Sphinx command
line tools available. You can do a basic verification running this command:

.. code-block:: console
(.venv) $ sphinx-build --version
sphinx-build 4.0.2
If you see a similar output, you are on the right path!

Creating the documentation layout
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Then from the command line, run the following command:

.. code-block:: console
(.venv) $ sphinx-quickstart docs
This will present to you a series of questions required to create the basic
directory and configuration layout for your project inside the ``docs`` folder.
To proceed, answer each question as follows:

- ``> Separate source and build directories (y/n) [n]``: Write "``y``" (without
quotes) and press :kbd:`Enter`.
- ``> Project name``: Write "``Lumache``" (without quotes) and press
:kbd:`Enter`.
- ``> Author name(s)``: Write "``Graziella``" (without quotes) and press
:kbd:`Enter`.
- ``> Project release []``: Write "``0.1``" (without quotes) and press
:kbd:`Enter`.
- ``> Project language [en]``: Leave it empty (the default, English) and press
:kbd:`Enter`.

After the last question, you will see the new ``docs`` directory with the
following content.

.. code-block:: text
docs
├── build
├── make.bat
├── Makefile
└── source
├── conf.py
├── index.rst
├── _static
└── _templates
The purpose of each of these files is:

``build/``
An empty directory (for now) that will hold the rendered documentation.

``make.bat`` and ``Makefile``
Convenience scripts to simplify some common Sphinx operations, such as
rendering the content.

``source/conf.py``
A Python script holding the configuration of the Sphinx project. It contains
the project name and release you specified to ``sphinx-quickstart``, as well
as some extra configuration keys.

``source/index.rst``
The :term:`master document` of the project, which serves as welcome page and
contains the root of the "table of contents tree" (or *toctree*).

Thanks to this bootstrapping step, you already have everything needed to render
the documentation as HTML for the first time. To do that, run this command:

.. code-block:: console
(.venv) $ sphinx-build -b html docs/source/ docs/build/html
And finally, open `docs/build/html/index.html` in your browser. You should see
something like this:

.. image:: /_static/tutorial/lumache-first-light.png

There we go! You created your first HTML documentation using Sphinx.

Making some tweaks to the index
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``index.rst`` file that ``sphinx-quickstart`` created has some content
already, and it gets rendered as the front page of our HTML documentation. It
is written in reStructuredText, a powerful markup language.

Modify the file as follows:

.. code-block:: rest
Welcome to Lumache's documentation!
===================================
**Lumache** (/lu'make/) is a Python library for cooks and food lovers that
creates recipes mixing random ingredients. It pulls data from the `Open Food
Facts database <https://world.openfoodfacts.org/>`_ and offers a *simple* and
*intuitive* API.
.. note::
This project is under active development.
This showcases several features of the reStructuredText syntax, including:

- a **section header** using ``===`` for the underline,
- two examples of :ref:`rst-inline-markup`: ``**strong emphasis**`` (typically
bold) and ``*emphasis*`` (typically italics),
- an **inline external link**,
- and a ``note`` **admonition** (one of the available :ref:`directives
<rst-directives>`)

Now to render it with the new content, you can use the ``sphinx-build`` command
as before, or leverage the convenience script as follows:

.. code-block:: console
(.venv) $ cd docs
(.venv) $ make html
After running this command, you will see that ``index.html`` reflects the new
changes!

Where to go from here
---------------------

This tutorial covered the very first steps to create a documentation project
with Sphinx. To continue learning more about Sphinx, check out the :ref:`rest
of the documentation <contents>`.
8 changes: 8 additions & 0 deletions doc/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,14 @@ Options for the C domain

.. versionadded:: 3.0

.. confval:: c_extra_keywords

A list of identifiers to be recognized as keywords by the C parser.
It defaults to ``['alignas', 'alignof', 'bool', 'complex', 'imaginary',
'noreturn', 'static_assert', 'thread_local']``.

.. versionadded:: 4.0.3

.. confval:: c_allow_pre_v3

A boolean (default ``False``) controlling whether to parse and try to
Expand Down
26 changes: 26 additions & 0 deletions doc/usage/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ the ``--pre`` flag.

$ pip install -U --pre sphinx

Using virtual environments
~~~~~~~~~~~~~~~~~~~~~~~~~~

When installing Sphinx using pip,
it is highly recommended to use *virtual environments*,
which isolate the installed packages from the system packages,
thus removing the need to use administrator privileges.
To create a virtual environment in the ``.venv`` directory,
use the following command.

::

$ python -m venv .venv

You can read more about them in the `Python Packaging User Guide`_.

.. _Python Packaging User Guide: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment

.. warning::

Note that in some Linux distributions, such as Debian and Ubuntu,
this might require an extra installation step as follows.

.. code-block:: console
$ apt-get install python3-venv
Docker
------
Expand Down

0 comments on commit e1d4e03

Please sign in to comment.