1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
# This file is part of libgpiod.
#
# Configuration file for the Sphinx documentation builder.
import os
import re
import subprocess
import sys
from pathlib import Path
project = "libgpiod"
copyright = "2017-2025, Bartosz Golaszewski"
author = "Bartosz Golaszewski"
master_doc = "index"
source_suffix = ".rst"
# Extract the full version from configure.ac (including -devel, -rc and other
# tags).
with open("../configure.ac", "r") as fd:
version = ""
extra = ""
for line in fd.readlines():
match = re.search(r"AC_INIT\(\[libgpiod\], \[(.*?)\]\)", line)
if match:
version = match.group(1)
continue
match = re.search(r"AC_SUBST\(EXTRA_VERSION, \[(.*?)\]\)", line)
if match:
extra = match.group(1)
release = f"{version}{extra}"
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:
import sphinx_rtd_theme
extensions.append("sphinx_rtd_theme")
except ImportError:
pass
html_theme = "sphinx_rtd_theme" if sphinx_rtd_theme else "default"
# 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",
"generate",
"--config",
f"{prefix}bindings/glib/gi-docgen.toml",
f"{prefix}bindings/glib/Gpiodglib-1.0.gir",
"--output-dir",
f"{app.outdir}",
],
check=True,
)
def setup(app):
app.connect("builder-inited", make_glib_docs)
subprocess.run(["doxygen", "Doxyfile"])
cwd = os.getcwd()
os.chdir("..")
subprocess.run(["autoreconf", "-ifv"], check=True)
subprocess.run(
[
"./configure",
"--enable-tools",
"--enable-bindings-glib",
"--enable-introspection",
"--enable-tools",
"--enable-dbus",
],
check=True,
)
subprocess.run(["make", "-j"], check=True)
os.chdir(cwd)
for page in [
"gpiodetect",
"gpioinfo",
"gpioget",
"gpioset",
"gpiomon",
"gpionotify",
"gpio-manager",
"gpiocli",
"gpiocli-detect",
"gpiocli-find",
"gpiocli-info",
"gpiocli-get",
"gpiocli-monitor",
"gpiocli-notify",
"gpiocli-reconfigure",
"gpiocli-release",
"gpiocli-request",
"gpiocli-requests",
"gpiocli-set",
"gpiocli-wait",
]:
subprocess.run(
[
"pandoc",
"--from=man",
"--to=rst",
"--standalone",
"--wrap=none",
f"--output={page}.rst",
f"../man/{page}.man",
],
check=True,
)
subprocess.run(["gdbus-codegen", "--generate-rst", "dbus", "../dbus/lib/io.gpiod1.xml"])
|