A community-maintained Python framework for creating mathematical animations.
change default for displaying source code with manim directive (#446)
Benjamin Hackl99428cfab0a3
diff --git a/docs/source/manim_directive.py b/docs/source/manim_directive.pyindex f05f370c7..aa731e13d 100644--- a/docs/source/manim_directive.py+++ b/docs/source/manim_directive.py@@ -5,7 +5,7 @@ A directive for including Manim videos in a Sphinx documentWhen rendering the HTML documentation, the ``.. manim::`` directiveimplemented here allows to include rendered videos.-Its basic usage that allows processing **inline content**+Its basic usage that allows processing **inline content**looks as follows::.. manim:: MyScene@@ -41,9 +41,9 @@ Options can be passed as follows::The following configuration options are supported by thedirective:- display_source+ hide_sourceIf this flag is present without argument,- the source code is displayed above the rendered video.+ the source code is not displayed above the rendered video.quality : {'low', 'medium', 'high', 'fourk'}Controls render quality of the video, in analogy to@@ -80,7 +80,7 @@ class ManimDirective(Directive):required_arguments = 1optional_arguments = 0option_spec = {- "display_source": bool,+ "hide_source": bool,"quality": lambda arg: directives.choice(arg, ("low", "medium", "high", "fourk")),@@ -100,7 +100,7 @@ class ManimDirective(Directive):else:classnamedict[clsname] += 1- display_source = "display_source" in self.options+ hide_source = "hide_source" in self.optionssave_as_gif = "save_as_gif" in self.optionssave_last_frame = "save_last_frame" in self.optionsassert not (save_as_gif and save_last_frame)@@ -211,7 +211,7 @@ class ManimDirective(Directive):raise ValueError("Invalid combination of render flags received.")rendered_template = jinja2.Template(TEMPLATE).render(- display_source=display_source,+ hide_source=hide_source,filesrc_rel=os.path.relpath(filesrc, setup.confdir),output_file=output_file,save_last_frame=save_last_frame,@@ -238,7 +238,7 @@ def setup(app):TEMPLATE = r"""-{% if display_source %}+{% if not hide_source %}.. raw:: html<div class="manim-example">@@ -258,7 +258,7 @@ TEMPLATE = r""":align: center{% endif %}-{% if display_source %}+{% if not hide_source %}.. raw:: html</div>diff --git a/docs/source/tutorials/a_deeper_look.rst b/docs/source/tutorials/a_deeper_look.rstindex f942f30dd..370b8a9d8 100644--- a/docs/source/tutorials/a_deeper_look.rst+++ b/docs/source/tutorials/a_deeper_look.rst@@ -65,6 +65,7 @@ will play it once it's done since we are using the ``-p`` flag. The outputshould look like this:.. manim:: SquareToCircle3+ :hide_source::quality: highclass SquareToCircle3(Scene):diff --git a/docs/source/tutorials/building_blocks.rst b/docs/source/tutorials/building_blocks.rstindex 750055899..96a4f8a27 100644--- a/docs/source/tutorials/building_blocks.rst+++ b/docs/source/tutorials/building_blocks.rst@@ -61,7 +61,6 @@ screen, simply call the :meth:`~.Scene.remove` method from the containing:class:`.Scene`... manim:: CreatingMobjects- :display_source::quality: mediumclass CreatingMobjects(Scene):@@ -81,7 +80,6 @@ some mobjects to it. This script generates a static picture that displays acircle, a square, and a triangle:.. manim:: Shapes- :display_source::quality: mediumclass Shapes(Scene):@@ -114,7 +112,6 @@ There are many other possible ways to place mobjects on the screen, for example``MobjectPlacement`` uses all three... manim:: MobjectPlacement- :display_source::quality: mediumclass MobjectPlacement(Scene):@@ -163,7 +160,6 @@ Styling mobjectsThe following scene changes the default aesthetics of the mobjects... manim:: MobjectStyling- :display_source::quality: mediumclass MobjectStyling(Scene):@@ -200,7 +196,6 @@ The next scene is exactly the same as the ``MobjectStyling`` scene from theprevious section, except for exactly one line... manim:: MobjectZOrder- :display_source::quality: mediumclass MobjectZOrder(Scene):@@ -234,7 +229,6 @@ At the heart of manim is animation. Generally, you can add an animation toyour scene by calling the :meth:`~.Scene.play` method... manim:: SomeAnimations- :display_source::quality: mediumclass SomeAnimations(Scene):@@ -271,7 +265,6 @@ method that changes a mobject's property can be used as an animation, throughthe use of :class:`.ApplyMethod`... manim:: ApplyMethodExample- :display_source::quality: mediumclass ApplyMethodExample(Scene):@@ -300,7 +293,6 @@ By default, any animation passed to :meth:`play` lasts for exactly one second.Use the :code:`run_time` argument to control the duration... manim:: RunTime- :display_source::quality: mediumclass RunTime(Scene):diff --git a/docs/source/tutorials/quickstart.rst b/docs/source/tutorials/quickstart.rstindex 9ab8f05d1..5f1614597 100644--- a/docs/source/tutorials/quickstart.rst+++ b/docs/source/tutorials/quickstart.rst@@ -58,6 +58,7 @@ and open that file with the default movie player application. You should see avideo playing the following animation... manim:: SquareToCircle+ :hide_source::quality: lowclass SquareToCircle(Scene):@@ -153,6 +154,7 @@ And render it using the following command:The output should look as follows... manim:: SquareToCircle2+ :hide_source::quality: lowclass SquareToCircle2(Scene):diff --git a/manim/mobject/changing.py b/manim/mobject/changing.pyindex 58c3b0625..db73ac566 100644--- a/manim/mobject/changing.py+++ b/manim/mobject/changing.py@@ -16,7 +16,6 @@ class AnimatedBoundary(VGroup):Examples--------.. manim:: AnimatedBoundaryExample- :display_source::quality: lowclass AnimatedBoundaryExample(Scene):@@ -90,7 +89,6 @@ class TracedPath(VMobject):Examples--------.. manim:: TracedPathExample- :display_source::quality: lowclass TracedPathExample(Scene):diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.pyindex a2ad4d1fd..94a53f851 100644--- a/manim/mobject/geometry.py+++ b/manim/mobject/geometry.py@@ -895,7 +895,7 @@ class ArrowTip(VMobject):a custom one like this:.. manim:: CustomTipExample- :display_source:+ :quality: low>>> class MyCustomArrowTip(ArrowTip, RegularPolygon):... def __init__(self, **kwargs):diff --git a/manim/mobject/value_tracker.py b/manim/mobject/value_tracker.pyindex 3955b0d0f..aeeac1478 100644--- a/manim/mobject/value_tracker.py+++ b/manim/mobject/value_tracker.py@@ -21,7 +21,6 @@ class ValueTracker(Mobject):Examples--------.. manim:: ValueTrackerExample- :display_source::quality: lowclass ValueTrackerExample(Scene):