# type: ignore r""" A directive for including Manim Slides in a Sphinx document =========================================================== .. warning:: This Sphinx extension requires Manim to be installed, and won't probably work on ManimGL examples. .. note:: The current implementation is highly inspired from Manim's own sphinx directive, from v0.17.3. When rendering the HTML documentation, the ``.. manim-slides::`` directive implemented here allows to include rendered videos. This directive requires three additional dependencies: ``manim``, ``docutils`` and ``jinja2``. The last two are usually bundled with Sphinx. You can install them manually, or with the extra keyword: pip install manim-slides[sphinx-directive] Note that you will still need to install Manim's platform-specific dependencies, see `their installation page `_. Usage ----- First, you must include the directive in the Sphinx configuration file: .. code-block:: python :caption: Sphinx configuration file (usually :code:`docs/source/conf.py`). :emphasize-lines: 3 extensions = [ # ... "manim_slides.docs.manim_slides_directive", ] Its basic usage that allows processing **inline content** looks as follows:: .. manim-slides:: MySlide from manim import * from manim_slides import Slide class MySlide(Slide): def construct(self): ... It is required to pass the name of the class representing the scene to be rendered to the directive. As a second application, the directive can also be used to render scenes that are defined within doctests, for example:: .. manim-slides:: DirectiveDoctestExample :ref_classes: Dot >>> from manim import Create, Dot, RED >>> from manim_slides import Slide >>> dot = Dot(color=RED) >>> dot.color >>> class DirectiveDoctestExample(Slide): ... def construct(self): ... self.play(Create(dot)) A third application is to render scenes from another specific file:: .. manim-slides:: file.py:FileExample :hide_source: :quality: high .. warning:: The code will be executed with the current working directory being the same as the one containing the source file. This being said, you should probably not include examples that rely on external files, since relative paths risk to be broken. Options ------- Options can be passed as follows:: .. manim-slides:: : :