Skip to content

Commit 10744c5

Browse files
committed
board/common: extract YANG documentation for all builds
This change builds on top of the earlier work to bootstrap Infix YANG modules at build time. Adding a step at the end of post-build.sh to call the yangdoc tool. The resulting yangdoc.html is a stand-alone HTML file of (almost) all YANG nodes. Almost because some top-level nodes are unused by Infix atm. and have been filtered out for readability. Fixes #432 Signed-off-by: Joachim Wiberg <[email protected]>
1 parent edaaa33 commit 10744c5

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

board/common/post-build.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@ common=$(dirname "$(readlink -f "$0")")
44
. "$BR2_CONFIG" 2>/dev/null
55
. "$TARGET_DIR/usr/lib/os-release"
66

7+
# Extract list of loaded YANG modules and their features for yangdoc.html
8+
mkyangdoc()
9+
{
10+
cmd="yangdoc -o $1 -p $TARGET_DIR/usr/share/yang"
11+
12+
# shellcheck disable=SC2155
13+
export SYSREPO_SHM_PREFIX="yangdoc"
14+
while IFS= read -r line; do
15+
if echo "$line" | grep -q '^[a-z]'; then
16+
module=$(echo "$line" | awk '{print $1}')
17+
cmd="$cmd -m $module"
18+
feature=$(echo "$line" | awk -F'|' '{print $8}' | sed 's/^ *//;s/ *$//')
19+
if [ -n "$feature" ]; then
20+
feature_list=$(echo "$feature" | tr ' ' '\n')
21+
for feat in $feature_list; do
22+
cmd="$cmd -e $feat"
23+
done
24+
fi
25+
fi
26+
done <<EOF
27+
$(sysrepoctl -l; rm -f /dev/shm/${SYSREPO_SHM_PREFIX}*)
28+
EOF
29+
30+
# Ignore a few top-level oddballs not used by core Infix
31+
cmd="$cmd -x supported-algorithms"
32+
33+
# Execute the command
34+
echo "Calling: $cmd"
35+
$cmd
36+
}
37+
738
if [ -n "${ID_LIKE}" ]; then
839
ID="${ID} ${ID_LIKE}"
940
fi
@@ -85,3 +116,8 @@ grep -qsE '^/bin/false$$' "$TARGET_DIR/etc/shells" \
85116
# Allow clish (symlink to /usr/bin/klish) to be a login shell
86117
grep -qsE '^/bin/clish$$' "$TARGET_DIR/etc/shells" \
87118
|| echo "/bin/clish" >> "$TARGET_DIR/etc/shells"
119+
120+
# Create YANG documentation
121+
if [ "$BR2_PACKAGE_HOST_PYTHON_YANGDOC" = "y" ]; then
122+
mkyangdoc "$BINARIES_DIR/yangdoc.html"
123+
fi

configs/aarch64_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ BR2_PACKAGE_PODMAN_DRIVER_VFS=y
157157
BR2_PACKAGE_TETRIS=y
158158
BR2_PACKAGE_ROUSETTE=y
159159
BR2_PACKAGE_LIBINPUT=y
160+
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
160161
DISK_IMAGE_BOOT_BIN=y
161162
TRUSTED_KEYS=y
162163
TRUSTED_KEYS_DEVELOPMENT=y

configs/r2s_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,6 @@ BR2_PACKAGE_PODMAN_DRIVER_VFS=y
184184
BR2_PACKAGE_TETRIS=y
185185
BR2_PACKAGE_ROUSETTE=y
186186
BR2_PACKAGE_LIBINPUT=y
187+
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
187188
# SIGN_ENABLED is not set
188189
# GNS3_APPLIANCE is not set

configs/x86_64_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y
159159
BR2_PACKAGE_PODMAN_DRIVER_VFS=y
160160
BR2_PACKAGE_TETRIS=y
161161
BR2_PACKAGE_ROUSETTE=y
162+
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
162163
TRUSTED_KEYS=y
163164
TRUSTED_KEYS_DEVELOPMENT=y
164165
GNS3_APPLIANCE_RAM=512

0 commit comments

Comments
 (0)