Files
pybricks-api/pybricks/_instances.py
T
Laurens Valk 529f8fe31c api: rename _common to builtins
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.
2019-10-18 16:05:23 +02:00

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)