mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
Because this module describes devices that can be built into a hub or other device. Since this design is now explicitly shown in the docs as well, we don't need to hide this module in the package.
27 lines
661 B
Python
27 lines
661 B
Python
"""Sphinx workaround to document instance attributes such as self.light"""
|
|
|
|
from .builtins import Speaker, Display, Battery, ColorLight, KeyPad, LightArray
|
|
|
|
from types import ModuleType
|
|
|
|
def make_instance(classdef):
|
|
"""Make a class instance to look like a module so Sphinx can parse it."""
|
|
name = ''
|
|
mod = ModuleType(name)
|
|
for m in classdef.__dict__.values():
|
|
if callable(m):
|
|
setattr(mod, m.__name__, m)
|
|
return mod
|
|
|
|
light = make_instance(ColorLight)
|
|
|
|
lights = make_instance(LightArray)
|
|
|
|
buttons = make_instance(KeyPad)
|
|
|
|
battery = make_instance(Battery)
|
|
|
|
speaker = make_instance(Speaker)
|
|
|
|
display = make_instance(Display)
|