Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Added :ref_methods: to the manim directive (#1209)

kolibril131c2a5099133d
diff --git a/docs/source/examples.rst b/docs/source/examples.rst
index aaaca1ea6..844e8e0ad 100644
--- a/docs/source/examples.rst
+++ b/docs/source/examples.rst
@@ -57,7 +57,7 @@ Basic Concepts
.. manim:: BraceAnnotation
:save_last_frame:
:ref_classes: Brace
- :ref_functions: Brace.get_text Brace.get_tex
+ :ref_methods: Brace.get_text Brace.get_tex
class BraceAnnotation(Scene):
def construct(self):
@@ -100,7 +100,7 @@ Basic Concepts
.. manim:: BezierSpline
:save_last_frame:
:ref_classes: Line VGroup
- :ref_functions: VMobject.add_cubic_bezier_curve
+ :ref_methods: VMobject.add_cubic_bezier_curve
class BezierSpline(Scene):
def construct(self):
@@ -203,7 +203,7 @@ Animations
self.wait()
.. manim:: MovingAround
- :ref_functions: Mobject.shift VMobject.set_fill Mobject.scale Mobject.rotate
+ :ref_methods: Mobject.shift VMobject.set_fill Mobject.scale Mobject.rotate
class MovingAround(Scene):
def construct(self):
@@ -216,7 +216,7 @@ Animations
.. manim:: MovingAngle
:ref_classes: Angle
- :ref_functions: Mobject.rotate
+ :ref_methods: Mobject.rotate
class MovingAngle(Scene):
def construct(self):
@@ -296,7 +296,7 @@ Animations
self.wait()
.. manim:: RotationUpdater
- :ref_functions: Mobject.add_updater Mobject.remove_updater
+ :ref_methods: Mobject.add_updater Mobject.remove_updater
class RotationUpdater(Scene):
def construct(self):
@@ -317,7 +317,7 @@ Animations
.. manim:: PointWithTrace
:ref_classes: Rotating
- :ref_functions: VMobject.set_points_as_corners Mobject.add_updater
+ :ref_methods: VMobject.set_points_as_corners Mobject.add_updater
class PointWithTrace(Scene):
def construct(self):
@@ -344,7 +344,7 @@ Plotting with Manim
:save_last_frame:
:ref_modules: manim.scene.graph_scene
:ref_classes: MathTex
- :ref_functions: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.input_to_graph_point
+ :ref_methods: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.input_to_graph_point
class SinAndCosFunctionPlot(GraphScene):
def __init__(self, **kwargs):
@@ -378,7 +378,7 @@ Plotting with Manim
.. manim:: GraphAreaPlot
:save_last_frame:
:ref_modules: manim.scenes.graph_scene
- :ref_functions: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.get_area
+ :ref_methods: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.get_area
class GraphAreaPlot(GraphScene):
def __init__(self, **kwargs):
@@ -404,7 +404,7 @@ Plotting with Manim
.. manim:: HeatDiagramPlot
:save_last_frame:
:ref_modules: manim.scenes.graph_scene
- :ref_functions: GraphScene.setup_axes GraphScene.coords_to_point
+ :ref_methods: GraphScene.setup_axes GraphScene.coords_to_point
class HeatDiagramPlot(GraphScene):
def __init__(self, **kwargs):
@@ -441,7 +441,7 @@ Special Camera Settings
.. manim:: FollowingGraphCamera
:ref_modules: manim.scene.moving_camera_scene
:ref_classes: GraphScene MovingCameraScene MoveAlongPath Restore
- :ref_functions: Mobject.add_updater
+ :ref_methods: Mobject.add_updater
class FollowingGraphCamera(GraphScene, MovingCameraScene):
def setup(self):
@@ -474,7 +474,7 @@ Special Camera Settings
.. manim:: MovingZoomedSceneAround
:ref_modules: manim.scene.zoomed_scene
:ref_classes: ZoomedScene BackgroundRectangle UpdateFromFunc
- :ref_functions: Mobject.add_updater ZoomedScene.get_zoomed_display_pop_out_animation
+ :ref_methods: Mobject.add_updater ZoomedScene.get_zoomed_display_pop_out_animation
class MovingZoomedSceneAround(ZoomedScene):
# contributed by TheoremofBeethoven, www.youtube.com/c/TheoremofBeethoven
@@ -543,7 +543,7 @@ Special Camera Settings
.. manim:: FixedInFrameMObjectTest
:save_last_frame:
:ref_classes: ThreeDScene
- :ref_functions: ThreeDScene.set_camera_orientation ThreeDScene.add_fixed_in_frame_mobjects
+ :ref_methods: ThreeDScene.set_camera_orientation ThreeDScene.add_fixed_in_frame_mobjects
class FixedInFrameMObjectTest(ThreeDScene):
def construct(self):
@@ -558,7 +558,7 @@ Special Camera Settings
.. manim:: ThreeDLightSourcePosition
:save_last_frame:
:ref_classes: ThreeDScene ThreeDAxes ParametricSurface
- :ref_functions: ThreeDScene.set_camera_orientation
+ :ref_methods: ThreeDScene.set_camera_orientation
class ThreeDLightSourcePosition(ThreeDScene):
def construct(self):
@@ -577,7 +577,7 @@ Special Camera Settings
.. manim:: ThreeDCameraRotation
:ref_classes: ThreeDScene ThreeDAxes
- :ref_functions: ThreeDScene.begin_ambient_camera_rotation ThreeDScene.stop_ambient_camera_rotation
+ :ref_methods: ThreeDScene.begin_ambient_camera_rotation ThreeDScene.stop_ambient_camera_rotation
class ThreeDCameraRotation(ThreeDScene):
def construct(self):
@@ -593,7 +593,7 @@ Special Camera Settings
.. manim:: ThreeDCameraIllusionRotation
:ref_classes: ThreeDScene ThreeDAxes
- :ref_functions: ThreeDScene.begin_3dillusion_camera_rotation ThreeDScene.stop_3dillusion_camera_rotation
+ :ref_methods: ThreeDScene.begin_3dillusion_camera_rotation ThreeDScene.stop_3dillusion_camera_rotation
class ThreeDCameraIllusionRotation(ThreeDScene):
def construct(self):
@@ -664,7 +664,7 @@ Advanced Projects
.. manim:: OpeningManim
:ref_classes: Tex MathTex Write FadeInFrom LaggedStart NumberPlane Create
- :ref_functions: NumberPlane.prepare_for_nonlinear_transform
+ :ref_methods: NumberPlane.prepare_for_nonlinear_transform
class OpeningManim(Scene):
def construct(self):
@@ -722,7 +722,8 @@ Advanced Projects
.. manim:: SineCurveUnitCircle
:ref_classes: MathTex Circle Dot Line VGroup
- :ref_functions: Mobject.add_updater Mobject.remove_updater always_redraw
+ :ref_methods: Mobject.add_updater Mobject.remove_updater
+ :ref_functions: always_redraw
class SineCurveUnitCircle(Scene):
# contributed by heejin_park, https://infograph.tistory.com/230
diff --git a/docs/source/manim_directive.py b/docs/source/manim_directive.py
index e448b9e34..5709eaaff 100644
--- a/docs/source/manim_directive.py
+++ b/docs/source/manim_directive.py
@@ -64,7 +64,11 @@ directive:
rendered in a reference block after the source code.
ref_functions
- A list of functions and methods, separated by spaces,
+ 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.
"""
@@ -133,6 +137,7 @@ class ManimDirective(Directive):
"ref_modules": lambda arg: process_name_list(arg, "mod"),
"ref_classes": lambda arg: process_name_list(arg, "class"),
"ref_functions": lambda arg: process_name_list(arg, "func"),
+ "ref_methods": lambda arg: process_name_list(arg, "meth"),
}
final_argument_whitespace = True
@@ -163,6 +168,7 @@ class ManimDirective(Directive):
self.options.get("ref_modules", [])
+ self.options.get("ref_classes", [])
+ self.options.get("ref_functions", [])
+ + self.options.get("ref_methods", [])
)
if ref_content:
ref_block = f"""