From 282949d167f5f47a0c8a1a4299559fb6f95533b6 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Mon, 15 Jul 2019 13:39:03 +0200 Subject: [PATCH] doc: Fix minor Pycardium module docs issues Signed-off-by: Rahix <rahix@rahix.de> --- Documentation/pycardium/leds.rst | 13 +++++++++---- pycardium/modules/py/color.py | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Documentation/pycardium/leds.rst b/Documentation/pycardium/leds.rst index 892fb07c..44af2a6a 100644 --- a/Documentation/pycardium/leds.rst +++ b/Documentation/pycardium/leds.rst @@ -5,16 +5,21 @@ Set one of the card10's RGB LEDs to a certain color. - Example which sets all LEDs on the top to red::: + **Example**: + + .. code-block:: python import leds, color + # Set all of the top LEDs to red for i in range(11): leds.set(i, color.RED) - :param led: Which led to set. 0-10 are the leds on the top and 11-14 are the 4 "ambient" leds. - :param color: What color to set the led to. Should be a :py:class:`color.Color` but any list/tuple - with 3 elements will work just as well. + :param led: Which led to set. 0-10 are the leds on the top + and 11-14 are the 4 "ambient" leds. + :param color: What color to set the led to. Should be a + :py:class:`color.Color` but any list/tuple with 3 elements + will work just as well. .. py:data:: leds.BOTTOM_RIGHT diff --git a/pycardium/modules/py/color.py b/pycardium/modules/py/color.py index 83d4b5a5..7a64e20a 100644 --- a/pycardium/modules/py/color.py +++ b/pycardium/modules/py/color.py @@ -32,10 +32,26 @@ class Color(_ColorTuple): @classmethod def from_hex(cls, color): """ - Create a color from a hexadecimal number:: + Create a color from a hexadecimal number. + + This function is available both as a class method and directly inside + the color module: + + **Example**: + + .. code-block:: python + + from color import Color # Magenta Color.from_hex(0xff00ff) + + .. code-block:: python + + import color + + # Cyan + color.from_hex(0x00ffff) """ red = (color & 0xff0000) >> 16 green = (color & 0x00ff00) >> 8 -- GitLab