building_the_manual.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. To get started, you need to:
  8. 1. Clone the `godot-docs repository <https://github.com/godotengine/godot-docs/>`__.
  9. 2. Install `Sphinx <https://www.sphinx-doc.org/>`__
  10. 3. To build the docs as HTML files, install the `readthedocs.org theme
  11. <https://github.com/snide/sphinx_rtd_theme>`__.
  12. 4. Install the Sphinx extensions defined in the `godot-docs repository
  13. <https://github.com/godotengine/godot-docs/>`__ ``requirements.txt`` file.
  14. We recommend using `pip <https://pip.pypa.io>`__, Python’s package manager to
  15. install all these tools. It comes pre-installed with `Python
  16. <https://www.python.org/>`__. Ensure that you install and use Python 3. Here are
  17. the commands to clone the repository and then install all requirements.
  18. .. note:: You may need to write ``python3 -m pip`` (Unix) or ``py -m pip`` (Windows) instead of ``pip3``.
  19. If both approaches fail, `check that you have pip3 installed <https://pip.pypa.io/en/stable/installation/>`__.
  20. .. code:: sh
  21. git clone https://github.com/godotengine/godot-docs.git
  22. pip3 install -r requirements.txt
  23. With the programs installed, you can build the HTML documentation from the root
  24. folder of this repository with the following command:
  25. .. code:: sh
  26. # On Linux and macOS
  27. make html
  28. # On Windows, you need to execute the ``make.bat`` file instead.
  29. make.bat html
  30. If you run into errors, you may try the following command:
  31. .. code:: sh
  32. make SPHINXBUILD=~/.local/bin/sphinx-build html
  33. Building the documentation requires at least 8 GB of RAM to run without disk
  34. swapping, which slows it down. If you have at least 16 GB of RAM, you can speed
  35. up compilation by running:
  36. .. code:: sh
  37. # On Linux/macOS
  38. make html SPHINXOPTS=-j2
  39. # On Windows
  40. set SPHINXOPTS=-j2 && make html
  41. The compilation will take some time as the ``classes/`` folder contains hundreds
  42. of files.
  43. You can then browse the documentation by opening ``_build/html/index.html`` in
  44. your web browser.
  45. In case you of a ``MemoryError`` or ``EOFError``, you can remove the
  46. ``classes/`` folder and run ``make`` again. This will drop the class references
  47. from the final HTML documentation but will keep the rest intact.
  48. .. note:: If you delete the ``classes/`` folder, do not use ``git add .`` when
  49. working on a pull request or the whole ``classes/`` folder will be
  50. removed when you commit. See `#3157
  51. <https://github.com/godotengine/godot-docs/issues/3157>`__ for more
  52. detail.
  53. Alternatively, you can build the documentation by running the sphinx-build
  54. program manually:
  55. .. code:: sh
  56. sphinx-build -b html ./ _build
  57. You can also specify a list of files to build, which can greatly speed up compilation:
  58. .. code:: sh
  59. sphinx-build -b html ./ _build classes/class_node.rst classes/class_resource.rst
  60. Building with Sphinx and virtualenv
  61. -----------------------------------
  62. If you want your Sphinx installation scoped to the project, you can install
  63. sphinx-build using virtualenv. To do so, run this command from this repository's
  64. root folder:
  65. .. code:: sh
  66. virtualenv --system-site-packages env/
  67. . env/bin/activate
  68. pip3 install -r requirements.txt
  69. Then, run ``make html`` as shown above.