blob: e11da771316c017471ca18bbf19e35deeed214f6 [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
Tamas Banb2e5fbb2024-09-02 15:04:51 +020040The documentation can be compiled into HTML-formatted pages from the project
41root directory by running:
Paul Beesley5d3799b2019-10-07 10:04:48 +000042
43.. code:: shell
44
Harrison Mutaiad39a9d2025-05-15 08:47:34 +000045 make doc
Paul Beesley5d3799b2019-10-07 10:04:48 +000046
Harrison Mutai342f4682023-04-24 09:58:17 +010047Output from the build process will be placed in: ``docs/build/html``.
Paul Beesley5d3799b2019-10-07 10:04:48 +000048
Harrison Mutai342f4682023-04-24 09:58:17 +010049Other Output Formats
50~~~~~~~~~~~~~~~~~~~~
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -060051
52We also support building documentation in other formats. From the ``docs``
53directory of the project, run the following command to see the supported
Harrison Mutai342f4682023-04-24 09:58:17 +010054formats.
Madhukar Pappireddy46adb1b2020-01-28 12:41:20 -060055
56.. code:: shell
57
Harrison Mutaiad39a9d2025-05-15 08:47:34 +000058 make -C docs help
Harrison Mutai342f4682023-04-24 09:58:17 +010059
Elizabeth Hofadfa652023-08-09 16:03:21 +010060To build the documentation in PDF format, additionally ensure that the following
61packages are installed:
62
63- FreeSerif font
64- latexmk
65- librsvg2-bin
66- xelatex
67- xindy
68
69Below is an example set of instructions to install the required packages
70(tested on Ubuntu):
71
72.. code:: shell
73
74 sudo apt install fonts-freefont-otf latexmk librsvg2-bin texlive-xetex xindy
75
76Once all the dependencies are installed, run the command ``poetry run make -C
77docs latexpdf`` to build the documentation. Output from the build process
78(``trustedfirmware-a.pdf``) can be found in ``docs/build/latex``.
79
Harrison Mutai342f4682023-04-24 09:58:17 +010080Building rendered documentation from Poetry's virtual environment
81~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82
Harrison Mutaiad39a9d2025-05-15 08:47:34 +000083If Poetry is installed, the ``doc`` target wraps its build steps with ``poetry
84run``, which runs the specified command within the project's virtual
85environment. The easiest way to activate this environment manually is by using
86the ``poetry shell`` command.
Harrison Mutaib378ad42023-02-16 10:20:48 +000087
Harrison Mutai342f4682023-04-24 09:58:17 +010088Running ``poetry shell`` from the directory containing this project, activates
89the same virtual environment. This creates a sub-shell through which you can
90build the documentation directly with ``make``.
Harrison Mutaib378ad42023-02-16 10:20:48 +000091
Harrison Mutai342f4682023-04-24 09:58:17 +010092.. code:: shell
93
94 poetry shell
Harrison Mutaiad39a9d2025-05-15 08:47:34 +000095 make -C docs html
Harrison Mutai342f4682023-04-24 09:58:17 +010096
97Type ``exit`` to deactivate the virtual environment and exit this new shell. For
98other use cases, please see the official `Poetry`_ documentation.
Paul Beesley5d3799b2019-10-07 10:04:48 +000099
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -0500100Building rendered documentation from a container
101------------------------------------------------
102
103There may be cases where you can not either install or upgrade required
104dependencies to generate the documents, so in this case, one way to
105create the documentation is through a docker container. The first step is
106to check if `docker`_ is installed in your host, otherwise check main docker
107page for installation instructions. Once installed, run the following script
108from project root directory
109
110.. code:: shell
111
Harrison Mutai342f4682023-04-24 09:58:17 +0100112 docker run --rm -v $PWD:/tf-a sphinxdoc/sphinx \
113 bash -c 'cd /tf-a &&
114 apt-get update && apt-get install -y curl plantuml &&
115 curl -sSL https://install.python-poetry.org | python3 - &&
Tamas Banb2e5fbb2024-09-02 15:04:51 +0200116 ~/.local/bin/poetry run make doc'
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -0500117
118The above command fetches the ``sphinxdoc/sphinx`` container from `docker
119hub`_, launches the container, installs documentation requirements and finally
120creates the documentation. Once done, exit the container and output from the
Harrison Mutai342f4682023-04-24 09:58:17 +0100121build process will be placed in: ``docs/build/html``.
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -0500122
Paul Beesley5d3799b2019-10-07 10:04:48 +0000123--------------
124
Harrison Mutaiad39a9d2025-05-15 08:47:34 +0000125*Copyright (c) 2019-2025, Arm Limited. All rights reserved.*
Paul Beesley5d3799b2019-10-07 10:04:48 +0000126
127.. _Sphinx: http://www.sphinx-doc.org/en/master/
Harrison Mutai342f4682023-04-24 09:58:17 +0100128.. _Poetry: https://python-poetry.org/docs/
Paul Beesley5d3799b2019-10-07 10:04:48 +0000129.. _pip homepage: https://pip.pypa.io/en/stable/
Paul Beesleyd2fcc4e2019-05-29 13:59:40 +0100130.. _Dia: https://wiki.gnome.org/Apps/Dia
Leonardo Sandoval8f9f6882020-06-10 18:26:28 -0500131.. _docker: https://www.docker.com/
132.. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx