xref: /rk3399_ARM-atf/docs/getting_started/docs-build.rst (revision 95f4abed84876a35343021c3629f729afb98d724)
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)
24*95f4abedSHarrison 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
29*95f4abedSHarrison MutaiBelow is an example set of instructions to get a working environment (tested on
30*95f4abedSHarrison 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*95f4abedSHarrison MutaiTo install Python dependencies using Poetry:
41*95f4abedSHarrison Mutai
42*95f4abedSHarrison Mutai.. code:: shell
43*95f4abedSHarrison Mutai
44*95f4abedSHarrison Mutai    poetry install
45*95f4abedSHarrison Mutai
46*95f4abedSHarrison MutaiPoetry will create a new virtual environment and install all dependencies listed
47*95f4abedSHarrison Mutaiin ``pyproject.toml``. You can get information about this environment, such as
48*95f4abedSHarrison Mutaiits location and the Python version, with the command:
49*95f4abedSHarrison Mutai
50*95f4abedSHarrison Mutai.. code:: shell
51*95f4abedSHarrison Mutai
52*95f4abedSHarrison Mutai    poetry env info
53*95f4abedSHarrison Mutai
54*95f4abedSHarrison MutaiIf you have already sourced a virtual environment, Poetry will respect this and
55*95f4abedSHarrison Mutaiinstall dependencies there.
56*95f4abedSHarrison Mutai
57*95f4abedSHarrison MutaiOnce all dependencies are installed, the documentation can be compiled into
58*95f4abedSHarrison 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
64*95f4abedSHarrison MutaiOutput from the build process will be placed in: ``docs/build/html``.
65862c764aSPaul Beesley
66*95f4abedSHarrison MutaiOther Output Formats
67*95f4abedSHarrison 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
71*95f4abedSHarrison Mutaiformats.
726de32378SMadhukar Pappireddy
736de32378SMadhukar Pappireddy.. code:: shell
746de32378SMadhukar Pappireddy
75*95f4abedSHarrison Mutai   poetry run make -C docs help
76793f72c0SHarrison Mutai
77*95f4abedSHarrison MutaiBuilding rendered documentation from Poetry's virtual environment
78*95f4abedSHarrison Mutai~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79793f72c0SHarrison Mutai
80*95f4abedSHarrison MutaiThe command ``poetry run`` used in the steps above executes the input command
81*95f4abedSHarrison Mutaifrom inside the project's virtual environment. The easiest way to activate this
82*95f4abedSHarrison Mutaivirtual environment is with the ``poetry shell`` command.
83*95f4abedSHarrison Mutai
84*95f4abedSHarrison MutaiRunning ``poetry shell`` from the directory containing this project, activates
85*95f4abedSHarrison Mutaithe same virtual environment. This creates a sub-shell through which you can
86*95f4abedSHarrison Mutaibuild the documentation directly with ``make``.
87*95f4abedSHarrison Mutai
88*95f4abedSHarrison Mutai.. code:: shell
89*95f4abedSHarrison Mutai
90*95f4abedSHarrison Mutai    poetry shell
91*95f4abedSHarrison Mutai    make doc
92*95f4abedSHarrison Mutai
93*95f4abedSHarrison MutaiType ``exit`` to deactivate the virtual environment and exit this new shell. For
94*95f4abedSHarrison Mutaiother use cases, please see the official `Poetry`_ documentation.
95862c764aSPaul Beesley
967be2b983SLeonardo SandovalBuilding rendered documentation from a container
977be2b983SLeonardo Sandoval------------------------------------------------
987be2b983SLeonardo Sandoval
997be2b983SLeonardo SandovalThere may be cases where you can not either install or upgrade required
1007be2b983SLeonardo Sandovaldependencies to generate the documents, so in this case, one way to
1017be2b983SLeonardo Sandovalcreate the documentation is through a docker container. The first step is
1027be2b983SLeonardo Sandovalto check if `docker`_ is installed in your host, otherwise check main docker
1037be2b983SLeonardo Sandovalpage for installation instructions. Once installed, run the following script
1047be2b983SLeonardo Sandovalfrom project root directory
1057be2b983SLeonardo Sandoval
1067be2b983SLeonardo Sandoval.. code:: shell
1077be2b983SLeonardo Sandoval
108*95f4abedSHarrison Mutai   docker run --rm -v $PWD:/tf-a sphinxdoc/sphinx \
109*95f4abedSHarrison Mutai        bash -c 'cd /tf-a &&
110*95f4abedSHarrison Mutai            apt-get update && apt-get install -y curl plantuml &&
111*95f4abedSHarrison Mutai            curl -sSL https://install.python-poetry.org | python3 - &&
112*95f4abedSHarrison Mutai            ~/.local/bin/poetry install && ~/.local/bin/poetry run make doc'
1137be2b983SLeonardo Sandoval
1147be2b983SLeonardo SandovalThe above command fetches the ``sphinxdoc/sphinx`` container from `docker
1157be2b983SLeonardo Sandovalhub`_, launches the container, installs documentation requirements and finally
1167be2b983SLeonardo Sandovalcreates the documentation. Once done, exit the container and output from the
117*95f4abedSHarrison Mutaibuild process will be placed in: ``docs/build/html``.
1187be2b983SLeonardo Sandoval
119862c764aSPaul Beesley--------------
120862c764aSPaul Beesley
121793f72c0SHarrison Mutai*Copyright (c) 2019-2023, Arm Limited. All rights reserved.*
122862c764aSPaul Beesley
123862c764aSPaul Beesley.. _Sphinx: http://www.sphinx-doc.org/en/master/
124*95f4abedSHarrison Mutai.. _Poetry: https://python-poetry.org/docs/
125862c764aSPaul Beesley.. _pip homepage: https://pip.pypa.io/en/stable/
12643f35ef5SPaul Beesley.. _Dia: https://wiki.gnome.org/Apps/Dia
1277be2b983SLeonardo Sandoval.. _docker: https://www.docker.com/
1287be2b983SLeonardo Sandoval.. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx
129