@@ -161,6 +161,7 @@ class BaseSlideConfig(BaseModel): # type: ignore
161161 notes : str = ""
162162 dedent_notes : bool = True
163163 skip_animations : bool = False
164+ src : Optional [FilePath ] = None
164165
165166 @classmethod
166167 def wrapper (cls , arg_name : str ) -> Callable [..., Any ]:
@@ -205,14 +206,13 @@ def __wrapper__(*args: Any, **kwargs: Any) -> Any: # noqa: N807
205206 return _wrapper_
206207
207208 @model_validator (mode = "after" )
208- @classmethod
209209 def apply_dedent_notes (
210- cls , base_slide_config : "BaseSlideConfig"
210+ self ,
211211 ) -> "BaseSlideConfig" :
212- if base_slide_config .dedent_notes :
213- base_slide_config .notes = dedent (base_slide_config .notes )
212+ if self .dedent_notes :
213+ self .notes = dedent (self .notes )
214214
215- return base_slide_config
215+ return self
216216
217217
218218class PreSlideConfig (BaseSlideConfig ):
@@ -242,25 +242,33 @@ def index_is_posint(cls, v: int) -> int:
242242 return v
243243
244244 @model_validator (mode = "after" )
245- @classmethod
246245 def start_animation_is_before_end (
247- cls , pre_slide_config : "PreSlideConfig"
246+ self ,
248247 ) -> "PreSlideConfig" :
249- if pre_slide_config .start_animation >= pre_slide_config .end_animation :
250- if pre_slide_config .start_animation == pre_slide_config .end_animation == 0 :
251- raise ValueError (
252- "You have to play at least one animation (e.g., `self.wait()`) "
253- "before pausing. If you want to start paused, use the appropriate "
254- "command-line option when presenting. "
255- "IMPORTANT: when using ManimGL, `self.wait()` is not considered "
256- "to be an animation, so prefer to directly use `self.play(...)`."
257- )
258-
248+ if self .start_animation > self .end_animation :
259249 raise ValueError (
260250 "Start animation index must be strictly lower than end animation index"
261251 )
252+ return self
253+
254+ @model_validator (mode = "after" )
255+ def has_src_or_more_than_zero_animations (
256+ self ,
257+ ) -> "PreSlideConfig" :
258+ if self .src is not None and self .start_animation != self .end_animation :
259+ raise ValueError (
260+ "A slide cannot have 'src=...' and more than zero animations at the same time."
261+ )
262+ elif self .src is None and self .start_animation == self .end_animation :
263+ raise ValueError (
264+ "You have to play at least one animation (e.g., 'self.wait()') "
265+ "before pausing. If you want to start paused, use the appropriate "
266+ "command-line option when presenting. "
267+ "IMPORTANT: when using ManimGL, 'self.wait()' is not considered "
268+ "to be an animation, so prefer to directly use 'self.play(...)'."
269+ )
262270
263- return pre_slide_config
271+ return self
264272
265273 @property
266274 def slides_slice (self ) -> slice :
0 commit comments