xref: /rk3399_ARM-atf/docs/getting_started/docs-build.rst (revision 5ac3fdcdfbed4a017fd8c94af81f6d2a79460287)
1862c764aSPaul BeesleyBuilding Documentation
2862c764aSPaul Beesley======================
3862c764aSPaul Beesley
4862c764aSPaul BeesleyTo create a rendered copy of this documentation locally you can use the
5862c764aSPaul Beesley`Sphinx`_ tool to build and package the plain-text documents into HTML-formatted
6862c764aSPaul Beesleypages.
7862c764aSPaul Beesley
8862c764aSPaul BeesleyIf you are building the documentation for the first time then you will need to
9862c764aSPaul Beesleycheck that you have the required software packages, as described in the
10862c764aSPaul Beesley*Prerequisites* section that follows.
11862c764aSPaul Beesley
12862c764aSPaul Beesley.. note::
13862c764aSPaul Beesley   An online copy of the documentation is available at
14862c764aSPaul Beesley   https://www.trustedfirmware.org/docs/tf-a, if you want to view a rendered
15862c764aSPaul Beesley   copy without doing a local build.
16862c764aSPaul Beesley
17862c764aSPaul BeesleyPrerequisites
18862c764aSPaul Beesley-------------
19862c764aSPaul Beesley
208526472aSBoyan KaratotevFor building a local copy of the |TF-A| documentation you will need:
21862c764aSPaul Beesley
22793f72c0SHarrison Mutai- Python 3 (3.8 or later)
23862c764aSPaul Beesley- PlantUML (1.2017.15 or later)
2495f4abedSHarrison Mutai- `Poetry`_ (Python dependency manager)
258526472aSBoyan Karatotev- Optionally, the `Dia`_ application can be installed if you need to edit
2643f35ef5SPaul Beesley  existing ``.dia`` diagram files, or create new ones.
2743f35ef5SPaul Beesley
28793f72c0SHarrison Mutai
2995f4abedSHarrison MutaiBelow is an example set of instructions to get a working environment (tested on
3095f4abedSHarrison MutaiUbuntu):
31862c764aSPaul Beesley
32862c764aSPaul Beesley.. code:: shell
33862c764aSPaul Beesley
3443f35ef5SPaul Beesley    sudo apt install python3 python3-pip plantuml [dia]
35793f72c0SHarrison Mutai    curl -sSL https://install.python-poetry.org | python3 -
36862c764aSPaul Beesley
37862c764aSPaul BeesleyBuilding rendered documentation
38862c764aSPaul Beesley-------------------------------
39862c764aSPaul Beesley
4095f4abedSHarrison MutaiTo install Python dependencies using Poetry:
4195f4abedSHarrison Mutai
4295f4abedSHarrison Mutai.. code:: shell
4395f4abedSHarrison Mutai
4495f4abedSHarrison Mutai    poetry install
4595f4abedSHarrison Mutai
4695f4abedSHarrison MutaiPoetry will create a new virtual environment and install all dependencies listed
4795f4abedSHarrison Mutaiin ``pyproject.toml``. You can get information about this environment, such as
4895f4abedSHarrison Mutaiits location and the Python version, with the command:
4995f4abedSHarrison Mutai
5095f4abedSHarrison Mutai.. code:: shell
5195f4abedSHarrison Mutai
5295f4abedSHarrison Mutai    poetry env info
5395f4abedSHarrison Mutai
5495f4abedSHarrison MutaiIf you have already sourced a virtual environment, Poetry will respect this and
5595f4abedSHarrison Mutaiinstall dependencies there.
5695f4abedSHarrison Mutai
5795f4abedSHarrison MutaiOnce all dependencies are installed, the documentation can be compiled into
5895f4abedSHarrison MutaiHTML-formatted pages from the project root directory by running:
59862c764aSPaul Beesley
60862c764aSPaul Beesley.. code:: shell
61862c764aSPaul Beesley
62793f72c0SHarrison Mutai   poetry run make doc
63862c764aSPaul Beesley
6495f4abedSHarrison MutaiOutput from the build process will be placed in: ``docs/build/html``.
65862c764aSPaul Beesley
6695f4abedSHarrison MutaiOther Output Formats
6795f4abedSHarrison Mutai~~~~~~~~~~~~~~~~~~~~
686de32378SMadhukar Pappireddy
696de32378SMadhukar PappireddyWe also support building documentation in other formats. From the ``docs``
706de32378SMadhukar Pappireddydirectory of the project, run the following command to see the supported
7195f4abedSHarrison Mutaiformats.
726de32378SMadhukar Pappireddy
736de32378SMadhukar Pappireddy.. code:: shell
746de32378SMadhukar Pappireddy
7595f4abedSHarrison Mutai   poetry run make -C docs help
76793f72c0SHarrison Mutai
77*5ac3fdcdSElizabeth HoTo build the documentation in PDF format, additionally ensure that the following
78*5ac3fdcdSElizabeth Hopackages are installed:
79*5ac3fdcdSElizabeth Ho
80*5ac3fdcdSElizabeth Ho- FreeSerif font
81*5ac3fdcdSElizabeth Ho- latexmk
82*5ac3fdcdSElizabeth Ho- librsvg2-bin
83*5ac3fdcdSElizabeth Ho- xelatex
84*5ac3fdcdSElizabeth Ho- xindy
85*5ac3fdcdSElizabeth Ho
86*5ac3fdcdSElizabeth HoBelow is an example set of instructions to install the required packages
87*5ac3fdcdSElizabeth Ho(tested on Ubuntu):
88*5ac3fdcdSElizabeth Ho
89*5ac3fdcdSElizabeth Ho.. code:: shell
90*5ac3fdcdSElizabeth Ho
91*5ac3fdcdSElizabeth Ho	sudo apt install fonts-freefont-otf latexmk librsvg2-bin texlive-xetex xindy
92*5ac3fdcdSElizabeth Ho
93*5ac3fdcdSElizabeth HoOnce all the dependencies are installed, run the command ``poetry run make -C
94*5ac3fdcdSElizabeth Hodocs latexpdf`` to build the documentation. Output from the build process
95*5ac3fdcdSElizabeth Ho(``trustedfirmware-a.pdf``) can be found in ``docs/build/latex``.
96*5ac3fdcdSElizabeth Ho
9795f4abedSHarrison MutaiBuilding rendered documentation from Poetry's virtual environment
9895f4abedSHarrison Mutai~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99793f72c0SHarrison Mutai
10095f4abedSHarrison MutaiThe command ``poetry run`` used in the steps above executes the input command
10195f4abedSHarrison Mutaifrom inside the project's virtual environment. The easiest way to activate this
10295f4abedSHarrison Mutaivirtual environment is with the ``poetry shell`` command.
10395f4abedSHarrison Mutai
10495f4abedSHarrison MutaiRunning ``poetry shell`` from the directory containing this project, activates
10595f4abedSHarrison Mutaithe same virtual environment. This creates a sub-shell through which you can
10695f4abedSHarrison Mutaibuild the documentation directly with ``make``.
10795f4abedSHarrison Mutai
10895f4abedSHarrison Mutai.. code:: shell
10995f4abedSHarrison Mutai
11095f4abedSHarrison Mutai    poetry shell
11195f4abedSHarrison Mutai    make doc
11295f4abedSHarrison Mutai
11395f4abedSHarrison MutaiType ``exit`` to deactivate the virtual environment and exit this new shell. For
11495f4abedSHarrison Mutaiother use cases, please see the official `Poetry`_ documentation.
115862c764aSPaul Beesley
1167be2b983SLeonardo SandovalBuilding rendered documentation from a container
1177be2b983SLeonardo Sandoval------------------------------------------------
1187be2b983SLeonardo Sandoval
1197be2b983SLeonardo SandovalThere may be cases where you can not either install or upgrade required
1207be2b983SLeonardo Sandovaldependencies to generate the documents, so in this case, one way to
1217be2b983SLeonardo Sandovalcreate the documentation is through a docker container. The first step is
1227be2b983SLeonardo Sandovalto check if `docker`_ is installed in your host, otherwise check main docker
1237be2b983SLeonardo Sandovalpage for installation instructions. Once installed, run the following script
1247be2b983SLeonardo Sandovalfrom project root directory
1257be2b983SLeonardo Sandoval
1267be2b983SLeonardo Sandoval.. code:: shell
1277be2b983SLeonardo Sandoval
12895f4abedSHarrison Mutai   docker run --rm -v $PWD:/tf-a sphinxdoc/sphinx \
12995f4abedSHarrison Mutai        bash -c 'cd /tf-a &&
13095f4abedSHarrison Mutai            apt-get update && apt-get install -y curl plantuml &&
13195f4abedSHarrison Mutai            curl -sSL https://install.python-poetry.org | python3 - &&
13295f4abedSHarrison Mutai            ~/.local/bin/poetry install && ~/.local/bin/poetry run make doc'
1337be2b983SLeonardo Sandoval
1347be2b983SLeonardo SandovalThe above command fetches the ``sphinxdoc/sphinx`` container from `docker
1357be2b983SLeonardo Sandovalhub`_, launches the container, installs documentation requirements and finally
1367be2b983SLeonardo Sandovalcreates the documentation. Once done, exit the container and output from the
13795f4abedSHarrison Mutaibuild process will be placed in: ``docs/build/html``.
1387be2b983SLeonardo Sandoval
139862c764aSPaul Beesley--------------
140862c764aSPaul Beesley
141793f72c0SHarrison Mutai*Copyright (c) 2019-2023, Arm Limited. All rights reserved.*
142862c764aSPaul Beesley
143862c764aSPaul Beesley.. _Sphinx: http://www.sphinx-doc.org/en/master/
14495f4abedSHarrison Mutai.. _Poetry: https://python-poetry.org/docs/
145862c764aSPaul Beesley.. _pip homepage: https://pip.pypa.io/en/stable/
14643f35ef5SPaul Beesley.. _Dia: https://wiki.gnome.org/Apps/Dia
1477be2b983SLeonardo Sandoval.. _docker: https://www.docker.com/
1487be2b983SLeonardo Sandoval.. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx
149