@@ -31,7 +31,18 @@ DOCS_DEPS = \
cpp_misc.rst \
cpp_request_config.rst \
Doxyfile \
- index.rst
+ index.rst \
+ python_api.rst \
+ python_chip_info.rst \
+ python_chip.rst \
+ python_edge_event.rst \
+ python_exceptions.rst \
+ python_info_event.rst \
+ python_line_info.rst \
+ python_line_request.rst \
+ python_line.rst \
+ python_line_settings.rst \
+ python_misc.rst
docs: $(DOCS_DEPS)
sphinx-build ./ ./sphinx-output
@@ -18,3 +18,4 @@ C library.
:caption: Contents
cpp_api
+ python_api
@@ -9,6 +9,7 @@ import os
import re
import subprocess
import sys
+from pathlib import Path
project = "libgpiod"
copyright = "2017-2025, Bartosz Golaszewski"
@@ -34,11 +35,14 @@ with open("../configure.ac", "r") as fd:
release = f"{version}{extra}"
-extensions = ["breathe"]
+extensions = ["breathe", "sphinx.ext.autodoc"]
breathe_projects = {"libgpiod": "./doxygen-output/xml"}
breathe_default_project = "libgpiod"
+sys.path.insert(0, str(Path("../bindings/python").resolve()))
+autodoc_mock_imports = ["gpiod._ext"]
+
# Use the RTD theme if available
sphinx_rtd_theme = None
try:
@@ -50,4 +54,16 @@ except ImportError:
html_theme = "sphinx_rtd_theme" if sphinx_rtd_theme else "default"
+
+def autodoc_skip_init(app, what, name, obj, would_skip, options):
+ if name == "__init__":
+ return False
+
+ return would_skip
+
+
+def setup(app):
+ app.connect("autodoc-skip-member", autodoc_skip_init)
+
+
subprocess.run(["doxygen", "Doxyfile"])
new file mode 100644
@@ -0,0 +1,33 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+ libgpiod python bindings documentation
+
+libgpiod Python bindings API
+============================
+
+The **libgpiod Python bindings** provide an interface to control and interact
+with GPIO (General-Purpose Input/Output) lines on Linux systems using the
+libgpiod library. The Python bindings allow developers to manage GPIO pins
+easily through Python scripts, enabling tasks such as reading input values,
+setting outputs, monitoring events, and configuring more fine-grained pin
+options.
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Contents
+
+ python_chip
+ python_chip_info
+ python_exceptions
+ python_line
+ python_line_info
+ python_info_event
+ python_edge_event
+ python_line_settings
+ python_line_request
+ python_misc
new file mode 100644
@@ -0,0 +1,12 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO chip
+=========
+
+.. autoclass:: gpiod.Chip
+ :members:
new file mode 100644
@@ -0,0 +1,12 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO chip info
+==============
+
+.. autoclass:: gpiod.ChipInfo
+ :members:
new file mode 100644
@@ -0,0 +1,12 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO edge event
+===============
+
+.. autoclass:: gpiod.EdgeEvent
+ :members:
new file mode 100644
@@ -0,0 +1,17 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+libgpiod python errors
+======================
+
+.. autoclass:: gpiod.ChipClosedError
+ :members:
+ :show-inheritance:
+
+.. autoclass:: gpiod.RequestReleasedError
+ :members:
+ :show-inheritance:
new file mode 100644
@@ -0,0 +1,12 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO info event
+===============
+
+.. autoclass:: gpiod.InfoEvent
+ :members:
new file mode 100644
@@ -0,0 +1,27 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO line definitions
+=====================
+
+.. autoclass:: gpiod.line.Value
+ :members:
+
+.. autoclass:: gpiod.line.Direction
+ :members:
+
+.. autoclass:: gpiod.line.Bias
+ :members:
+
+.. autoclass:: gpiod.line.Drive
+ :members:
+
+.. autoclass:: gpiod.line.Edge
+ :members:
+
+.. autoclass:: gpiod.line.Clock
+ :members:
new file mode 100644
@@ -0,0 +1,12 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO line info
+==============
+
+.. autoclass:: gpiod.LineInfo
+ :members:
new file mode 100644
@@ -0,0 +1,12 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO line request
+=================
+
+.. autoclass:: gpiod.LineRequest
+ :members:
new file mode 100644
@@ -0,0 +1,12 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+GPIO line settings
+==================
+
+.. autoclass:: gpiod.LineSettings
+ :members:
new file mode 100644
@@ -0,0 +1,13 @@
+..
+ SPDX-License-Identifier: CC-BY-SA-4.0
+ SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+..
+ This file is part of libgpiod.
+
+libgpiod python bindings misc
+=============================
+
+.. autofunction:: gpiod.is_gpiochip_device
+
+.. autofunction:: gpiod.request_lines