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 | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 24 | - Poetry Python dependency and package manager |
| 25 | - Python modules specified in ``pyproject.toml`` |
Boyan Karatotev | db85878 | 2022-10-27 13:55:12 +0100 | [diff] [blame] | 26 | - Optionally, the `Dia`_ application can be installed if you need to edit |
| 27 | existing ``.dia`` diagram files, or create new ones. |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 28 | |
Harrison Mutai | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 29 | |
| 30 | Poetry will handle the creation of a virtual build environment, either creating |
| 31 | a new environment or re-using one created by the user, and installing all |
| 32 | dependencies herein. This ensures that the Python environment is isolated from |
| 33 | your system environment. |
| 34 | |
| 35 | An example set of installation commands for Ubuntu follows: |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 36 | |
| 37 | .. code:: shell |
| 38 | |
Paul Beesley | d2fcc4e | 2019-05-29 13:59:40 +0100 | [diff] [blame] | 39 | sudo apt install python3 python3-pip plantuml [dia] |
Harrison Mutai | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 40 | curl -sSL https://install.python-poetry.org | python3 - |
| 41 | poetry install |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 42 | |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 43 | Building rendered documentation |
| 44 | ------------------------------- |
| 45 | |
Madhukar Pappireddy | 46adb1b | 2020-01-28 12:41:20 -0600 | [diff] [blame] | 46 | Documents can be built into HTML-formatted pages from project root directory by |
| 47 | running the following command. |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 48 | |
| 49 | .. code:: shell |
| 50 | |
Harrison Mutai | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 51 | poetry run make doc |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 52 | |
| 53 | Output from the build process will be placed in: |
| 54 | |
| 55 | :: |
| 56 | |
Leonardo Sandoval | 8f9f688 | 2020-06-10 18:26:28 -0500 | [diff] [blame] | 57 | docs/build/html |
Madhukar Pappireddy | 46adb1b | 2020-01-28 12:41:20 -0600 | [diff] [blame] | 58 | |
| 59 | We also support building documentation in other formats. From the ``docs`` |
| 60 | directory of the project, run the following command to see the supported |
| 61 | formats. It is important to note that you will not get the correct result if |
| 62 | the command is run from the project root directory, as that would invoke the |
| 63 | top-level Makefile for |TF-A| itself. |
| 64 | |
| 65 | .. code:: shell |
| 66 | |
Harrison Mutai | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 67 | poetry run make help |
| 68 | |
| 69 | .. note:: |
| 70 | |
| 71 | The ``run`` command used above executes ``make`` in the projects virtual |
| 72 | environment. To spawn a shell in this environment, use ``poetry |
| 73 | shell``. For other use cases, please see the official `Poetry`_ |
| 74 | documentation. |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 75 | |
Leonardo Sandoval | 8f9f688 | 2020-06-10 18:26:28 -0500 | [diff] [blame] | 76 | Building rendered documentation from a container |
| 77 | ------------------------------------------------ |
| 78 | |
| 79 | There may be cases where you can not either install or upgrade required |
| 80 | dependencies to generate the documents, so in this case, one way to |
| 81 | create the documentation is through a docker container. The first step is |
| 82 | to check if `docker`_ is installed in your host, otherwise check main docker |
| 83 | page for installation instructions. Once installed, run the following script |
| 84 | from project root directory |
| 85 | |
| 86 | .. code:: shell |
| 87 | |
| 88 | docker run --rm -v $PWD:/TF sphinxdoc/sphinx \ |
| 89 | bash -c 'cd /TF && \ |
Harrison Mutai | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 90 | poetry install && poetry run make doc' |
Leonardo Sandoval | 8f9f688 | 2020-06-10 18:26:28 -0500 | [diff] [blame] | 91 | |
| 92 | The above command fetches the ``sphinxdoc/sphinx`` container from `docker |
| 93 | hub`_, launches the container, installs documentation requirements and finally |
| 94 | creates the documentation. Once done, exit the container and output from the |
| 95 | build process will be placed in: |
| 96 | |
| 97 | :: |
| 98 | |
| 99 | docs/build/html |
| 100 | |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 101 | -------------- |
| 102 | |
Harrison Mutai | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 103 | *Copyright (c) 2019-2023, Arm Limited. All rights reserved.* |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 104 | |
| 105 | .. _Sphinx: http://www.sphinx-doc.org/en/master/ |
Harrison Mutai | b378ad4 | 2023-02-16 10:20:48 +0000 | [diff] [blame] | 106 | .. _Poetry: https://python-poetry.org/docs/cli/ |
Paul Beesley | 5d3799b | 2019-10-07 10:04:48 +0000 | [diff] [blame] | 107 | .. _pip homepage: https://pip.pypa.io/en/stable/ |
Paul Beesley | d2fcc4e | 2019-05-29 13:59:40 +0100 | [diff] [blame] | 108 | .. _Dia: https://wiki.gnome.org/Apps/Dia |
Leonardo Sandoval | 8f9f688 | 2020-06-10 18:26:28 -0500 | [diff] [blame] | 109 | .. _docker: https://www.docker.com/ |
| 110 | .. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx |