From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Vincent Fazio <vfazio@xes-inc.com>,
Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Erik Schilling <erik.schilling@linaro.org>,
Phil Howard <phil@gadgetoid.com>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org
Subject: [PATCH libgpiod v3 05/16] bindings: python: doc: describe undocumented members
Date: Thu, 06 Feb 2025 13:22:02 +0100 [thread overview]
Message-ID: <20250206-improve-docs-v3-5-2065191fff6f@linaro.org> (raw)
In-Reply-To: <20250206-improve-docs-v3-0-2065191fff6f@linaro.org>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
There are several public members in python bindings that are missing
docstrings. Document them for completeness.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
bindings/python/gpiod/chip_info.py | 5 +++++
bindings/python/gpiod/edge_event.py | 9 +++++++++
bindings/python/gpiod/info_event.py | 8 ++++++++
bindings/python/gpiod/line.py | 20 ++++++++++++++++++++
bindings/python/gpiod/line_info.py | 12 ++++++++++++
bindings/python/gpiod/line_settings.py | 8 ++++++++
6 files changed, 62 insertions(+)
diff --git a/bindings/python/gpiod/chip_info.py b/bindings/python/gpiod/chip_info.py
index 3306af2..737a45e 100644
--- a/bindings/python/gpiod/chip_info.py
+++ b/bindings/python/gpiod/chip_info.py
@@ -14,8 +14,13 @@ class ChipInfo:
"""
name: str
+ """Name of the chip."""
+
label: str
+ """Label of the chip."""
+
num_lines: int
+ """Number of lines exposed by the chip."""
def __str__(self) -> str:
return f'<ChipInfo name="{self.name}" label="{self.label}" num_lines={self.num_lines}>'
diff --git a/bindings/python/gpiod/edge_event.py b/bindings/python/gpiod/edge_event.py
index 7f5cd4d..c888cb2 100644
--- a/bindings/python/gpiod/edge_event.py
+++ b/bindings/python/gpiod/edge_event.py
@@ -16,14 +16,23 @@ class EdgeEvent:
"""
class Type(Enum):
+ """Possible edge event types."""
+
RISING_EDGE = _ext.EDGE_EVENT_TYPE_RISING
+ """Rising edge event."""
FALLING_EDGE = _ext.EDGE_EVENT_TYPE_FALLING
+ """Falling edge event."""
event_type: Type
+ """Edge event type."""
timestamp_ns: int
+ """Timestamp of the event in nanoseconds."""
line_offset: int
+ """Offset of the line on which this event was registered."""
global_seqno: int
+ """Global sequence number of this event."""
line_seqno: int
+ """Event sequence number specific to the concerned line."""
def __init__(
self,
diff --git a/bindings/python/gpiod/info_event.py b/bindings/python/gpiod/info_event.py
index 4a86697..cd2785e 100644
--- a/bindings/python/gpiod/info_event.py
+++ b/bindings/python/gpiod/info_event.py
@@ -17,13 +17,21 @@ class InfoEvent:
"""
class Type(Enum):
+ """Line status change event types."""
+
LINE_REQUESTED = _ext.INFO_EVENT_TYPE_LINE_REQUESTED
+ """Line has been requested."""
LINE_RELEASED = _ext.INFO_EVENT_TYPE_LINE_RELEASED
+ """Previously requested line has been released."""
LINE_CONFIG_CHANGED = _ext.INFO_EVENT_TYPE_LINE_CONFIG_CHANGED
+ """Line configuration has changed."""
event_type: Type
+ """Event type of the status change event."""
timestamp_ns: int
+ """Timestamp of the event."""
line_info: LineInfo
+ """Snapshot of line-info associated with the event."""
def __init__(self, event_type: int, timestamp_ns: int, line_info: LineInfo):
object.__setattr__(self, "event_type", InfoEvent.Type(event_type))
diff --git a/bindings/python/gpiod/line.py b/bindings/python/gpiod/line.py
index 33c7368..0cfc854 100644
--- a/bindings/python/gpiod/line.py
+++ b/bindings/python/gpiod/line.py
@@ -13,7 +13,9 @@ class Value(Enum):
"""Logical line states."""
INACTIVE = _ext.VALUE_INACTIVE
+ """Line is logically inactive."""
ACTIVE = _ext.VALUE_ACTIVE
+ """Line is logically active."""
def __bool__(self) -> bool:
return self == self.ACTIVE
@@ -23,40 +25,58 @@ class Direction(Enum):
"""Direction settings."""
AS_IS = _ext.DIRECTION_AS_IS
+ """Request the line(s), but don't change direction."""
INPUT = _ext.DIRECTION_INPUT
+ """Direction is input - for reading the value of an externally driven GPIO line."""
OUTPUT = _ext.DIRECTION_OUTPUT
+ """Direction is output - for driving the GPIO line."""
class Bias(Enum):
"""Internal bias settings."""
AS_IS = _ext.BIAS_AS_IS
+ """Don't change the bias setting when applying line config."""
UNKNOWN = _ext.BIAS_UNKNOWN
+ """The internal bias state is unknown."""
DISABLED = _ext.BIAS_DISABLED
+ """The internal bias is disabled."""
PULL_UP = _ext.BIAS_PULL_UP
+ """The internal pull-up bias is enabled."""
PULL_DOWN = _ext.BIAS_PULL_DOWN
+ """The internal pull-down bias is enabled."""
class Drive(Enum):
"""Drive settings."""
PUSH_PULL = _ext.DRIVE_PUSH_PULL
+ """Drive setting is push-pull."""
OPEN_DRAIN = _ext.DRIVE_OPEN_DRAIN
+ """Line output is open-drain."""
OPEN_SOURCE = _ext.DRIVE_OPEN_SOURCE
+ """Line output is open-source."""
class Edge(Enum):
"""Edge detection settings."""
NONE = _ext.EDGE_NONE
+ """Line edge detection is disabled."""
RISING = _ext.EDGE_RISING
+ """Line detects rising edge events."""
FALLING = _ext.EDGE_FALLING
+ """Line detects falling edge events."""
BOTH = _ext.EDGE_BOTH
+ """Line detects both rising and falling edge events."""
class Clock(Enum):
"""Event clock settings."""
MONOTONIC = _ext.CLOCK_MONOTONIC
+ """Line uses the monotonic clock for edge event timestamps."""
REALTIME = _ext.CLOCK_REALTIME
+ """Line uses the realtime clock for edge event timestamps."""
HTE = _ext.CLOCK_HTE
+ """Line uses the hardware timestamp engine for event timestamps."""
diff --git a/bindings/python/gpiod/line_info.py b/bindings/python/gpiod/line_info.py
index 1aca142..d31565e 100644
--- a/bindings/python/gpiod/line_info.py
+++ b/bindings/python/gpiod/line_info.py
@@ -16,17 +16,29 @@ class LineInfo:
"""
offset: int
+ """Offset of the line."""
name: str
+ """Name of the line."""
used: bool
+ """Indicates whether line is in use."""
consumer: str
+ """Name of the consumer of the line."""
direction: Direction
+ """Direction setting of the line."""
active_low: bool
+ """Active-low setting of the line."""
bias: Bias
+ """Bias setting of the line."""
drive: Drive
+ """Drive setting of the line."""
edge_detection: Edge
+ """Edge detection setting of the line."""
event_clock: Clock
+ """Event clock setting used for edge event timestamps for the line."""
debounced: bool
+ """Indicates whether line is debounced."""
debounce_period: timedelta
+ """Debounce period of the line."""
def __init__(
self,
diff --git a/bindings/python/gpiod/line_settings.py b/bindings/python/gpiod/line_settings.py
index 2aca71c..3752acd 100644
--- a/bindings/python/gpiod/line_settings.py
+++ b/bindings/python/gpiod/line_settings.py
@@ -17,13 +17,21 @@ class LineSettings:
"""
direction: Direction = Direction.AS_IS
+ """Line direction."""
edge_detection: Edge = Edge.NONE
+ """Edge detection setting."""
bias: Bias = Bias.AS_IS
+ """Line bias setting."""
drive: Drive = Drive.PUSH_PULL
+ """Line drive setting."""
active_low: bool = False
+ """Active-low switch."""
debounce_period: timedelta = timedelta()
+ """Debounce period of the line."""
event_clock: Clock = Clock.MONOTONIC
+ """Edge event timestamping clock setting."""
output_value: Value = Value.INACTIVE
+ """Output value of the line."""
# __repr__ generated by @dataclass uses repr for enum members resulting in
# an unusable representation as those are of the form: <NAME: $value>
--
2.45.2
next prev parent reply other threads:[~2025-02-06 12:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 12:21 [PATCH libgpiod v3 00/16] doc: improvements for ReadTheDocs Bartosz Golaszewski
2025-02-06 12:21 ` [PATCH libgpiod v3 01/16] build: set PACKAGE_URL Bartosz Golaszewski
2025-02-06 12:21 ` [PATCH libgpiod v3 02/16] bindings: cxx: doc: remove the gpiod_cxx doxygen group Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 03/16] bindings: python: doc: update the docstring for gpiod.request_lines() Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 04/16] bindings: python: doc: make code examples appear as such in sphinx Bartosz Golaszewski
2025-02-06 12:22 ` Bartosz Golaszewski [this message]
2025-02-06 12:22 ` [PATCH libgpiod v3 06/16] bindings: glib: add the configuration file for gi-docgen Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 07/16] dbus: daemon: add a more detailed description to help text Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 08/16] dbus: client: tweak " Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 09/16] dbus: improve comments in API xml Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 10/16] doc: create man entries for gpio-manager and gpiocli Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 11/16] doc: provide sphinx docs for the core C API and C++ bindings Bartosz Golaszewski
2025-02-10 14:53 ` [External] - " Vincent Fazio
2025-02-11 12:19 ` Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 12/16] doc: add documentation for python bindings Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 13/16] doc: add documentation for GLib bindings Bartosz Golaszewski
2025-02-10 15:10 ` [External] - " Vincent Fazio
2025-02-11 12:51 ` Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 14/16] doc: add documentation for gpio-tools Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 15/16] doc: add documentation for D-Bus API, daemon and command-line client Bartosz Golaszewski
2025-02-06 12:22 ` [PATCH libgpiod v3 16/16] doc: move README contents to sphinx docs Bartosz Golaszewski
2025-02-10 13:48 ` [External] - " Vincent Fazio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250206-improve-docs-v3-5-2065191fff6f@linaro.org \
--to=brgl@bgdev.pl \
--cc=bartosz.golaszewski@linaro.org \
--cc=erik.schilling@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=phil@gadgetoid.com \
--cc=vfazio@xes-inc.com \
--cc=viresh.kumar@linaro.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).