Skip to content

Commit 541bf96

Browse files
feat(lib): add Slide.next_section method (#295)
* feat(lib): add `Slide.next_section` method * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6267641 commit 541bf96

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ In an effort to better document changes, this CHANGELOG document is now created.
4343
- Added `loop` option to `Slide`'s `next_slide` method.
4444
Calling `next_slide` will never fail anymore.
4545
[#294](https://github.com/jeertmans/manim-slides/pull/294)
46+
- Added `Slide.next_section` for compatibility with `manim`'s
47+
`Scene.next_section` method.
48+
[#295](https://github.com/jeertmans/manim-slides/pull/295)
4649

4750
(v5-changed)=
4851
### Changed

docs/source/reference/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use, not the methods used internally when rendering.
1515
canvas,
1616
canvas_mobjects,
1717
mobjects_without_canvas,
18+
next_section,
1819
next_slide,
1920
remove_from_canvas,
2021
wait_time_between_slides,

manim_slides/slide/base.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,24 @@ def play(self, *args: Any, **kwargs: Any) -> None:
252252
super().play(*args, **kwargs) # type: ignore[misc]
253253
self._current_animation += 1
254254

255-
def next_slide(self, loop: bool = False) -> None:
255+
def next_slide(self, *, loop: bool = False, **kwargs: Any) -> None:
256256
"""
257257
Create a new slide with previous animations, and setup options
258258
for the next slide.
259259
260260
This usually means that the user will need to press some key before the
261261
next slide is played. By default, this is the right arrow key.
262262
263+
:param args:
264+
Positional arguments to be passed to
265+
:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`,
266+
or ignored if `manimlib` API is used.
263267
:param loop:
264268
If set, next slide will be looping.
269+
:param kwargs:
270+
Keyword arguments to be passed to
271+
:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`,
272+
or ignored if `manimlib` API is used.
265273
266274
.. note::
267275
@@ -273,6 +281,11 @@ def next_slide(self, loop: bool = False) -> None:
273281
When rendered with RevealJS, loops cannot be in the first nor
274282
the last slide.
275283
284+
.. seealso::
285+
286+
When using ``manim`` API, this method will also call
287+
:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`.
288+
276289
Examples
277290
--------
278291
The following contains 3 slides:

manim_slides/slide/manim.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ def _leave_progress_bar(self) -> bool:
6464
def _start_at_animation_number(self) -> Optional[int]:
6565
return config["from_animation_number"] # type: ignore
6666

67+
def next_section(self, *args: Any, **kwargs: Any) -> None:
68+
"""
69+
Alias to :meth:`next_slide`.
70+
71+
:param args:
72+
Positional arguments to be passed to :meth:`next_slide`.
73+
:param kwargs:
74+
Keyword arguments to be passed to :meth:`next_slide`.
75+
76+
.. attention::
77+
78+
This method is only available when using ``manim`` API.
79+
"""
80+
self.next_slide(*args, **kwargs)
81+
82+
def next_slide(self, *args: Any, loop: bool = False, **kwargs: Any) -> None:
83+
Scene.next_section(self, *args, **kwargs)
84+
BaseSlide.next_slide(self, loop=loop)
85+
6786
def render(self, *args: Any, **kwargs: Any) -> None:
6887
"""MANIM render."""
6988
# We need to disable the caching limit since we rely on intermediate files

0 commit comments

Comments
 (0)