1#!/usr/bin/env bash
2# SPDX-License-Identifier: LGPL-2.1-or-later
3set -eu
4set -o pipefail
5
6sd_good=0
7sd_total=0
8udev_good=0
9udev_total=0
10
11deprecated=(
12    -e sd_bus_try_close
13    -e sd_bus_process_priority
14    -e sd_bus_message_get_priority
15    -e sd_bus_message_set_priority
16    -e sd_seat_can_multi_session
17    -e sd_journal_open_container
18)
19
20for symbol in $(nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | grep -wv "${deprecated[@]}" | sort -u); do
21    if test -f "${MESON_BUILD_ROOT:?}/man/$symbol.3"; then
22        echo "✓ Symbol $symbol() is documented."
23        good=1
24    else
25        echo -e "  \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m"
26        good=0
27    fi
28
29    case "$symbol" in
30        sd_*)
31            ((sd_good+=good))
32            ((sd_total+=1))
33            ;;
34        udev_*)
35            ((udev_good+=good))
36            ((udev_total+=1))
37            ;;
38        *)
39            echo 'unknown symbol prefix'
40            exit 1
41    esac
42done
43
44echo "libsystemd: $sd_good/$sd_total libudev: $udev_good/$udev_total"
45