xref: /arm-trusted-firmware/docs/getting_started/docs-build.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluBuilding Documentation
2*91f16700Schasinglulu======================
3*91f16700Schasinglulu
4*91f16700SchasingluluTo create a rendered copy of this documentation locally you can use the
5*91f16700Schasinglulu`Sphinx`_ tool to build and package the plain-text documents into HTML-formatted
6*91f16700Schasinglulupages.
7*91f16700Schasinglulu
8*91f16700SchasingluluIf you are building the documentation for the first time then you will need to
9*91f16700Schasinglulucheck that you have the required software packages, as described in the
10*91f16700Schasinglulu*Prerequisites* section that follows.
11*91f16700Schasinglulu
12*91f16700Schasinglulu.. note::
13*91f16700Schasinglulu   An online copy of the documentation is available at
14*91f16700Schasinglulu   https://www.trustedfirmware.org/docs/tf-a, if you want to view a rendered
15*91f16700Schasinglulu   copy without doing a local build.
16*91f16700Schasinglulu
17*91f16700SchasingluluPrerequisites
18*91f16700Schasinglulu-------------
19*91f16700Schasinglulu
20*91f16700SchasingluluFor building a local copy of the |TF-A| documentation you will need:
21*91f16700Schasinglulu
22*91f16700Schasinglulu- Python 3 (3.8 or later)
23*91f16700Schasinglulu- PlantUML (1.2017.15 or later)
24*91f16700Schasinglulu- `Poetry`_ (Python dependency manager)
25*91f16700Schasinglulu- Optionally, the `Dia`_ application can be installed if you need to edit
26*91f16700Schasinglulu  existing ``.dia`` diagram files, or create new ones.
27*91f16700Schasinglulu
28*91f16700Schasinglulu
29*91f16700SchasingluluBelow is an example set of instructions to get a working environment (tested on
30*91f16700SchasingluluUbuntu):
31*91f16700Schasinglulu
32*91f16700Schasinglulu.. code:: shell
33*91f16700Schasinglulu
34*91f16700Schasinglulu    sudo apt install python3 python3-pip plantuml [dia]
35*91f16700Schasinglulu    curl -sSL https://install.python-poetry.org | python3 -
36*91f16700Schasinglulu
37*91f16700SchasingluluBuilding rendered documentation
38*91f16700Schasinglulu-------------------------------
39*91f16700Schasinglulu
40*91f16700SchasingluluTo install Python dependencies using Poetry:
41*91f16700Schasinglulu
42*91f16700Schasinglulu.. code:: shell
43*91f16700Schasinglulu
44*91f16700Schasinglulu    poetry install
45*91f16700Schasinglulu
46*91f16700SchasingluluPoetry will create a new virtual environment and install all dependencies listed
47*91f16700Schasingluluin ``pyproject.toml``. You can get information about this environment, such as
48*91f16700Schasingluluits location and the Python version, with the command:
49*91f16700Schasinglulu
50*91f16700Schasinglulu.. code:: shell
51*91f16700Schasinglulu
52*91f16700Schasinglulu    poetry env info
53*91f16700Schasinglulu
54*91f16700SchasingluluIf you have already sourced a virtual environment, Poetry will respect this and
55*91f16700Schasingluluinstall dependencies there.
56*91f16700Schasinglulu
57*91f16700SchasingluluOnce all dependencies are installed, the documentation can be compiled into
58*91f16700SchasingluluHTML-formatted pages from the project root directory by running:
59*91f16700Schasinglulu
60*91f16700Schasinglulu.. code:: shell
61*91f16700Schasinglulu
62*91f16700Schasinglulu   poetry run make doc
63*91f16700Schasinglulu
64*91f16700SchasingluluOutput from the build process will be placed in: ``docs/build/html``.
65*91f16700Schasinglulu
66*91f16700SchasingluluOther Output Formats
67*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~
68*91f16700Schasinglulu
69*91f16700SchasingluluWe also support building documentation in other formats. From the ``docs``
70*91f16700Schasingluludirectory of the project, run the following command to see the supported
71*91f16700Schasingluluformats.
72*91f16700Schasinglulu
73*91f16700Schasinglulu.. code:: shell
74*91f16700Schasinglulu
75*91f16700Schasinglulu   poetry run make -C docs help
76*91f16700Schasinglulu
77*91f16700SchasingluluTo build the documentation in PDF format, additionally ensure that the following
78*91f16700Schasinglulupackages are installed:
79*91f16700Schasinglulu
80*91f16700Schasinglulu- FreeSerif font
81*91f16700Schasinglulu- latexmk
82*91f16700Schasinglulu- librsvg2-bin
83*91f16700Schasinglulu- xelatex
84*91f16700Schasinglulu- xindy
85*91f16700Schasinglulu
86*91f16700SchasingluluBelow is an example set of instructions to install the required packages
87*91f16700Schasinglulu(tested on Ubuntu):
88*91f16700Schasinglulu
89*91f16700Schasinglulu.. code:: shell
90*91f16700Schasinglulu
91*91f16700Schasinglulu	sudo apt install fonts-freefont-otf latexmk librsvg2-bin texlive-xetex xindy
92*91f16700Schasinglulu
93*91f16700SchasingluluOnce all the dependencies are installed, run the command ``poetry run make -C
94*91f16700Schasingluludocs latexpdf`` to build the documentation. Output from the build process
95*91f16700Schasinglulu(``trustedfirmware-a.pdf``) can be found in ``docs/build/latex``.
96*91f16700Schasinglulu
97*91f16700SchasingluluBuilding rendered documentation from Poetry's virtual environment
98*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99*91f16700Schasinglulu
100*91f16700SchasingluluThe command ``poetry run`` used in the steps above executes the input command
101*91f16700Schasinglulufrom inside the project's virtual environment. The easiest way to activate this
102*91f16700Schasingluluvirtual environment is with the ``poetry shell`` command.
103*91f16700Schasinglulu
104*91f16700SchasingluluRunning ``poetry shell`` from the directory containing this project, activates
105*91f16700Schasingluluthe same virtual environment. This creates a sub-shell through which you can
106*91f16700Schasinglulubuild the documentation directly with ``make``.
107*91f16700Schasinglulu
108*91f16700Schasinglulu.. code:: shell
109*91f16700Schasinglulu
110*91f16700Schasinglulu    poetry shell
111*91f16700Schasinglulu    make doc
112*91f16700Schasinglulu
113*91f16700SchasingluluType ``exit`` to deactivate the virtual environment and exit this new shell. For
114*91f16700Schasingluluother use cases, please see the official `Poetry`_ documentation.
115*91f16700Schasinglulu
116*91f16700SchasingluluBuilding rendered documentation from a container
117*91f16700Schasinglulu------------------------------------------------
118*91f16700Schasinglulu
119*91f16700SchasingluluThere may be cases where you can not either install or upgrade required
120*91f16700Schasingluludependencies to generate the documents, so in this case, one way to
121*91f16700Schasinglulucreate the documentation is through a docker container. The first step is
122*91f16700Schasingluluto check if `docker`_ is installed in your host, otherwise check main docker
123*91f16700Schasinglulupage for installation instructions. Once installed, run the following script
124*91f16700Schasinglulufrom project root directory
125*91f16700Schasinglulu
126*91f16700Schasinglulu.. code:: shell
127*91f16700Schasinglulu
128*91f16700Schasinglulu   docker run --rm -v $PWD:/tf-a sphinxdoc/sphinx \
129*91f16700Schasinglulu        bash -c 'cd /tf-a &&
130*91f16700Schasinglulu            apt-get update && apt-get install -y curl plantuml &&
131*91f16700Schasinglulu            curl -sSL https://install.python-poetry.org | python3 - &&
132*91f16700Schasinglulu            ~/.local/bin/poetry install && ~/.local/bin/poetry run make doc'
133*91f16700Schasinglulu
134*91f16700SchasingluluThe above command fetches the ``sphinxdoc/sphinx`` container from `docker
135*91f16700Schasingluluhub`_, launches the container, installs documentation requirements and finally
136*91f16700Schasinglulucreates the documentation. Once done, exit the container and output from the
137*91f16700Schasinglulubuild process will be placed in: ``docs/build/html``.
138*91f16700Schasinglulu
139*91f16700Schasinglulu--------------
140*91f16700Schasinglulu
141*91f16700Schasinglulu*Copyright (c) 2019-2023, Arm Limited. All rights reserved.*
142*91f16700Schasinglulu
143*91f16700Schasinglulu.. _Sphinx: http://www.sphinx-doc.org/en/master/
144*91f16700Schasinglulu.. _Poetry: https://python-poetry.org/docs/
145*91f16700Schasinglulu.. _pip homepage: https://pip.pypa.io/en/stable/
146*91f16700Schasinglulu.. _Dia: https://wiki.gnome.org/Apps/Dia
147*91f16700Schasinglulu.. _docker: https://www.docker.com/
148*91f16700Schasinglulu.. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx
149