docs-build.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. Building Documentation
  2. ======================
  3. To create a rendered copy of this documentation locally you can use the
  4. `Sphinx`_ tool to build and package the plain-text documents into HTML-formatted
  5. pages.
  6. If you are building the documentation for the first time then you will need to
  7. check that you have the required software packages, as described in the
  8. *Prerequisites* section that follows.
  9. .. note::
  10. An online copy of the documentation is available at
  11. https://www.trustedfirmware.org/docs/tf-a, if you want to view a rendered
  12. copy without doing a local build.
  13. Prerequisites
  14. -------------
  15. For building a local copy of the |TF-A| documentation you will need:
  16. - Python 3 (3.8 or later)
  17. - PlantUML (1.2017.15 or later)
  18. - `Poetry`_ (Python dependency manager)
  19. - Optionally, the `Dia`_ application can be installed if you need to edit
  20. existing ``.dia`` diagram files, or create new ones.
  21. Below is an example set of instructions to get a working environment (tested on
  22. Ubuntu):
  23. .. code:: shell
  24. sudo apt install python3 python3-pip plantuml [dia]
  25. curl -sSL https://install.python-poetry.org | python3 -
  26. Building rendered documentation
  27. -------------------------------
  28. The documentation can be compiled into HTML-formatted pages from the project
  29. root directory by running:
  30. .. code:: shell
  31. poetry run make doc
  32. Output from the build process will be placed in: ``docs/build/html``.
  33. Other Output Formats
  34. ~~~~~~~~~~~~~~~~~~~~
  35. We also support building documentation in other formats. From the ``docs``
  36. directory of the project, run the following command to see the supported
  37. formats.
  38. .. code:: shell
  39. poetry run make -C docs help
  40. To build the documentation in PDF format, additionally ensure that the following
  41. packages are installed:
  42. - FreeSerif font
  43. - latexmk
  44. - librsvg2-bin
  45. - xelatex
  46. - xindy
  47. Below is an example set of instructions to install the required packages
  48. (tested on Ubuntu):
  49. .. code:: shell
  50. sudo apt install fonts-freefont-otf latexmk librsvg2-bin texlive-xetex xindy
  51. Once all the dependencies are installed, run the command ``poetry run make -C
  52. docs latexpdf`` to build the documentation. Output from the build process
  53. (``trustedfirmware-a.pdf``) can be found in ``docs/build/latex``.
  54. Building rendered documentation from Poetry's virtual environment
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. The command ``poetry run`` used in the steps above executes the input command
  57. from inside the project's virtual environment. The easiest way to activate this
  58. virtual environment is with the ``poetry shell`` command.
  59. Running ``poetry shell`` from the directory containing this project, activates
  60. the same virtual environment. This creates a sub-shell through which you can
  61. build the documentation directly with ``make``.
  62. .. code:: shell
  63. poetry shell
  64. make doc
  65. Type ``exit`` to deactivate the virtual environment and exit this new shell. For
  66. other use cases, please see the official `Poetry`_ documentation.
  67. Building rendered documentation from a container
  68. ------------------------------------------------
  69. There may be cases where you can not either install or upgrade required
  70. dependencies to generate the documents, so in this case, one way to
  71. create the documentation is through a docker container. The first step is
  72. to check if `docker`_ is installed in your host, otherwise check main docker
  73. page for installation instructions. Once installed, run the following script
  74. from project root directory
  75. .. code:: shell
  76. docker run --rm -v $PWD:/tf-a sphinxdoc/sphinx \
  77. bash -c 'cd /tf-a &&
  78. apt-get update && apt-get install -y curl plantuml &&
  79. curl -sSL https://install.python-poetry.org | python3 - &&
  80. ~/.local/bin/poetry run make doc'
  81. The above command fetches the ``sphinxdoc/sphinx`` container from `docker
  82. hub`_, launches the container, installs documentation requirements and finally
  83. creates the documentation. Once done, exit the container and output from the
  84. build process will be placed in: ``docs/build/html``.
  85. --------------
  86. *Copyright (c) 2019-2024, Arm Limited. All rights reserved.*
  87. .. _Sphinx: http://www.sphinx-doc.org/en/master/
  88. .. _Poetry: https://python-poetry.org/docs/
  89. .. _pip homepage: https://pip.pypa.io/en/stable/
  90. .. _Dia: https://wiki.gnome.org/Apps/Dia
  91. .. _docker: https://www.docker.com/
  92. .. _docker hub: https://hub.docker.com/repository/docker/sphinxdoc/sphinx