diff --git a/docs/source/conf.py b/docs/source/conf.py index cc8f7d4..535a61d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -15,15 +15,23 @@ author = "Jérome Eertmans" # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ + # Built-in "sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.viewcode", + # Additional + "myst_parser", "sphinxext.opengraph", "sphinx_click", - "myst_parser", "sphinx_copybutton", + # Custom + "manim_slides.docs.manim_slides_directive", ] +typehints_defaults = "comma" +typehints_use_signature = True +typehints_use_signature_return = True + myst_enable_extensions = [ "colon_fence", "html_admonition", diff --git a/docs/source/reference/api.md b/docs/source/reference/api.md index 143dc08..3270a40 100644 --- a/docs/source/reference/api.md +++ b/docs/source/reference/api.md @@ -6,7 +6,7 @@ Therefore, we only document here the methods we think the end-user will ever use ```{eval-rst} .. autoclass:: manim_slides.Slide - :members: start_loop, end_loop, pause, next_slide + :members: start_loop, end_loop, pause, next_slide, wipe .. autoclass:: manim_slides.ThreeDSlide :members: diff --git a/docs/source/reference/index.md b/docs/source/reference/index.md index d2cf2a1..6ee70b6 100644 --- a/docs/source/reference/index.md +++ b/docs/source/reference/index.md @@ -11,6 +11,7 @@ examples gui html sharing +Sphinx Extension ``` [Application Programming Interface](./api): list of classes and methods that may diff --git a/docs/source/reference/sphinx_extension.md b/docs/source/reference/sphinx_extension.md new file mode 100644 index 0000000..7c55fb9 --- /dev/null +++ b/docs/source/reference/sphinx_extension.md @@ -0,0 +1,6 @@ +# Manim Slides' Sphinx directive + +```{eval-rst} +.. automodule:: manim_slides.docs.manim_slides_directive + :members: +``` diff --git a/manim_slides/docs/manim_slides_directive.py b/manim_slides/docs/manim_slides_directive.py new file mode 100644 index 0000000..b03be6a --- /dev/null +++ b/manim_slides/docs/manim_slides_directive.py @@ -0,0 +1,399 @@ +# 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. + +Its basic usage that allows processing **inline content** +looks as follows:: + + .. manim-slides:: MySlide + + class MySlide(Scene): + 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, Scene + >>> dot = Dot(color=RED) + >>> dot.color + + >>> class DirectiveDoctestExample(Scene): + ... def construct(self): + ... self.play(Create(dot)) + + +Options +------- + +Options can be passed as follows:: + + .. manim-slides:: + :