Skip to content

Commit 1c2a509

Browse files
kolibril13jsonvillanuevabehackl
authored
Added :ref_methods: to the manim directive (#1209)
* fix manim_directive for methods * added ref_methods to Angle example * black * added new ref_methods references * sort out ref_functions vs ref_methods in examples.rst Co-authored-by: Jason Villanueva <[email protected]> Co-authored-by: Benjamin Hackl <[email protected]>
1 parent 21ad14e commit 1c2a509

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

docs/source/examples.rst

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Basic Concepts
5757
.. manim:: BraceAnnotation
5858
:save_last_frame:
5959
:ref_classes: Brace
60-
:ref_functions: Brace.get_text Brace.get_tex
60+
:ref_methods: Brace.get_text Brace.get_tex
6161

6262
class BraceAnnotation(Scene):
6363
def construct(self):
@@ -100,7 +100,7 @@ Basic Concepts
100100
.. manim:: BezierSpline
101101
:save_last_frame:
102102
:ref_classes: Line VGroup
103-
:ref_functions: VMobject.add_cubic_bezier_curve
103+
:ref_methods: VMobject.add_cubic_bezier_curve
104104

105105
class BezierSpline(Scene):
106106
def construct(self):
@@ -203,7 +203,7 @@ Animations
203203
self.wait()
204204

205205
.. manim:: MovingAround
206-
:ref_functions: Mobject.shift VMobject.set_fill Mobject.scale Mobject.rotate
206+
:ref_methods: Mobject.shift VMobject.set_fill Mobject.scale Mobject.rotate
207207

208208
class MovingAround(Scene):
209209
def construct(self):
@@ -216,7 +216,7 @@ Animations
216216

217217
.. manim:: MovingAngle
218218
:ref_classes: Angle
219-
:ref_functions: Mobject.rotate
219+
:ref_methods: Mobject.rotate
220220

221221
class MovingAngle(Scene):
222222
def construct(self):
@@ -296,7 +296,7 @@ Animations
296296
self.wait()
297297

298298
.. manim:: RotationUpdater
299-
:ref_functions: Mobject.add_updater Mobject.remove_updater
299+
:ref_methods: Mobject.add_updater Mobject.remove_updater
300300

301301
class RotationUpdater(Scene):
302302
def construct(self):
@@ -317,7 +317,7 @@ Animations
317317

318318
.. manim:: PointWithTrace
319319
:ref_classes: Rotating
320-
:ref_functions: VMobject.set_points_as_corners Mobject.add_updater
320+
:ref_methods: VMobject.set_points_as_corners Mobject.add_updater
321321

322322
class PointWithTrace(Scene):
323323
def construct(self):
@@ -344,7 +344,7 @@ Plotting with Manim
344344
:save_last_frame:
345345
:ref_modules: manim.scene.graph_scene
346346
:ref_classes: MathTex
347-
:ref_functions: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.input_to_graph_point
347+
:ref_methods: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.input_to_graph_point
348348

349349
class SinAndCosFunctionPlot(GraphScene):
350350
def __init__(self, **kwargs):
@@ -378,7 +378,7 @@ Plotting with Manim
378378
.. manim:: GraphAreaPlot
379379
:save_last_frame:
380380
:ref_modules: manim.scenes.graph_scene
381-
:ref_functions: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.get_area
381+
:ref_methods: GraphScene.setup_axes GraphScene.get_graph GraphScene.get_vertical_line_to_graph GraphScene.get_area
382382

383383
class GraphAreaPlot(GraphScene):
384384
def __init__(self, **kwargs):
@@ -404,7 +404,7 @@ Plotting with Manim
404404
.. manim:: HeatDiagramPlot
405405
:save_last_frame:
406406
:ref_modules: manim.scenes.graph_scene
407-
:ref_functions: GraphScene.setup_axes GraphScene.coords_to_point
407+
:ref_methods: GraphScene.setup_axes GraphScene.coords_to_point
408408

409409
class HeatDiagramPlot(GraphScene):
410410
def __init__(self, **kwargs):
@@ -441,7 +441,7 @@ Special Camera Settings
441441
.. manim:: FollowingGraphCamera
442442
:ref_modules: manim.scene.moving_camera_scene
443443
:ref_classes: GraphScene MovingCameraScene MoveAlongPath Restore
444-
:ref_functions: Mobject.add_updater
444+
:ref_methods: Mobject.add_updater
445445

446446
class FollowingGraphCamera(GraphScene, MovingCameraScene):
447447
def setup(self):
@@ -474,7 +474,7 @@ Special Camera Settings
474474
.. manim:: MovingZoomedSceneAround
475475
:ref_modules: manim.scene.zoomed_scene
476476
:ref_classes: ZoomedScene BackgroundRectangle UpdateFromFunc
477-
:ref_functions: Mobject.add_updater ZoomedScene.get_zoomed_display_pop_out_animation
477+
:ref_methods: Mobject.add_updater ZoomedScene.get_zoomed_display_pop_out_animation
478478

479479
class MovingZoomedSceneAround(ZoomedScene):
480480
# contributed by TheoremofBeethoven, www.youtube.com/c/TheoremofBeethoven
@@ -543,7 +543,7 @@ Special Camera Settings
543543
.. manim:: FixedInFrameMObjectTest
544544
:save_last_frame:
545545
:ref_classes: ThreeDScene
546-
:ref_functions: ThreeDScene.set_camera_orientation ThreeDScene.add_fixed_in_frame_mobjects
546+
:ref_methods: ThreeDScene.set_camera_orientation ThreeDScene.add_fixed_in_frame_mobjects
547547

548548
class FixedInFrameMObjectTest(ThreeDScene):
549549
def construct(self):
@@ -558,7 +558,7 @@ Special Camera Settings
558558
.. manim:: ThreeDLightSourcePosition
559559
:save_last_frame:
560560
:ref_classes: ThreeDScene ThreeDAxes ParametricSurface
561-
:ref_functions: ThreeDScene.set_camera_orientation
561+
:ref_methods: ThreeDScene.set_camera_orientation
562562

563563
class ThreeDLightSourcePosition(ThreeDScene):
564564
def construct(self):
@@ -577,7 +577,7 @@ Special Camera Settings
577577

578578
.. manim:: ThreeDCameraRotation
579579
:ref_classes: ThreeDScene ThreeDAxes
580-
:ref_functions: ThreeDScene.begin_ambient_camera_rotation ThreeDScene.stop_ambient_camera_rotation
580+
:ref_methods: ThreeDScene.begin_ambient_camera_rotation ThreeDScene.stop_ambient_camera_rotation
581581

582582
class ThreeDCameraRotation(ThreeDScene):
583583
def construct(self):
@@ -593,7 +593,7 @@ Special Camera Settings
593593

594594
.. manim:: ThreeDCameraIllusionRotation
595595
:ref_classes: ThreeDScene ThreeDAxes
596-
:ref_functions: ThreeDScene.begin_3dillusion_camera_rotation ThreeDScene.stop_3dillusion_camera_rotation
596+
:ref_methods: ThreeDScene.begin_3dillusion_camera_rotation ThreeDScene.stop_3dillusion_camera_rotation
597597

598598
class ThreeDCameraIllusionRotation(ThreeDScene):
599599
def construct(self):
@@ -664,7 +664,7 @@ Advanced Projects
664664

665665
.. manim:: OpeningManim
666666
:ref_classes: Tex MathTex Write FadeInFrom LaggedStart NumberPlane Create
667-
:ref_functions: NumberPlane.prepare_for_nonlinear_transform
667+
:ref_methods: NumberPlane.prepare_for_nonlinear_transform
668668

669669
class OpeningManim(Scene):
670670
def construct(self):
@@ -722,7 +722,8 @@ Advanced Projects
722722

723723
.. manim:: SineCurveUnitCircle
724724
:ref_classes: MathTex Circle Dot Line VGroup
725-
:ref_functions: Mobject.add_updater Mobject.remove_updater always_redraw
725+
:ref_methods: Mobject.add_updater Mobject.remove_updater
726+
:ref_functions: always_redraw
726727

727728
class SineCurveUnitCircle(Scene):
728729
# contributed by heejin_park, https://infograph.tistory.com/230

docs/source/manim_directive.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ def construct(self):
6464
rendered in a reference block after the source code.
6565
6666
ref_functions
67-
A list of functions and methods, separated by spaces,
67+
A list of functions, separated by spaces,
68+
that is rendered in a reference block after the source code.
69+
70+
ref_methods
71+
A list of methods, separated by spaces,
6872
that is rendered in a reference block after the source code.
6973
7074
"""
@@ -133,6 +137,7 @@ class ManimDirective(Directive):
133137
"ref_modules": lambda arg: process_name_list(arg, "mod"),
134138
"ref_classes": lambda arg: process_name_list(arg, "class"),
135139
"ref_functions": lambda arg: process_name_list(arg, "func"),
140+
"ref_methods": lambda arg: process_name_list(arg, "meth"),
136141
}
137142
final_argument_whitespace = True
138143

@@ -163,6 +168,7 @@ def run(self):
163168
self.options.get("ref_modules", [])
164169
+ self.options.get("ref_classes", [])
165170
+ self.options.get("ref_functions", [])
171+
+ self.options.get("ref_methods", [])
166172
)
167173
if ref_content:
168174
ref_block = f"""

0 commit comments

Comments
 (0)