|
| 1 | +==================== |
| 2 | +Adding Documentation |
| 3 | +==================== |
| 4 | + |
| 5 | +Building the documentation |
| 6 | +-------------------------- |
| 7 | + |
| 8 | +When you clone the Manim repository from GitHub, you can access the |
| 9 | +``docs/`` folder which contains the necessary files to build the |
| 10 | +documentation. |
| 11 | + |
| 12 | +To build the docs locally, open a CLI, enter the ``docs/`` folder with the |
| 13 | +``cd`` command and execute the following depending on your OS: |
| 14 | + |
| 15 | +- Windows: ``./make.bat html`` |
| 16 | +- macOS and Linux: ``make html`` |
| 17 | + |
| 18 | +The first time you build the docs, the process will take several |
| 19 | +minutes because it needs to generate all the ``.rst`` (reST: |
| 20 | +reStructured Text) files from scratch by reading and parsing all the |
| 21 | +Manim content. The process becomes much shorter the next time, as it |
| 22 | +rebuilds only the parts which have changed. |
| 23 | + |
| 24 | + |
| 25 | +Sphinx library and extensions |
| 26 | +----------------------------- |
| 27 | + |
| 28 | +Manim uses `Sphinx <https://www.sphinx-doc.org>`_ for building the |
| 29 | +docs. It also makes use of Sphinx extensions such as: |
| 30 | + |
| 31 | +- `Autodoc: <https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html>`_ |
| 32 | + imports Manim's Python source code, extracts its docstrings and |
| 33 | + generates documentation from them. |
| 34 | +- `Autosummary: <https://www.sphinx-doc.org/en/master/usage/extensions/autosummary.html>`_ |
| 35 | + a complement to Autodoc which adds a special directive ``autosummary``, |
| 36 | + used in Manim to automatically document classes, methods, |
| 37 | + attributes, functions, module-level variables and exceptions. |
| 38 | + Autosummary makes use of `Jinja templates <https://jinja.palletsprojects.com/templates/>`_, |
| 39 | + which Manim defines for autosummarizing classes and modules |
| 40 | + inside ``docs/source/_templates/``. |
| 41 | +- `Graphviz extension for Sphinx: <https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html>`_ |
| 42 | + embeds graphs generated by the `Graphviz <https://graphviz.org/>`_ |
| 43 | + module, which must be installed in order to render the |
| 44 | + inheritance diagrams in the :doc:`/reference`. |
| 45 | +- `Napoleon: <https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html>`_ |
| 46 | + enables Sphinx to read Google style docstrings and, in |
| 47 | + particular for Manim, `NumPy style docstrings <https://numpydoc.readthedocs.io/en/latest/format.html>`_ |
| 48 | + - see :doc:`docs/docstrings` for more information. |
| 49 | + |
| 50 | + |
| 51 | +Sphinx theme |
| 52 | +------------ |
| 53 | + |
| 54 | +The theme used for this website is `Furo <https://sphinx-themes.org/sample-sites/furo/>`_. |
| 55 | + |
| 56 | + |
| 57 | +Custom Sphinx directives |
| 58 | +------------------------ |
| 59 | + |
| 60 | +Manim implements **custom directives** for use with Autodoc and Autosummary, which |
| 61 | +are defined in :mod:`~.docbuild`: |
| 62 | + |
| 63 | +.. currentmodule:: manim.utils.docbuild |
| 64 | + |
| 65 | +.. autosummary:: |
| 66 | + |
| 67 | + :toctree: ../reference |
| 68 | + autoaliasattr_directive |
| 69 | + autocolor_directive |
| 70 | + manim_directive |
| 71 | + |
| 72 | + |
| 73 | +Index |
| 74 | +----- |
| 75 | + |
| 76 | +.. toctree:: |
| 77 | + :maxdepth: 2 |
| 78 | + |
| 79 | + docs/admonitions |
| 80 | + docs/docstrings |
| 81 | + docs/examples |
| 82 | + docs/references |
| 83 | + docs/typings |
0 commit comments