xref: /rk3399_ARM-atf/docs/getting_started/docs-build.rst (revision 793f72c06ca1c2782f800c9f20980ca6b7870072)
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
22*793f72c0SHarrison Mutai- Python 3 (3.8 or later)
23862c764aSPaul Beesley- PlantUML (1.2017.15 or later)
24*793f72c0SHarrison Mutai- Poetry Python dependency and package manager
25*793f72c0SHarrison Mutai- Python modules specified in ``pyproject.toml``
268526472aSBoyan Karatotev- Optionally, the `Dia`_ application can be installed if you need to edit
2743f35ef5SPaul Beesley  existing ``.dia`` diagram files, or create new ones.
2843f35ef5SPaul Beesley
29*793f72c0SHarrison Mutai
30*793f72c0SHarrison MutaiPoetry will handle the creation of a virtual build environment, either creating
31*793f72c0SHarrison Mutaia new environment or re-using one created by the user, and installing all
32*793f72c0SHarrison Mutaidependencies herein. This ensures that the Python environment is isolated from
33*793f72c0SHarrison Mutaiyour system environment.
34*793f72c0SHarrison Mutai
35*793f72c0SHarrison MutaiAn example set of installation commands for Ubuntu follows:
36862c764aSPaul Beesley
37862c764aSPaul Beesley.. code:: shell
38862c764aSPaul Beesley
3943f35ef5SPaul Beesley    sudo apt install python3 python3-pip plantuml [dia]
40*793f72c0SHarrison Mutai    curl -sSL https://install.python-poetry.org | python3 -
41*793f72c0SHarrison Mutai    poetry install
42862c764aSPaul Beesley
43862c764aSPaul BeesleyBuilding rendered documentation
44862c764aSPaul Beesley-------------------------------
45862c764aSPaul Beesley
466de32378SMadhukar PappireddyDocuments can be built into HTML-formatted pages from project root directory by
476de32378SMadhukar Pappireddyrunning the following command.
48862c764aSPaul Beesley
49862c764aSPaul Beesley.. code:: shell
50862c764aSPaul Beesley
51*793f72c0SHarrison Mutai   poetry run make doc
52862c764aSPaul Beesley
53862c764aSPaul BeesleyOutput from the build process will be placed in:
54862c764aSPaul Beesley
55862c764aSPaul Beesley::
56862c764aSPaul Beesley
577be2b983SLeonardo Sandoval   docs/build/html
586de32378SMadhukar Pappireddy
596de32378SMadhukar PappireddyWe also support building documentation in other formats. From the ``docs``
606de32378SMadhukar Pappireddydirectory of the project, run the following command to see the supported
616de32378SMadhukar Pappireddyformats. It is important to note that you will not get the correct result if
626de32378SMadhukar Pappireddythe command is run from the project root directory, as that would invoke the
636de32378SMadhukar Pappireddytop-level Makefile for |TF-A| itself.
646de32378SMadhukar Pappireddy
656de32378SMadhukar Pappireddy.. code:: shell
666de32378SMadhukar Pappireddy
67*793f72c0SHarrison Mutai   poetry run make help
68*793f72c0SHarrison Mutai
69*793f72c0SHarrison Mutai.. note::
70*793f72c0SHarrison Mutai
71*793f72c0SHarrison Mutai   The ``run`` command used above executes ``make`` in the projects virtual
72*793f72c0SHarrison Mutai   environment. To spawn a shell in this environment, use ``poetry
73*793f72c0SHarrison Mutai   shell``. For other use cases, please see the official `Poetry`_
74*793f72c0SHarrison Mutai   documentation.
75862c764aSPaul Beesley
767be2b983SLeonardo SandovalBuilding rendered documentation from a container
777be2b983SLeonardo Sandoval------------------------------------------------
787be2b983SLeonardo Sandoval
797be2b983SLeonardo SandovalThere may be cases where you can not either install or upgrade required
807be2b983SLeonardo Sandovaldependencies to generate the documents, so in this case, one way to
817be2b983SLeonardo Sandovalcreate the documentation is through a docker container. The first step is
827be2b983SLeonardo Sandovalto check if `docker`_ is installed in your host, otherwise check main docker
837be2b983SLeonardo Sandovalpage for installation instructions. Once installed, run the following script
847be2b983SLeonardo Sandovalfrom project root directory
857be2b983SLeonardo Sandoval
867be2b983SLeonardo Sandoval.. code:: shell
877be2b983SLeonardo Sandoval
887be2b983SLeonardo Sandoval   docker run --rm -v $PWD:/TF sphinxdoc/sphinx \
897be2b983SLeonardo Sandoval          bash -c 'cd /TF && \
90*793f72c0SHarrison Mutai          poetry install && poetry run make doc'
917be2b983SLeonardo Sandoval
927be2b983SLeonardo SandovalThe above command fetches the ``sphinxdoc/sphinx`` container from `docker
937be2b983SLeonardo Sandovalhub`_, launches the container, installs documentation requirements and finally
947be2b983SLeonardo Sandovalcreates the documentation. Once done, exit the container and output from the
957be2b983SLeonardo Sandovalbuild process will be placed in:
967be2b983SLeonardo Sandoval
977be2b983SLeonardo Sandoval::
987be2b983SLeonardo Sandoval
997be2b983SLeonardo Sandoval   docs/build/html
1007be2b983SLeonardo Sandoval
101862c764aSPaul Beesley--------------
102862c764aSPaul Beesley
103*793f72c0SHarrison Mutai*Copyright (c) 2019-2023, Arm Limited. All rights reserved.*
104862c764aSPaul Beesley
105862c764aSPaul Beesley.. _Sphinx: http://www.sphinx-doc.org/en/master/
106*793f72c0SHarrison Mutai.. _Poetry: https://python-poetry.org/docs/cli/
107862c764aSPaul Beesley.. _pip homepage: https://pip.pypa.io/en/stable/
10843f35ef5SPaul Beesley.. _Dia: https://wiki.gnome.org/Apps/Dia
1097be2b983SLeonardo Sandoval.. _docker: https://www.docker.com/
1107be2b983SLeonardo Sandoval.. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx
111