mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-07-05 16:16:31 +08:00
Compare commits
2 Commits
tests-grou
...
v4.16.1
Author | SHA1 | Date | |
---|---|---|---|
5461a20257 | |||
5e3603b40b |
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 4.16.0
|
current_version = 4.16.1
|
||||||
commit = True
|
commit = True
|
||||||
message = chore(version): bump {current_version} to {new_version}
|
message = chore(version): bump {current_version} to {new_version}
|
||||||
|
|
||||||
|
@ -29,4 +29,4 @@ keywords:
|
|||||||
- PowerPoint
|
- PowerPoint
|
||||||
- Python
|
- Python
|
||||||
license: MIT
|
license: MIT
|
||||||
version: v4.16.0
|
version: v4.16.1
|
||||||
|
@ -1 +1 @@
|
|||||||
__version__ = "4.16.0"
|
__version__ = "4.16.1"
|
||||||
|
@ -140,43 +140,48 @@ class Str(str):
|
|||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Ensures that the string is correctly quoted."""
|
"""Ensures that the string is correctly quoted."""
|
||||||
if self in ["true", "false", "null"]:
|
if self in ["true", "false", "null"]:
|
||||||
return super().__str__()
|
return self
|
||||||
else:
|
else:
|
||||||
return f"'{super().__str__()}'"
|
return f"'{super().__str__()}'"
|
||||||
|
|
||||||
|
|
||||||
|
class StrEnum(Enum):
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return str(self.value)
|
||||||
|
|
||||||
|
|
||||||
Function = str # Basically, anything
|
Function = str # Basically, anything
|
||||||
|
|
||||||
|
|
||||||
class JsTrue(str, Enum):
|
class JsTrue(str, StrEnum):
|
||||||
true = "true"
|
true = "true"
|
||||||
|
|
||||||
|
|
||||||
class JsFalse(str, Enum):
|
class JsFalse(str, StrEnum):
|
||||||
false = "false"
|
false = "false"
|
||||||
|
|
||||||
|
|
||||||
class JsBool(Str, Enum): # type: ignore
|
class JsBool(Str, StrEnum): # type: ignore
|
||||||
true = "true"
|
true = "true"
|
||||||
false = "false"
|
false = "false"
|
||||||
|
|
||||||
|
|
||||||
class JsNull(Str, Enum): # type: ignore
|
class JsNull(Str, StrEnum): # type: ignore
|
||||||
null = "null"
|
null = "null"
|
||||||
|
|
||||||
|
|
||||||
class ControlsLayout(Str, Enum): # type: ignore
|
class ControlsLayout(Str, StrEnum): # type: ignore
|
||||||
edges = "edges"
|
edges = "edges"
|
||||||
bottom_right = "bottom-right"
|
bottom_right = "bottom-right"
|
||||||
|
|
||||||
|
|
||||||
class ControlsBackArrows(Str, Enum): # type: ignore
|
class ControlsBackArrows(Str, StrEnum): # type: ignore
|
||||||
faded = "faded"
|
faded = "faded"
|
||||||
hidden = "hidden"
|
hidden = "hidden"
|
||||||
visibly = "visibly"
|
visibly = "visibly"
|
||||||
|
|
||||||
|
|
||||||
class SlideNumber(Str, Enum): # type: ignore
|
class SlideNumber(Str, StrEnum): # type: ignore
|
||||||
true = "true"
|
true = "true"
|
||||||
false = "false"
|
false = "false"
|
||||||
hdotv = "h.v"
|
hdotv = "h.v"
|
||||||
@ -185,24 +190,24 @@ class SlideNumber(Str, Enum): # type: ignore
|
|||||||
candt = "c/t"
|
candt = "c/t"
|
||||||
|
|
||||||
|
|
||||||
class ShowSlideNumber(Str, Enum): # type: ignore
|
class ShowSlideNumber(Str, StrEnum): # type: ignore
|
||||||
all = "all"
|
all = "all"
|
||||||
print = "print"
|
print = "print"
|
||||||
speaker = "speaker"
|
speaker = "speaker"
|
||||||
|
|
||||||
|
|
||||||
class KeyboardCondition(Str, Enum): # type: ignore
|
class KeyboardCondition(Str, StrEnum): # type: ignore
|
||||||
null = "null"
|
null = "null"
|
||||||
focused = "focused"
|
focused = "focused"
|
||||||
|
|
||||||
|
|
||||||
class NavigationMode(Str, Enum): # type: ignore
|
class NavigationMode(Str, StrEnum): # type: ignore
|
||||||
default = "default"
|
default = "default"
|
||||||
linear = "linear"
|
linear = "linear"
|
||||||
grid = "grid"
|
grid = "grid"
|
||||||
|
|
||||||
|
|
||||||
class AutoPlayMedia(Str, Enum): # type: ignore
|
class AutoPlayMedia(Str, StrEnum): # type: ignore
|
||||||
null = "null"
|
null = "null"
|
||||||
true = "true"
|
true = "true"
|
||||||
false = "false"
|
false = "false"
|
||||||
@ -211,25 +216,25 @@ class AutoPlayMedia(Str, Enum): # type: ignore
|
|||||||
PreloadIframes = AutoPlayMedia
|
PreloadIframes = AutoPlayMedia
|
||||||
|
|
||||||
|
|
||||||
class AutoAnimateMatcher(Str, Enum): # type: ignore
|
class AutoAnimateMatcher(Str, StrEnum): # type: ignore
|
||||||
null = "null"
|
null = "null"
|
||||||
|
|
||||||
|
|
||||||
class AutoAnimateEasing(Str, Enum): # type: ignore
|
class AutoAnimateEasing(Str, StrEnum): # type: ignore
|
||||||
ease = "ease"
|
ease = "ease"
|
||||||
|
|
||||||
|
|
||||||
AutoSlide = Union[PositiveInt, JsFalse]
|
AutoSlide = Union[PositiveInt, JsFalse]
|
||||||
|
|
||||||
|
|
||||||
class AutoSlideMethod(Str, Enum): # type: ignore
|
class AutoSlideMethod(Str, StrEnum): # type: ignore
|
||||||
null = "null"
|
null = "null"
|
||||||
|
|
||||||
|
|
||||||
MouseWheel = Union[JsNull, float]
|
MouseWheel = Union[JsNull, float]
|
||||||
|
|
||||||
|
|
||||||
class Transition(Str, Enum): # type: ignore
|
class Transition(Str, StrEnum): # type: ignore
|
||||||
none = "none"
|
none = "none"
|
||||||
fade = "fade"
|
fade = "fade"
|
||||||
slide = "slide"
|
slide = "slide"
|
||||||
@ -238,13 +243,13 @@ class Transition(Str, Enum): # type: ignore
|
|||||||
zoom = "zoom"
|
zoom = "zoom"
|
||||||
|
|
||||||
|
|
||||||
class TransitionSpeed(Str, Enum): # type: ignore
|
class TransitionSpeed(Str, StrEnum): # type: ignore
|
||||||
default = "default"
|
default = "default"
|
||||||
fast = "fast"
|
fast = "fast"
|
||||||
slow = "slow"
|
slow = "slow"
|
||||||
|
|
||||||
|
|
||||||
class BackgroundSize(Str, Enum): # type: ignore
|
class BackgroundSize(Str, StrEnum): # type: ignore
|
||||||
# From: https://developer.mozilla.org/en-US/docs/Web/CSS/background-size
|
# From: https://developer.mozilla.org/en-US/docs/Web/CSS/background-size
|
||||||
# TODO: support more background size
|
# TODO: support more background size
|
||||||
contain = "contain"
|
contain = "contain"
|
||||||
@ -254,11 +259,11 @@ class BackgroundSize(Str, Enum): # type: ignore
|
|||||||
BackgroundTransition = Transition
|
BackgroundTransition = Transition
|
||||||
|
|
||||||
|
|
||||||
class Display(Str, Enum): # type: ignore
|
class Display(Str, StrEnum): # type: ignore
|
||||||
block = "block"
|
block = "block"
|
||||||
|
|
||||||
|
|
||||||
class RevealTheme(str, Enum):
|
class RevealTheme(str, StrEnum):
|
||||||
black = "black"
|
black = "black"
|
||||||
white = "white"
|
white = "white"
|
||||||
league = "league"
|
league = "league"
|
||||||
|
@ -43,7 +43,7 @@ packages = [
|
|||||||
]
|
]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/jeertmans/manim-slides"
|
repository = "https://github.com/jeertmans/manim-slides"
|
||||||
version = "4.16.0"
|
version = "4.16.1"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
click = "^8.1.3"
|
click = "^8.1.3"
|
||||||
|
@ -1,6 +1,126 @@
|
|||||||
|
from enum import EnumMeta
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from manim_slides.convert import PDF, Converter, PowerPoint, RevealJS
|
from manim_slides.convert import (
|
||||||
|
PDF,
|
||||||
|
AutoAnimateEasing,
|
||||||
|
AutoAnimateMatcher,
|
||||||
|
AutoPlayMedia,
|
||||||
|
AutoSlideMethod,
|
||||||
|
BackgroundSize,
|
||||||
|
BackgroundTransition,
|
||||||
|
ControlsBackArrows,
|
||||||
|
ControlsLayout,
|
||||||
|
Converter,
|
||||||
|
Display,
|
||||||
|
JsBool,
|
||||||
|
JsFalse,
|
||||||
|
JsNull,
|
||||||
|
JsTrue,
|
||||||
|
KeyboardCondition,
|
||||||
|
NavigationMode,
|
||||||
|
PowerPoint,
|
||||||
|
PreloadIframes,
|
||||||
|
RevealJS,
|
||||||
|
RevealTheme,
|
||||||
|
ShowSlideNumber,
|
||||||
|
SlideNumber,
|
||||||
|
Transition,
|
||||||
|
TransitionSpeed,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("enum_type",),
|
||||||
|
[
|
||||||
|
(JsTrue,),
|
||||||
|
(JsFalse,),
|
||||||
|
(JsBool,),
|
||||||
|
(JsNull,),
|
||||||
|
(ControlsLayout,),
|
||||||
|
(ControlsBackArrows,),
|
||||||
|
(SlideNumber,),
|
||||||
|
(ShowSlideNumber,),
|
||||||
|
(KeyboardCondition,),
|
||||||
|
(NavigationMode,),
|
||||||
|
(AutoPlayMedia,),
|
||||||
|
(PreloadIframes,),
|
||||||
|
(AutoAnimateMatcher,),
|
||||||
|
(AutoAnimateEasing,),
|
||||||
|
(AutoSlideMethod,),
|
||||||
|
(Transition,),
|
||||||
|
(TransitionSpeed,),
|
||||||
|
(BackgroundSize,),
|
||||||
|
(BackgroundTransition,),
|
||||||
|
(Display,),
|
||||||
|
(RevealTheme,),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_format_enum(enum_type: EnumMeta) -> None:
|
||||||
|
for enum in enum_type: # type: ignore[var-annotated]
|
||||||
|
expected = str(enum)
|
||||||
|
got = f"{enum}"
|
||||||
|
|
||||||
|
assert expected == got
|
||||||
|
|
||||||
|
got = "{enum}".format(enum=enum)
|
||||||
|
|
||||||
|
assert expected == got
|
||||||
|
|
||||||
|
got = format(enum, "")
|
||||||
|
|
||||||
|
assert expected == got
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("enum_type",),
|
||||||
|
[
|
||||||
|
(ControlsLayout,),
|
||||||
|
(ControlsBackArrows,),
|
||||||
|
(SlideNumber,),
|
||||||
|
(ShowSlideNumber,),
|
||||||
|
(KeyboardCondition,),
|
||||||
|
(NavigationMode,),
|
||||||
|
(AutoPlayMedia,),
|
||||||
|
(PreloadIframes,),
|
||||||
|
(AutoAnimateMatcher,),
|
||||||
|
(AutoAnimateEasing,),
|
||||||
|
(AutoSlideMethod,),
|
||||||
|
(Transition,),
|
||||||
|
(TransitionSpeed,),
|
||||||
|
(BackgroundSize,),
|
||||||
|
(BackgroundTransition,),
|
||||||
|
(Display,),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_quoted_enum(enum_type: EnumMeta) -> None:
|
||||||
|
for enum in enum_type: # type: ignore[var-annotated]
|
||||||
|
if enum in ["true", "false", "null"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
expected = "'" + enum.value + "'"
|
||||||
|
got = str(enum)
|
||||||
|
|
||||||
|
assert expected == got
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("enum_type",),
|
||||||
|
[
|
||||||
|
(JsTrue,),
|
||||||
|
(JsFalse,),
|
||||||
|
(JsBool,),
|
||||||
|
(JsNull,),
|
||||||
|
(RevealTheme,),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_unquoted_enum(enum_type: EnumMeta) -> None:
|
||||||
|
for enum in enum_type: # type: ignore[var-annotated]
|
||||||
|
expected = enum.value
|
||||||
|
got = str(enum)
|
||||||
|
|
||||||
|
assert expected == got
|
||||||
|
|
||||||
|
|
||||||
class TestConverter:
|
class TestConverter:
|
||||||
|
Reference in New Issue
Block a user