Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanup docs
  • Loading branch information
jeertmans committed Oct 17, 2023
commit c010971f390ef663d9888df5bf66d52f5cadbe6d
11 changes: 2 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,13 @@
"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
autodoc_typehints = "both"

myst_enable_extensions = [
"colon_fence",
Expand Down Expand Up @@ -82,6 +74,7 @@
"python": ("https://docs.python.org/3", None),
"manim": ("https://docs.manim.community/en/stable/", None),
"manimlib": ("https://3b1b.github.io/manim/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
}

# -- OpenGraph settings
Expand Down
8 changes: 5 additions & 3 deletions docs/source/features_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ The following summarizes the different presentation features Manim Slides offers
| Pause animation | Yes | No | No | N/A |
| Play slide in reverse | Yes | No | No | N/A |
| Slide count | Yes | Yes (optional) | Yes (optional) | N/A |
| Animation count | Yes | No | No | N/A |
| Needs Python with Manim Slides installed | Yes | No | No | No
| Requires internet access | No | Yes | No | No |
| Auto. play slides | Yes | Yes | Yes | N/A |
Expand All @@ -23,5 +22,8 @@ The following summarizes the different presentation features Manim Slides offers
| Works cross-platforms | Yes | Yes | Partly[^1][^2] | Yes |
:::

[^1]: If you encounter a problem where slides do not automatically play or loops do not work, please [file an issue on GitHub](https://github.com/jeertmans/manim-slides/issues/new/choose).
[^2]: PowerPoint online does not seem to support automatic playing of videos, so you need LibreOffice Impress on Linux platforms.
[^1]: If you encounter a problem where slides do not automatically play or loops do not work,
please
[file an issue on GitHub](https://github.com/jeertmans/manim-slides/issues/new/choose).
[^2]: PowerPoint online does not seem to support automatic playing of videos,
so you need LibreOffice Impress on Linux platforms.
1 change: 1 addition & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Manim Slides.
quickstart
reference/index
features_table
manim_or_manimgl
```

```{toctree}
Expand Down
71 changes: 71 additions & 0 deletions docs/source/manim_or_manimgl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Manim or ManimGL

Manim Slides supports both Manim (Community Edition) and ManimGL (by 3b1b).

Because both modules have slightly different APIs, Manim Slides needs to know
which Manim API you are using, to import the correct module.

## Default Behavior

By default, Manim Slides looks at {py:data}`sys.modules` and chooses the first
Manim package that is already imported: `manim` for Manim,
`manimlib` for ManimGL. This works pretty well when rendering
the slides.

If both modules are present in {py:data}`sys.modules`, then Manim Slides will
prefer using `manim`.


### Usage

The simplest way to use Manim Slides with the correct Manim API is to:

1. first import the Manim API;
2. and, then, import `manim_slides`.

Example for `manim`:

```python
from manim import *
from manim_slides import Slide
```

Example for `manimlib`:

```python
from manimlib import *
from manim_slides import Slide
```

### Example of Default Import

The following code shows how Manim Slides detected that `manimlib`
was imported, so the {py:class}`Slide<manim_slides.slide.Slide>`
automatically subclasses the class from ManimGL, not Manim.

```python
from manimlib import Scene
from manim_slides import Slide

assert issubclass(Slide, Scene) # Slide subclasses Scene from ManimGL

from manim import Scene

assert not issubclass(Slide, Scene) # but not Scene from Manim
```

## Custom Manim API

If you want to override the default Manim API, you can set the `MANIM_API`
environment variable to:

- `manim` or `manimce` to import `manim`;
- `manimlib` or `manimgl` to import `manimlib`;

prior to importing `manim_slides`.

Note that Manim Slides will still first look at {py:data}`sys.modules` to check
if any of the two modules is already imported.

If you want to force Manim Slides to obey the `MANIM_API` environment variable,
you must also set `FORCE_MANIM_API=1`.
12 changes: 8 additions & 4 deletions manim_slides/slide/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
:meth:`Scene.play<manim.scene.scene.Scene.play>` call.

For each of the provided classes, there exists a method variant
that directly calls :python:`self.play(Animation(...))`, see
:class:`Slide`.
that directly calls ``self.play(Animation(...))``, see
:class:`Slide<manim_slides.slide.Slide>`.
"""

__all__ = ["Wipe", "Zoom"]

from typing import Any, Mapping, Sequence

import numpy as np

from . import MANIM

if MANIM:
from manim import LEFT, AnimationGroup, FadeIn, FadeOut, Mobject
from manim import LEFT, AnimationGroup, FadeIn, FadeOut
from manim.mobject.mobject import Mobject
else:
from manimlib import LEFT, AnimationGroup, FadeIn, FadeOut, Mobject
from manimlib import LEFT, AnimationGroup, FadeIn, FadeOut
Mobject = Any


class Wipe(AnimationGroup): # type: ignore[misc]
Expand Down
10 changes: 6 additions & 4 deletions manim_slides/slide/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__all__ = ["BaseSlide"]

import platform
from abc import abstractmethod
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
List,
MutableMapping,
Expand All @@ -20,12 +21,13 @@
from ..logger import logger
from ..utils import concatenate_video_files, merge_basenames, reverse_video_file

if TYPE_CHECKING:
from manim import Mobject
from . import MANIM

if MANIM:
from manim.mobject.mobject import Mobject
else:
Mobject = Any


class BaseSlide:
def __init__(
self, *args: Any, output_folder: Path = FOLDER_PATH, **kwargs: Any
Expand Down
Loading