manim_directive¶
A directive for including Manim videos in a Sphinx document¶
When rendering the HTML documentation, the .. manim:: directive
implemented here allows to include rendered videos.
Its basic usage that allows processing inline content looks as follows:
.. manim:: MyScene
class MyScene(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:: DirectiveDoctestExample
:ref_classes: Dot
>>> from manim import Create, Dot, RED, Scene
>>> dot = Dot(color=RED)
>>> dot.color
ManimColor('#FC6255')
>>> class DirectiveDoctestExample(Scene):
... def construct(self):
... self.play(Create(dot))
Options¶
Options can be passed as follows:
.. manim:: <Class name>
:<option name>: <value>
The following configuration options are supported by the directive:
- hide_source
If this flag is present without argument, the source code is not displayed above the rendered video.
- no_autoplay
If this flag is present without argument, the video will not autoplay.
- quality{‘low’, ‘medium’, ‘high’, ‘fourk’}
Controls render quality of the video, in analogy to the corresponding command line flags.
- save_as_gif
If this flag is present without argument, the scene is rendered as a gif.
- save_last_frame
If this flag is present without argument, an image representing the last frame of the scene will be rendered and displayed, instead of a video.
- ref_classes
A list of classes, separated by spaces, that is rendered in a reference block after the source code.
- ref_functions
A list of functions, separated by spaces, that is rendered in a reference block after the source code.
- ref_methods
A list of methods, separated by spaces, that is rendered in a reference block after the source code.
Classes
The manim directive, rendering videos while building the documentation. |
|
Auxiliary node class that is used when the |
Functions
- depart(self, node)[source]¶
- Parameters:
self (SkipManimNode)
node (Element)
- Return type:
None
- process_name_list(option_input, reference_type)[source]¶
Reformats a string of space separated class names as a list of strings containing valid Sphinx references.
Tests¶
>>> process_name_list("Tex TexTemplate", "class") [':class:`~.Tex`', ':class:`~.TexTemplate`'] >>> process_name_list("Scene.play Mobject.rotate", "func") [':func:`~.Scene.play`', ':func:`~.Mobject.rotate`']
- Parameters:
option_input (str)
reference_type (str)
- Return type:
list[str]
- visit(self, node, name='')[source]¶
- Parameters:
self (SkipManimNode)
node (Element)
name (str)
- Return type:
None
- class ManimDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]¶
Bases:
DirectiveThe manim directive, rendering videos while building the documentation.
See the module docstring for documentation.
- final_argument_whitespace = True¶
May the final argument contain whitespace?
- has_content = True¶
May the directive have content?
- option_spec = {'hide_source': <class 'bool'>, 'no_autoplay': <class 'bool'>, 'quality': <function ManimDirective.<lambda>>, 'ref_classes': <function ManimDirective.<lambda>>, 'ref_functions': <function ManimDirective.<lambda>>, 'ref_methods': <function ManimDirective.<lambda>>, 'ref_modules': <function ManimDirective.<lambda>>, 'save_as_gif': <class 'bool'>, 'save_last_frame': <class 'bool'>}¶
Mapping of option names to validator functions.
- optional_arguments = 0¶
Number of optional arguments after the required arguments.
- required_arguments = 1¶
Number of required directive arguments.