building_the_manual.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. - On Windows, run ``py -m venv godot-docs-venv``
  20. - On other platforms, run ``python3 -m venv godot-docs-venv``
  21. b. Activate the virtual environment:
  22. - On Windows, run ``godot-docs-venv\Scripts\activate.bat``
  23. - On other platforms, run ``source godot-docs-venv/bin/activate``
  24. c. *(Optional)* Update pre-installed packages:
  25. - On Windows, run ``py -m pip install --upgrade pip setuptools``
  26. - On other platforms, run ``pip3 install --upgrade pip setuptools``
  27. 2. Clone the docs repo:
  28. .. code:: sh
  29. git clone https://github.com/godotengine/godot-docs.git
  30. 3. Change directory into the docs repo:
  31. .. code:: sh
  32. cd godot-docs
  33. 4. Install the required packages:
  34. .. code:: sh
  35. pip3 install -r requirements.txt
  36. 5. Build the docs:
  37. .. code:: sh
  38. make html
  39. .. note:: On Windows, that command will run ``make.bat`` instead of GNU Make (or
  40. an alternative).
  41. If you run into errors, you may try the following command:
  42. .. code:: sh
  43. make SPHINXBUILD=~/.local/bin/sphinx-build html
  44. Building the documentation requires at least 8 GB of RAM to run without disk
  45. swapping, which slows it down. If you have at least 16 GB of RAM, you can speed
  46. up compilation by running:
  47. .. code:: sh
  48. # On Linux/macOS
  49. make html SPHINXOPTS=-j2
  50. # On Windows
  51. set SPHINXOPTS=-j2 && make html
  52. The compilation will take some time as the ``classes/`` folder contains hundreds
  53. of files.
  54. You can then browse the documentation by opening ``_build/html/index.html`` in
  55. your web browser.
  56. If you get a ``MemoryError`` or ``EOFError``, you can remove the
  57. ``classes/`` folder and run ``make`` again. This will drop the class references
  58. from the final HTML documentation but will keep the rest intact.
  59. .. note:: If you delete the ``classes/`` folder, do not use ``git add .`` when
  60. working on a pull request or the whole ``classes/`` folder will be
  61. removed when you commit. See `#3157
  62. <https://github.com/godotengine/godot-docs/issues/3157>`__ for more
  63. detail.
  64. Alternatively, you can build the documentation by running the sphinx-build
  65. program manually:
  66. .. code:: sh
  67. sphinx-build -b html ./ _build
  68. You can also specify a list of files to build, which can greatly speed up compilation:
  69. .. code:: sh
  70. sphinx-build -b html ./ _build classes/class_node.rst classes/class_resource.rst