File: sphinx.rst

package info (click to toggle)
openmpi 5.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,684 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (242 lines) | stat: -rw-r--r-- 8,854 bytes parent folder | download | duplicates (8)
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
.. _developers-installing-sphinx-label:

Installing and running Sphinx (building the Open MPI docs)
==========================================================

As with all content in the Developer's Guide, this section is only
relevant for developers who work in the Open MPI code base itself.
End users who install a binary Open MPI package or build from an
official Open MPI distribution tarball do not need to have Sphinx
installed.

Installing Python
-----------------

The `Sphinx tool <https://www.sphinx-doc.org/>`_ is written in Python,
and therefore needs to have Python available.  As of late 2022, Sphinx
requires Python >= v3.7.

This documentation does not contain detailed instructions for
installing a Python version sufficient for using Sphinx.  Consult your
local OS documentation for how to obtain Python >= v3.7, or search the
internet for further information.

Installing Sphinx
-----------------

`The Sphinx documentation
<https://www.sphinx-doc.org/en/master/usage/installation.html>`_
recommends installing Sphinx (and its required Python dependencies)
via ``pip``, which typically requires connectivity to the general
internet.

.. note:: If you are running on MacOS, you may be tempted to use
   Homebrew or MacPorts to install Sphinx.  The Sphinx documentation
   recommends **against** this.  Instead, you should use ``pip`` to
   install Sphinx.

There are three general ways to install Sphinx; you only need one of
them.

Install Sphinx in a Python virtual environment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The preferred method of installing Sphinx for Open MPI documentation
development is to install Sphinx in a Python virtual environment.
This places Sphinx in a sandbox that will not conflict with other
``pip``-installed Python modules.  This example installs Sphinx and
other Python modules in the ``ompi-docs-venv`` tree under your Open
MPI Git clone directory:

.. code-block:: sh

   # Create the Python virtual environment
   shell$ cd TOP_OF_OPEN_MPI_GIT_CLONE
   shell$ python3 -m venv ompi-docs-venv
   # Or: python3 -m virtualenv ompi-docs-venv
   # Or: virtualenv --python=python3 ompi-docs-venv

   # Activate the virtual environment
   shell$ . ./ompi-docs-venv/bin/activate

   # Notice that the shell prompt changes
   # Now install the required Python modules
   (ompi-docs-venv) shell$ pip3 install -r docs/requirements.txt
   # Or: python3 -m pip install install -r docs/requirements.txt

Note that sourcing the ``activate`` script will change your prompt to
put the name of your virtual environment directory at the front, just
as a visual reminder that you are operating in a Python virtual
environment.  You can run ``deactivate`` to leave the virtual
environment.

.. important:: You will need to source the ``activate`` script to put
               Sphinx in your ``PATH`` *before* running ``configure``.

Install Sphinx globally
^^^^^^^^^^^^^^^^^^^^^^^

If Python virtual environments are not desirable on your system, you
can install Sphinx globally on your system (you may need to run with
root privileges):

.. code-block:: sh

   shell$ cd TOP_OF_OPEN_MPI_GIT_CLONE
   shell$ pip3 install -r docs/requirements.txt
   # Or: python3 -m pip install install -r docs/requirements.txt

This will install Sphinx and some Python modules required for building
the Open MPI documentation in a system-wide location.

This will likely install the ``sphinx-build`` executable in a location
that is already in your ``PATH``.  If the location is not already in
your ``PATH``, then you need to add it to your ``PATH``.

.. important:: You will need to ensure that Sphinx is in your ``PATH``
               *before* running ``configure``.


Install Sphinx locally
^^^^^^^^^^^^^^^^^^^^^^

If you cannot or do not want to install Sphinx globally on your
system, the following will install Sphinx somewhere under your
``$HOME``.  It is the same ``pip`` command as shown above, but with
the addition of the ``--user`` flag (you should not need ``root``
permissions to run this command):

.. code-block:: sh

   shell$ cd TOP_OF_OPEN_MPI_GIT_CLONE
   shell$ pip3 install --user -r docs/requirements.txt
   # Or: python3 -m pip install install -r docs/requirements.txt

This will install Sphinx and some Python modules required for building
the Open MPI documentation in a user-specific location, likely
somewhere under ``$HOME``

You will likely need to find the location where ``sphinx-build`` was
installed and add it to your ``PATH`` (e.g., on macOS, it might appear
under ``$HOME/Library/Python/PYTHON_VERSION/bin/sphinx-build``).

.. note:: On MacOS, look for ``sphinx-build`` under
          ``$HOME/Library/Python/VERSION/bin`` (where ``VERSION`` is
          the version number of Python).  Or it may have installed to
          ``/usr/local/bin/sphinx-build``.  YMMV.

.. important:: You will need to ensure that Sphinx is in your ``PATH``
               *before* running ``configure``.

Running Sphinx
--------------

Open MPI's build environment is setup to invoke Sphinx automatically;
you should not need to invoke Sphinx manually.

.. important:: You will need to ensure that Sphinx is in your ``PATH``
               *before* running ``configure``.

As long as ``configure`` found Sphinx, ``make`` will invoke Sphinx to
build the documentation.  You can also run ``make`` directly in the
``docs/`` directory to build *just* the docs and skip building the
rest of the Open MPI software.  This can be a huge time-saver when
iteratively writing, rendering, and viewing/proofing documentation.

.. note:: The fully-built HTML and man page docs are included in
          official Open MPI distribution tarballs.  Meaning: if you
          download an Open MPI tarball from
          https://www.open-mpi.org/software/ompi (version v5.0.0 or
          later), the pre-built HTML and man page files are included
          in the tarball.

          Sphinx is a requirement for *developers* who want to build
          the Open MPI docs.  End users do *not* need to have Sphinx
          available to build Open MPI or have its docs installed from
          an official distribution tarball.

Sphinx execution time
^^^^^^^^^^^^^^^^^^^^^

The first time you invoke Sphinx on a clean tree, it takes a little
time to render all the docs.

However, Sphinx is stateful: subsequent runs can be significantly
faster because Sphinx will only re-render HTML files that have
changes.  This is an enormous time saver for Open MPI (e.g., if you
are iterating over writing the docs and running ``make`` to see how
they rendered in HTML).

.. caution:: Sphinx is only *somewhat* smart in its partial
             re-rendering.  If you change a title in an RST file, for
             example, Sphinx will (by default) only re-render *that*
             page.  The Tables of Contents / left hand navigation on
             other pages may not be updated.

             You can always force a full re-render via:

             .. code:: sh

                shell$ cd docs
                shell$ rm -rf _build
                shell$ make

Checking Sphinx HTML links
^^^^^^^^^^^^^^^^^^^^^^^^^^

``make linkcheck`` will invoke Sphinx's functionality to check all the
external links in the documentation:

.. code:: sh

   shell$ cd docs
   shell$ make linkcheck

.. important:: You will need to be on a computer that has good access
               to the internet when running this command.

Viewing docs locally
^^^^^^^^^^^^^^^^^^^^

Once you have built the docs in your local Git clone, you can view
them locally in the build tree:

#. Open ``docs/_build/html/index.html`` in a browser to view the HTML
   docs.  For example, on MacOS, the following command opens the build
   tree docs in the default web browser:

   .. code:: sh

      shell$ open docs/_build/html/index.html

#. Use the ``man`` command to view the Nroff files in
   ``docs/_build/man`` (you may need to use an absolute or relative
   filename to prevent ``man`` from using its search paths).  For
   example:

   .. code:: sh

      shell$ cd docs/_build/man
      shell$ man ./MPI_Send.3

Alternatively, you can view these files in their installed locations
after running ``make install``:

#. The HTML docs are installed (by default) to
   ``$prefix/share/doc/openmpi/html``.  You can use a web browser to
   open the ``index.html`` in that directory to view the docs locally.
   For example, on MacOS, the following command opens the installed
   docs in the default web browser:

   .. code:: sh

      shell$ open $prefix/share/doc/openmpi/html/index.html

#. The man pages are installed (by default) to ``$preix/share/man``.
   If your man page search path includes this location, you can invoke
   commands similar to the following to see the same content that you
   see in these HTML pages:

   .. code:: sh

      shell$ man MPI_Send