@@ -14,6 +14,7 @@ build:
os: ubuntu-24.04
tools:
python: "3.12"
+ rust: "1.86"
apt_packages:
- autoconf
- autoconf-archive
@@ -24,6 +25,8 @@ build:
- gir1.2-glib-2.0-dev
- gobject-introspection
- graphviz
+ # Needed by rust bindgen for stdbool.h
+ - libclang-dev
- libglib2.0-dev-bin
- libgudev-1.0-dev
- libtool
@@ -54,15 +54,16 @@ except ImportError:
html_theme = "sphinx_rtd_theme" if sphinx_rtd_theme else "default"
+# We need to know where to put docs generated by gi-docgen and cargo but
+# app.outdir is only set once the builder is initialized. Let's delay running
+# gi-docgen until we're notified.
+#
+# For some reason on RTD we're in the docs/ directory while during a local
+# build, we're still in the top source directory.
+prefix = "../" if os.getenv("READTHEDOCS") == "True" else "./"
+
-# We need to know where to put docs generated by gi-docgen but app.outdir is
-# only set once the builder is initialized. Let's delay running gi-docgen
-# until we're notified.
def make_glib_docs(app):
- # For some reason on RTD we're in the docs/ directory while during a local
- # build, we're still in the top source directory.
- prefix = "../" if os.getenv("READTHEDOCS") == "True" else "./"
-
subprocess.run(
[
"gi-docgen",
@@ -77,8 +78,31 @@ def make_glib_docs(app):
)
+def make_rust_docs(app):
+ subprocess.run(
+ [
+ "cargo",
+ "doc",
+ "--manifest-path",
+ f"{prefix}/bindings/rust/libgpiod/Cargo.toml",
+ "--target-dir",
+ f"{app.outdir}/rust/",
+ "--no-deps",
+ "--package=libgpiod",
+ ],
+ check=True,
+ env=dict(
+ os.environ,
+ SYSTEM_DEPS_LIBGPIOD_LIB="gpiod",
+ SYSTEM_DEPS_LIBGPIOD_NO_PKG_CONFIG="1",
+ SYSTEM_DEPS_LIBGPIOD_INCLUDE="../../../include/",
+ ),
+ )
+
+
def setup(app):
app.connect("builder-inited", make_glib_docs)
+ app.connect("builder-inited", make_rust_docs)
subprocess.run(["doxygen", "Doxyfile"])
@@ -5,19 +5,25 @@
..
This file is part of libgpiod.
-Where are the Rust bindings?
-=============================
+ libgpiod Rust bindings documentation
-.. warning::
- There's currently no good way of integrating rust documentation with sphinx.
- Rust bindings should be documented on https://docs.rs/ but due to a yet
- unsolved build problem, this is currently not the case. Please refer to the
- in-source comments for now.
+libgpiod Rust bindings API
+==========================
-Rust bindings are available on https://crates.io/ as the ``libgpiod`` package.
+Rust bindings for libgpiod aim to provide a memory-safe interface to the
+low-level C API. They are available on https://crates.io/ as the ``libgpiod``
+package.
.. note::
When building the Rust bindings along the C library using make, they will
be automatically configured to build against the build results of the
C library. Building rust bindings requires cargo to be available on the
system.
+
+.. warning::
+ The documentation for Rust bindings is generated using ``cargo doc`` and
+ cannot be easily integrated with sphinx documentation. Please navigate to
+ a separate section dedicated exclusively to the Rust part of the API.
+
+
+`Navigate to Rust bindings documentation <rust/doc/libgpiod/index.html>`_