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