summaryrefslogtreecommitdiff
path: root/tools/check-docs.sh
blob: b7623fed88a25ee632b42a5f95e44f1e19ac9be7 (plain)
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
#!/bin/bash

set -e

die() {
    printf '%s\n' "$@" >&2
    exit 1
}

word_regex() {
    tr '\n|<>\\' ' ' \
    | sed -e 's, *$,\\>,' \
          -e 's,^ *,\\<,' \
          -e 's, \+,\\>\\|\\<,g'
}

same_lines() {
    diff <(printf "%s\n" "$1"          | sed '/^$/d' | sort) \
         <(printf "%s\n%s\n" "$2" "$3" | sed '/^$/d' | sort) >&2
}

SOURCEDIR="$1"
[ -n "$SOURCEDIR" ] && SOURCEDIR="$SOURCEDIR/"

# Check that the D-Bus API docs contain all known interfaces
F1="$(sed -n 's,^      <xi:include href="dbus-\([^"]*\.xml\)"/>$,\1,p' "$SOURCEDIR"docs/api/network-manager-docs.xml)"
F2="$(cd "$SOURCEDIR"introspection; ls -1 *.xml)"
if ! same_lines "$F1" "$F2" ; then
    die "*** Error: D-Bus interfaces not included in docs/api/network-manager-docs.xml ***"
fi

# Check that files that define types that are in public libnm API are included in libnm documentation.
F1="$(sed -n 's/.*<xi:include href="xml\/\([^"]*\)\.xml".*/\1/p' "$SOURCEDIR"docs/libnm/libnm-docs.xml)"
F2="$(grep -l "$(sed -n 's/^[\t ]*\(.*_get_type\);/\1/p' "$SOURCEDIR"libnm/libnm.ver | word_regex)" \
           "$SOURCEDIR"libnm/*.h \
           "$SOURCEDIR"libnm-core/*.h \
      | sed 's,.*/\([^/]\+\)\.h$,\1,')"
F2_EXTRA="
annotation-glossary
api-index-full
nm-dbus-interface
nm-errors
nm-utils
nm-version
"
if ! same_lines "$F1" "$F2" "$F2_EXTRA"; then
    die "*** Error: libnm classes not included in docs/libnm/libnm-docs.xml ***"
fi