Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2af0403
refactor(lib): change how manim API is imported
jeertmans Oct 13, 2023
e0fdac9
chore(lib): delete old files
jeertmans Oct 13, 2023
01aca2f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 13, 2023
5ebb61c
Merge remote-tracking branch 'origin/refactor-manim' into refactor-manim
jeertmans Oct 13, 2023
f3ff76e
wip: moving all commands
jeertmans Oct 13, 2023
06ff18f
adding animations
jeertmans Oct 13, 2023
9355e3d
fix tests
jeertmans Oct 13, 2023
2211ac6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 13, 2023
dd57527
fix mypy
jeertmans Oct 13, 2023
effcc75
fixes
jeertmans Oct 13, 2023
418f1f7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 13, 2023
f5f60e7
trying to fix docs
jeertmans Oct 14, 2023
d4a6148
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 14, 2023
1b1d6c5
wip: docs
jeertmans Oct 16, 2023
c803d67
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2023
bccff71
make it work
jeertmans Oct 16, 2023
036a796
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2023
2c3e5cc
wip test
jeertmans Oct 16, 2023
927a489
Merge remote-tracking branch 'origin/refactor-manim' into refactor-manim
jeertmans Oct 16, 2023
fb97409
tests are working
jeertmans Oct 16, 2023
946cb11
improving docs
jeertmans Oct 16, 2023
aa8205a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2023
85ff07e
fix index
jeertmans Oct 16, 2023
b79da53
docs: nicer shift
jeertmans Oct 16, 2023
6c14ee2
docs: nicer quickstart example
jeertmans Oct 16, 2023
95f84ef
fix tests
jeertmans Oct 17, 2023
353a7f4
change tests
jeertmans Oct 17, 2023
7b37c2d
move coverage to test workflow
jeertmans Oct 17, 2023
b182e72
fix(tests): remove resolve
jeertmans Oct 17, 2023
ffe8322
strict resolve
jeertmans Oct 17, 2023
90a2909
change local path test
jeertmans Oct 17, 2023
4c1df69
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 17, 2023
f8978c2
documented changes
jeertmans Oct 17, 2023
489ea5b
Merge remote-tracking branch 'origin/refactor-manim' into refactor-manim
jeertmans Oct 17, 2023
c010971
cleanup docs
jeertmans Oct 17, 2023
4d166d5
cleanup files
jeertmans Oct 17, 2023
a767aef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 17, 2023
9300811
fix(ci): set type
jeertmans Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ repos:
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.9.1
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [--in-place, --config, ./pyproject.toml]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
hooks:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ Wrap a series of animations between `self.start_loop()` and `self.stop_loop()` w
# example.py

from manim import *

# or: from manimlib import *
from manim_slides import Slide


class BasicExample(Slide):
def construct(self):
circle = Circle(radius=3, color=BLUE)
Expand Down
2 changes: 2 additions & 0 deletions custom_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
style:
background_color: "#000000"
8 changes: 8 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@
"nbsphinx",
"myst_parser",
"sphinxext.opengraph",
# "sphinx_autodoc_typehints",
"sphinx_click",
"sphinx_copybutton",
# Custom
"manim_slides.docs.manim_slides_directive",
]

rst_prolog = """
.. role:: python(code)
:language: python
"""

typehints_defaults = "comma"
typehints_use_signature = True
typehints_use_signature_return = True
Expand All @@ -41,6 +47,8 @@
templates_path = ["_templates"]
exclude_patterns = []

# Removes the 'package.module' part from package.module.Class
add_module_names = False

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
Expand Down
2 changes: 2 additions & 0 deletions docs/source/docutils.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[restructuredtext parser]
syntax_highlight = short
20 changes: 17 additions & 3 deletions docs/source/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,36 @@ and `ThreeDSlide`, which are subclasses of `Scene` and `ThreeDScene` from Manim.
Therefore, we only document here the methods we think the end-user will ever
use, not the methods used internally when rendering.

## Slide

```{eval-rst}
.. autoclass:: manim_slides.Slide
.. autoclass:: manim_slides.slide.Slide
:members:
add_to_canvas,
canvas,
canvas_mobjects,
end_loop,
mobjects_without_canvas,
next_slide,
pause,
remove_from_canvas,
start_loop,
wait_time_between_slides,
wipe,
zoom,
```

## 3D Slide

.. autoclass:: manim_slides.ThreeDSlide
```{eval-rst}
.. autoclass:: manim_slides.slide.ThreeDSlide
:members:
```

## Animations

```{eval-rst}
.. automodule:: manim_slides.slide.animation
:members:
Wipe,
Zoom,
```
28 changes: 7 additions & 21 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# flake8: noqa: F403, F405
# type: ignore
import sys

if "manimlib" in sys.modules:
from manimlib import *
from manim_slides import Slide, ThreeDSlide
from manim_slides.slide import MANIM, MANIMGL

MANIMGL = True
else:
if MANIM:
from manim import *

MANIMGL = False

from manim_slides import Slide, ThreeDSlide
elif MANIMGL:
from manimlib import *


class BasicExample(Slide):
Expand All @@ -27,7 +23,6 @@ def construct(self):
self.end_loop() # This will loop until user inputs a key

self.play(dot.animate.move_to(ORIGIN))
self.next_slide() # Waits user to press continue to go to the next slide


class MultipleAnimationsInLastSlide(Slide):
Expand All @@ -46,8 +41,6 @@ def construct(self):
self.play(dot.animate.move_to(LEFT))
self.play(dot.animate.move_to(DOWN))

self.next_slide()


class TestFileTooLong(Slide):
"""This is used to check against solution for issue #123."""
Expand All @@ -64,8 +57,6 @@ def construct(self):
self.play(dot.animate.move_to(direction), run_time=0.1)
self.play(dot.animate.move_to(ORIGIN), run_time=0.1)

self.next_slide()


class ConvertExample(Slide):
"""WARNING: this example does not seem to work with ManimGL."""
Expand Down Expand Up @@ -207,7 +198,7 @@ def construct(self):
language="console",
).shift(DOWN)

self.play(self.wipe(title, code))
self.wipe(title, code)
self.next_slide()

self.play(FadeIn(step, shift=RIGHT))
Expand Down Expand Up @@ -311,11 +302,7 @@ def construct(self):
# [manimgl-3d]
# WARNING: 3b1b's manim change how ThreeDScene work,
# this is why things have to be managed differently.
class ThreeDExample(Slide):
CONFIG = {
"camera_class": ThreeDCamera,
}

class ThreeDExample(ThreeDSlide):
def construct(self):
axes = ThreeDAxes()
circle = Circle(radius=3, color=BLUE)
Expand All @@ -327,7 +314,6 @@ def construct(self):
frame.set_euler_angles(
theta=30 * DEGREES,
phi=75 * DEGREES,
gamma=0,
)

self.play(GrowFromCenter(circle))
Expand Down
3 changes: 1 addition & 2 deletions manim_slides/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .__version__ import __version__
from .convert import convert
from .logger import make_logger
from .logger import logger
from .present import list_scenes, present
from .wizard import init, wizard

Expand All @@ -27,7 +27,6 @@ def cli(notify_outdated_version: bool) -> None:

If no command is specified, defaults to `present`.
"""
logger = make_logger()
# Code below is mostly a copy from:
# https://github.com/ManimCommunity/manim/blob/main/manim/cli/render/commands.py
if notify_outdated_version:
Expand Down
6 changes: 2 additions & 4 deletions manim_slides/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def dispatch(key: PositiveInt) -> None:


class Config(BaseModel): # type: ignore[misc]
"""General Manim Slides config"""
"""General Manim Slides config."""

keys: Keys = Keys()

Expand Down Expand Up @@ -207,9 +207,7 @@ def to_file(self, path: Path) -> None:
f.write(self.model_dump_json(indent=2))

def copy_to(self, folder: Path, use_cached: bool = True) -> "PresentationConfig":
"""
Copy the files to a given directory.
"""
"""Copy the files to a given directory."""
for slide_config in self.slides:
file = slide_config.file
rev_file = slide_config.rev_file
Expand Down
17 changes: 8 additions & 9 deletions manim_slides/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def validate_config_option(


def file_to_data_uri(file: Path) -> str:
"""
Reads a video and returns the corresponding data-uri.
"""
"""Reads a video and returns the corresponding data-uri."""
b64 = b64encode(file.read_bytes()).decode("ascii")
mime_type = mimetypes.guess_type(file)[0] or "video/mp4"

Expand All @@ -84,9 +82,11 @@ def convert_to(self, dest: Path) -> None:
raise NotImplementedError

def load_template(self) -> str:
"""Returns the template as a string.
"""
Returns the template as a string.

An empty string is returned if no template is used."""
An empty string is returned if no template is used.
"""
return ""

def open(self, file: Path) -> Any:
Expand Down Expand Up @@ -358,7 +358,8 @@ def open(self, file: Path) -> bool:
return webbrowser.open(file.absolute().as_uri())

def convert_to(self, dest: Path) -> None:
"""Converts this configuration into a RevealJS HTML presentation, saved to DEST."""
"""Converts this configuration into a RevealJS HTML presentation, saved to
DEST."""
if self.data_uri:
assets_dir = Path("") # Actually we won't care.
else:
Expand Down Expand Up @@ -632,9 +633,7 @@ def convert(
config_options: Dict[str, str],
template: Optional[Path],
) -> None:
"""
Convert SCENE(s) into a given format and writes the result in DEST.
"""
"""Convert SCENE(s) into a given format and writes the result in DEST."""

presentation_configs = get_scenes_presentation_config(scenes, folder)

Expand Down
14 changes: 8 additions & 6 deletions manim_slides/docs/manim_slides_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def construct(self):


class SkipManimNode(nodes.Admonition, nodes.Element):
"""Auxiliary node class that is used when the ``skip-manim-slides`` tag is
present or ``.pot`` files are being built.
"""
Auxiliary node class that is used when the ``skip-manim-slides`` tag is present or
``.pot`` files are being built.

Skips rendering the manim-slides directive and outputs a placeholder instead.
"""
Expand All @@ -158,8 +159,9 @@ def depart(self, node):


def process_name_list(option_input: str, reference_type: str) -> list[str]:
r"""Reformats a string of space separated class names
as a list of strings containing valid Sphinx references.
r"""
Reformats a string of space separated class names as a list of strings containing
valid Sphinx references.

Tests
-----
Expand All @@ -175,8 +177,8 @@ def process_name_list(option_input: str, reference_type: str) -> list[str]:


class ManimSlidesDirective(Directive):
r"""The manim-slides directive, rendering videos while building
the documentation.
r"""
The manim-slides directive, rendering videos while building the documentation.

See the module docstring for documentation.
"""
Expand Down
5 changes: 2 additions & 3 deletions manim_slides/ipython/ipython_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def manim_slides(
cell: Optional[str] = None,
local_ns: Dict[str, Any] = {},
) -> None:
r"""Render Manim Slides contained in IPython cells.
Works as a line or cell magic.
r"""
Render Manim Slides contained in IPython cells. Works as a line or cell magic.

.. note::

Expand Down Expand Up @@ -143,7 +143,6 @@ def construct(self):
In case you want to hide the red box containing the output progress bar, the ``progress_bar`` config
option should be set to ``None``. This can also be done by passing ``--progress_bar None`` as a
CLI flag.

"""
if cell:
exec(cell, local_ns)
Expand Down
9 changes: 5 additions & 4 deletions manim_slides/logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Logger utils, mostly copied from Manim Community:

https://github.com/ManimCommunity/manim/blob/d5b65b844b8ce8ff5151a2f56f9dc98cebbc1db4/manim/_config/logger_utils.py#L29-L101
"""

Expand All @@ -8,7 +9,7 @@
from rich.console import Console
from rich.logging import RichHandler

__all__ = ["logger", "make_logger"]
__all__ = ["logger"]

HIGHLIGHTED_KEYWORDS = [ # these keywords are highlighted specially
"Played",
Expand All @@ -29,9 +30,7 @@


def make_logger() -> logging.Logger:
"""
Make a logger similar to the one used by Manim.
"""
"""Make a logger similar to the one used by Manim."""
RichHandler.KEYWORDS = HIGHLIGHTED_KEYWORDS
rich_handler = RichHandler(
show_time=True,
Expand All @@ -44,4 +43,6 @@ def make_logger() -> logging.Logger:
return logger


make_logger()

logger = logging.getLogger("manim-slides")
Loading