manim
manim copied to clipboard
Clean Up Manim's API
Currently, it's difficult to tell which methods are internal to Manim, and which are designed to be used by an end user. Once the API of Manim is solidified, it's easier to make more drastic changes without having to worry about breaking user code, because all you have to do is keep the public interface stable (ish).
Renaming methods to start with an _ to avoid them being documented is not a good solution, as the documentation should be for both developers and end users.
Because python support multi-inheritance there is possibility to use this kind of pattern to separate Internal and ui methods and information in code.
from __future__ import annotations
class ModelUi:
'''Methods intented for end users'''
def set_color(self:Model):
print("supertype UI")
class ModelApi:
def trade_info(self:Model):
return self.info
class Model(ModelUi, ModelApi):
'''Internal use only'''
class SubModelUI(ModelUi):
def set_color(self:SubModel):
print("subtype UI")
class SubModel(Model, SubModelUI):
'''Internal use only'''
pass
super = Model()
sub = SubModel()
super.set_color()
sub.set_color()