building_the_manual.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. .. _doc_building_the_manual:
  2. Building the manual with Sphinx
  3. ===============================
  4. This page explains how to build a local copy of the Godot manual using the
  5. Sphinx docs engine. This allows you to have local HTML files and build the
  6. documentation as a PDF, EPUB, or LaTeX file, for example.
  7. Before you get started, make sure that you have:
  8. - `Git <https://git-scm.com/>`_
  9. - `make <https://www.gnu.org/software/make/>`_ (unless you're using Windows)
  10. - `Python <https://www.python.org/>`_ 3
  11. .. note:: Python 3 should come with the ``pip3`` command. You may need to write
  12. ``python3 -m pip`` (Unix) or ``py -m pip`` (Windows) instead of ``pip3``.
  13. If both approaches fail, `make sure that you have pip3 installed
  14. <https://pip.pypa.io/en/stable/installation/>`__.
  15. 1. *(Optional)* Set up a virtual environment. Virtual environments prevent
  16. potential conflicts between the Python packages in ``requirements.txt`` and
  17. other Python packages that are installed on your system.
  18. a. Create the virtual environment:
  19. .. tabs::
  20. .. group-tab:: Windows
  21. .. code:: pwsh
  22. py -m venv godot-docs-venv
  23. .. group-tab:: Other platforms
  24. .. code:: sh
  25. python3 -m venv godot-docs-venv
  26. b. Activate the virtual environment:
  27. .. tabs::
  28. .. group-tab:: Windows
  29. .. code:: pwsh
  30. godot-docs-venv\Scripts\activate.bat
  31. .. group-tab:: Other platforms
  32. .. code:: sh
  33. source godot-docs-venv/bin/activate
  34. c. *(Optional)* Update pre-installed packages:
  35. .. tabs::
  36. .. group-tab:: Windows
  37. .. code:: pwsh
  38. py -m pip install --upgrade pip setuptools
  39. .. group-tab:: Other platforms
  40. .. code:: sh
  41. pip3 install --upgrade pip setuptools
  42. 2. Clone the docs repo:
  43. .. code:: sh
  44. git clone https://github.com/godotengine/godot-docs.git
  45. 3. Change directory into the docs repo:
  46. .. code:: sh
  47. cd godot-docs
  48. 4. Install the required packages:
  49. .. code:: sh
  50. pip3 install -r requirements.txt
  51. 5. Build the docs:
  52. .. code:: sh
  53. make html
  54. .. note::
  55. On Windows, that command will run ``make.bat`` instead of GNU Make (or an alternative).
  56. Alternatively, you can build the documentation by running the sphinx-build program manually:
  57. .. code:: sh
  58. sphinx-build -b html ./ _build/html
  59. The compilation will take some time as the ``classes/`` folder contains hundreds of files.
  60. See :ref:`doc_building_the_manual:performance`.
  61. You can then browse the documentation by opening ``_build/html/index.html`` in
  62. your web browser.
  63. Dealing with errors
  64. -------------------
  65. If you run into errors, you may try the following command:
  66. .. code:: sh
  67. make SPHINXBUILD=~/.local/bin/sphinx-build html
  68. If you get a ``MemoryError`` or ``EOFError``, you can remove the ``classes/`` folder and
  69. run ``make`` again.
  70. This will drop the class references from the final HTML documentation but will keep the
  71. rest intact.
  72. .. important::
  73. If you delete the ``classes/`` folder, do not use ``git add .`` when working on a pull
  74. request or the whole ``classes/`` folder will be removed when you commit.
  75. See `#3157 <https://github.com/godotengine/godot-docs/issues/3157>`__ for more detail.
  76. .. _doc_building_the_manual:performance:
  77. Hints for performance
  78. ---------------------
  79. RAM usage
  80. ^^^^^^^^^
  81. Building the documentation requires at least 8 GB of RAM to run without disk swapping,
  82. which slows it down.
  83. If you have at least 16 GB of RAM, you can speed up compilation by running:
  84. .. tabs::
  85. .. group-tab:: Windows
  86. .. code:: pwsh
  87. set SPHINXOPTS=-j2 && make html
  88. .. group-tab:: Other platforms
  89. .. code:: sh
  90. make html SPHINXOPTS=-j2
  91. You can use ``-j auto`` to use all available CPU threads, but this can use a lot
  92. of RAM if you have a lot of CPU threads. For instance, on a system with 32 CPU
  93. threads, ``-j auto`` (which corresponds to ``-j 32`` here) can require 20+ GB of
  94. RAM for Sphinx alone.
  95. Specifying a list of files
  96. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  97. You can specify a list of files to build, which can greatly speed up compilation:
  98. .. code:: sh
  99. make FILELIST='classes/class_node.rst classes/class_resource.rst' html