blob: aa8c2bbf67124304ef9453f5e24e0106297d71dd [file] [log] [blame]
Paul Beesley5d3799b2019-10-07 10:04:48 +00001Building Documentation
2======================
3
4To create a rendered copy of this documentation locally you can use the
5`Sphinx`_ tool to build and package the plain-text documents into HTML-formatted
6pages.
7
8If you are building the documentation for the first time then you will need to
9check that you have the required software packages, as described in the
10*Prerequisites* section that follows.
11
12.. note::
13 An online copy of the documentation is available at
14 https://www.trustedfirmware.org/docs/tf-a, if you want to view a rendered
15 copy without doing a local build.
16
17Prerequisites
18-------------
19
Boyan Karatotevdb858782022-10-27 13:55:12 +010020For building a local copy of the |TF-A| documentation you will need:
Paul Beesley5d3799b2019-10-07 10:04:48 +000021
Harrison Mutaib378ad42023-02-16 10:20:48 +000022- Python 3 (3.8 or later)
Paul Beesley5d3799b2019-10-07 10:04:48 +000023- PlantUML (1.2017.15 or later)
Harrison Mutai342f4682023-04-24 09:58:17 +010024- `Poetry`_ (Python dependency manager)
Boyan Karatotevdb858782022-10-27 13:55:12 +010025- Optionally, the `Dia`_ application can be installed if you need to edit
26 existing ``.dia`` diagram files, or create new ones.
Paul Beesley5d3799b2019-10-07 10:04:48 +000027
Harrison Mutaib378ad42023-02-16 10:20:48 +000028
Harrison Mutai342f4682023-04-24 09:58:17 +010029Below is an example set of instructions to get a working environment (tested on
30Ubuntu):
Paul Beesley5d3799b2019-10-07 10:04:48 +000031
32.. code:: shell
33
Paul Beesleyd2fcc4e2019-05-29 13:59:40 +010034 sudo apt install python3 python3-pip plantuml [dia]
Harrison Mutaib378ad42023-02-16 10:20:48 +000035 curl -sSL https://install.python-poetry.org | python3 -
Paul Beesley5d3799b2019-10-07 10:04:48 +000036
Paul Beesley5d3799b2019-10-07 10:04:48 +000037Building rendered documentation
38-------------------------------
39
Harrison Mutai342f4682023-04-24 09:58:17 +010040To install Python dependencies using Poetry:
Paul Beesley5d3799b2019-10-07 10:04:48 +000041
42.. code:: shell
43
Harrison Mutai342f4682023-04-24 09:58:17 +010044 poetry install
45
46Poetry will create a new virtual environment and install all dependencies listed
47in ``pyproject.toml``. You can get information about this environment, such as
48its location and the Python version, with the command:
49
50.. code:: shell
51
52 poetry env info
53
54If you have already sourced a virtual environment, Poetry will respect this and
55install dependencies there.
56
57Once all dependencies are installed, the documentation can be compiled into
58HTML-formatted pages from the project root directory by running:
Paul Beesley5d3799b2019-10-07 10:04:48 +000059
Harrison Mutai342f4682023-04-24 09:58:17 +010060.. code:: shell
61
62 poetry run make doc
Paul Beesley5d3799b2019-10-07 10:04:48 +000063
Harrison Mutai342f4682023-04-24 09:58:17 +010064Output from the build process will be placed in: ``docs/build/html``.
Paul Beesley5d3799b2019-10-07 10:04:48 +000065
Harrison Mutai342f4682023-04-24 09:58:17 +010066Other Output Formats
67~~~~~~~~~~~~~~~~~~~~
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -060068
69We also support building documentation in other formats. From the ``docs``
70directory of the project, run the following command to see the supported
Harrison Mutai342f4682023-04-24 09:58:17 +010071formats.
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -060072
73.. code:: shell
74
Harrison Mutai342f4682023-04-24 09:58:17 +010075 poetry run make -C docs help
76
77Building rendered documentation from Poetry's virtual environment
78~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
80The command ``poetry run`` used in the steps above executes the input command
81from inside the project's virtual environment. The easiest way to activate this
82virtual environment is with the ``poetry shell`` command.
Harrison Mutaib378ad42023-02-16 10:20:48 +000083
Harrison Mutai342f4682023-04-24 09:58:17 +010084Running ``poetry shell`` from the directory containing this project, activates
85the same virtual environment. This creates a sub-shell through which you can
86build the documentation directly with ``make``.
Harrison Mutaib378ad42023-02-16 10:20:48 +000087
Harrison Mutai342f4682023-04-24 09:58:17 +010088.. code:: shell
89
90 poetry shell
91 make doc
92
93Type ``exit`` to deactivate the virtual environment and exit this new shell. For
94other use cases, please see the official `Poetry`_ documentation.
Paul Beesley5d3799b2019-10-07 10:04:48 +000095
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -050096Building rendered documentation from a container
97------------------------------------------------
98
99There may be cases where you can not either install or upgrade required
100dependencies to generate the documents, so in this case, one way to
101create the documentation is through a docker container. The first step is
102to check if `docker`_ is installed in your host, otherwise check main docker
103page for installation instructions. Once installed, run the following script
104from project root directory
105
106.. code:: shell
107
Harrison Mutai342f4682023-04-24 09:58:17 +0100108 docker run --rm -v $PWD:/tf-a sphinxdoc/sphinx \
109 bash -c 'cd /tf-a &&
110 apt-get update && apt-get install -y curl plantuml &&
111 curl -sSL https://install.python-poetry.org | python3 - &&
112 ~/.local/bin/poetry install && ~/.local/bin/poetry run make doc'
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -0500113
114The above command fetches the ``sphinxdoc/sphinx`` container from `docker
115hub`_, launches the container, installs documentation requirements and finally
116creates the documentation. Once done, exit the container and output from the
Harrison Mutai342f4682023-04-24 09:58:17 +0100117build process will be placed in: ``docs/build/html``.
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -0500118
Paul Beesley5d3799b2019-10-07 10:04:48 +0000119--------------
120
Harrison Mutaib378ad42023-02-16 10:20:48 +0000121*Copyright (c) 2019-2023, Arm Limited. All rights reserved.*
Paul Beesley5d3799b2019-10-07 10:04:48 +0000122
123.. _Sphinx: http://www.sphinx-doc.org/en/master/
Harrison Mutai342f4682023-04-24 09:58:17 +0100124.. _Poetry: https://python-poetry.org/docs/
Paul Beesley5d3799b2019-10-07 10:04:48 +0000125.. _pip homepage: https://pip.pypa.io/en/stable/
Paul Beesleyd2fcc4e2019-05-29 13:59:40 +0100126.. _Dia: https://wiki.gnome.org/Apps/Dia
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -0500127.. _docker: https://www.docker.com/
128.. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx