[docs]classIDefaultPrintable(IPrinter,ABC):"""Base for printers that register themselves automatically. Subclasses must define `target_type()` and will be added to the shared dispatcher."""default_dispatcher=PrinterDispatcher()def__init_subclass__(cls,**kwargs):super().__init_subclass__(**kwargs)ifnotgetattr(cls,"__abstractmethods__",False):IDefaultPrintable.default_dispatcher.add(cls.target_type(),cls)
[docs]@staticmethod@abstractmethoddeftarget_type()->type:"""The NodeElement this printer handles."""
[docs]classDefaultCodePrinter(IPrinter):"""Printer that combines all default printers into one."""def__init__(self)->None:super().__init__(IDefaultPrintable.default_dispatcher)