xref: /rk3399_ARM-atf/docs/getting_started/docs-build.rst (revision 9db2b059eb76eaf51af8e434904caf277b998c99)
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
40*9db2b059STamas BanThe documentation can be compiled into HTML-formatted pages from the project
41*9db2b059STamas Banroot directory by running:
42862c764aSPaul Beesley
43862c764aSPaul Beesley.. code:: shell
44862c764aSPaul Beesley
45793f72c0SHarrison Mutai   poetry run make doc
46862c764aSPaul Beesley
4795f4abedSHarrison MutaiOutput from the build process will be placed in: ``docs/build/html``.
48862c764aSPaul Beesley
4995f4abedSHarrison MutaiOther Output Formats
5095f4abedSHarrison Mutai~~~~~~~~~~~~~~~~~~~~
516de32378SMadhukar Pappireddy
526de32378SMadhukar PappireddyWe also support building documentation in other formats. From the ``docs``
536de32378SMadhukar Pappireddydirectory of the project, run the following command to see the supported
5495f4abedSHarrison Mutaiformats.
556de32378SMadhukar Pappireddy
566de32378SMadhukar Pappireddy.. code:: shell
576de32378SMadhukar Pappireddy
5895f4abedSHarrison Mutai   poetry run make -C docs help
59793f72c0SHarrison Mutai
605ac3fdcdSElizabeth HoTo build the documentation in PDF format, additionally ensure that the following
615ac3fdcdSElizabeth Hopackages are installed:
625ac3fdcdSElizabeth Ho
635ac3fdcdSElizabeth Ho- FreeSerif font
645ac3fdcdSElizabeth Ho- latexmk
655ac3fdcdSElizabeth Ho- librsvg2-bin
665ac3fdcdSElizabeth Ho- xelatex
675ac3fdcdSElizabeth Ho- xindy
685ac3fdcdSElizabeth Ho
695ac3fdcdSElizabeth HoBelow is an example set of instructions to install the required packages
705ac3fdcdSElizabeth Ho(tested on Ubuntu):
715ac3fdcdSElizabeth Ho
725ac3fdcdSElizabeth Ho.. code:: shell
735ac3fdcdSElizabeth Ho
745ac3fdcdSElizabeth Ho	sudo apt install fonts-freefont-otf latexmk librsvg2-bin texlive-xetex xindy
755ac3fdcdSElizabeth Ho
765ac3fdcdSElizabeth HoOnce all the dependencies are installed, run the command ``poetry run make -C
775ac3fdcdSElizabeth Hodocs latexpdf`` to build the documentation. Output from the build process
785ac3fdcdSElizabeth Ho(``trustedfirmware-a.pdf``) can be found in ``docs/build/latex``.
795ac3fdcdSElizabeth Ho
8095f4abedSHarrison MutaiBuilding rendered documentation from Poetry's virtual environment
8195f4abedSHarrison Mutai~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82793f72c0SHarrison Mutai
8395f4abedSHarrison MutaiThe command ``poetry run`` used in the steps above executes the input command
8495f4abedSHarrison Mutaifrom inside the project's virtual environment. The easiest way to activate this
8595f4abedSHarrison Mutaivirtual environment is with the ``poetry shell`` command.
8695f4abedSHarrison Mutai
8795f4abedSHarrison MutaiRunning ``poetry shell`` from the directory containing this project, activates
8895f4abedSHarrison Mutaithe same virtual environment. This creates a sub-shell through which you can
8995f4abedSHarrison Mutaibuild the documentation directly with ``make``.
9095f4abedSHarrison Mutai
9195f4abedSHarrison Mutai.. code:: shell
9295f4abedSHarrison Mutai
9395f4abedSHarrison Mutai    poetry shell
9495f4abedSHarrison Mutai    make doc
9595f4abedSHarrison Mutai
9695f4abedSHarrison MutaiType ``exit`` to deactivate the virtual environment and exit this new shell. For
9795f4abedSHarrison Mutaiother use cases, please see the official `Poetry`_ documentation.
98862c764aSPaul Beesley
997be2b983SLeonardo SandovalBuilding rendered documentation from a container
1007be2b983SLeonardo Sandoval------------------------------------------------
1017be2b983SLeonardo Sandoval
1027be2b983SLeonardo SandovalThere may be cases where you can not either install or upgrade required
1037be2b983SLeonardo Sandovaldependencies to generate the documents, so in this case, one way to
1047be2b983SLeonardo Sandovalcreate the documentation is through a docker container. The first step is
1057be2b983SLeonardo Sandovalto check if `docker`_ is installed in your host, otherwise check main docker
1067be2b983SLeonardo Sandovalpage for installation instructions. Once installed, run the following script
1077be2b983SLeonardo Sandovalfrom project root directory
1087be2b983SLeonardo Sandoval
1097be2b983SLeonardo Sandoval.. code:: shell
1107be2b983SLeonardo Sandoval
11195f4abedSHarrison Mutai   docker run --rm -v $PWD:/tf-a sphinxdoc/sphinx \
11295f4abedSHarrison Mutai        bash -c 'cd /tf-a &&
11395f4abedSHarrison Mutai            apt-get update && apt-get install -y curl plantuml &&
11495f4abedSHarrison Mutai            curl -sSL https://install.python-poetry.org | python3 - &&
115*9db2b059STamas Ban            ~/.local/bin/poetry run make doc'
1167be2b983SLeonardo Sandoval
1177be2b983SLeonardo SandovalThe above command fetches the ``sphinxdoc/sphinx`` container from `docker
1187be2b983SLeonardo Sandovalhub`_, launches the container, installs documentation requirements and finally
1197be2b983SLeonardo Sandovalcreates the documentation. Once done, exit the container and output from the
12095f4abedSHarrison Mutaibuild process will be placed in: ``docs/build/html``.
1217be2b983SLeonardo Sandoval
122862c764aSPaul Beesley--------------
123862c764aSPaul Beesley
124*9db2b059STamas Ban*Copyright (c) 2019-2024, Arm Limited. All rights reserved.*
125862c764aSPaul Beesley
126862c764aSPaul Beesley.. _Sphinx: http://www.sphinx-doc.org/en/master/
12795f4abedSHarrison Mutai.. _Poetry: https://python-poetry.org/docs/
128862c764aSPaul Beesley.. _pip homepage: https://pip.pypa.io/en/stable/
12943f35ef5SPaul Beesley.. _Dia: https://wiki.gnome.org/Apps/Dia
1307be2b983SLeonardo Sandoval.. _docker: https://www.docker.com/
1317be2b983SLeonardo Sandoval.. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx
132