Skip to content

Commit

Permalink
board/common: extract YANG documentation for all builds
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
troglobit committed Jun 28, 2024
1 parent edaaa33 commit 10744c5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
36 changes: 36 additions & 0 deletions board/common/post-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@ common=$(dirname "$(readlink -f "$0")")
. "$BR2_CONFIG" 2>/dev/null
. "$TARGET_DIR/usr/lib/os-release"

# Extract list of loaded YANG modules and their features for yangdoc.html
mkyangdoc()
{
cmd="yangdoc -o $1 -p $TARGET_DIR/usr/share/yang"

# shellcheck disable=SC2155
export SYSREPO_SHM_PREFIX="yangdoc"
while IFS= read -r line; do
if echo "$line" | grep -q '^[a-z]'; then
module=$(echo "$line" | awk '{print $1}')
cmd="$cmd -m $module"
feature=$(echo "$line" | awk -F'|' '{print $8}' | sed 's/^ *//;s/ *$//')
if [ -n "$feature" ]; then
feature_list=$(echo "$feature" | tr ' ' '\n')
for feat in $feature_list; do
cmd="$cmd -e $feat"
done
fi
fi
done <<EOF
$(sysrepoctl -l; rm -f /dev/shm/${SYSREPO_SHM_PREFIX}*)
EOF

# Ignore a few top-level oddballs not used by core Infix
cmd="$cmd -x supported-algorithms"

# Execute the command
echo "Calling: $cmd"
$cmd
}

if [ -n "${ID_LIKE}" ]; then
ID="${ID} ${ID_LIKE}"
fi
Expand Down Expand Up @@ -85,3 +116,8 @@ grep -qsE '^/bin/false$$' "$TARGET_DIR/etc/shells" \
# Allow clish (symlink to /usr/bin/klish) to be a login shell
grep -qsE '^/bin/clish$$' "$TARGET_DIR/etc/shells" \
|| echo "/bin/clish" >> "$TARGET_DIR/etc/shells"

# Create YANG documentation
if [ "$BR2_PACKAGE_HOST_PYTHON_YANGDOC" = "y" ]; then
mkyangdoc "$BINARIES_DIR/yangdoc.html"
fi
1 change: 1 addition & 0 deletions configs/aarch64_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ BR2_PACKAGE_PODMAN_DRIVER_VFS=y
BR2_PACKAGE_TETRIS=y
BR2_PACKAGE_ROUSETTE=y
BR2_PACKAGE_LIBINPUT=y
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
DISK_IMAGE_BOOT_BIN=y
TRUSTED_KEYS=y
TRUSTED_KEYS_DEVELOPMENT=y
Expand Down
1 change: 1 addition & 0 deletions configs/r2s_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,6 @@ BR2_PACKAGE_PODMAN_DRIVER_VFS=y
BR2_PACKAGE_TETRIS=y
BR2_PACKAGE_ROUSETTE=y
BR2_PACKAGE_LIBINPUT=y
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
# SIGN_ENABLED is not set
# GNS3_APPLIANCE is not set
1 change: 1 addition & 0 deletions configs/x86_64_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y
BR2_PACKAGE_PODMAN_DRIVER_VFS=y
BR2_PACKAGE_TETRIS=y
BR2_PACKAGE_ROUSETTE=y
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
TRUSTED_KEYS=y
TRUSTED_KEYS_DEVELOPMENT=y
GNS3_APPLIANCE_RAM=512
Expand Down

0 comments on commit 10744c5

Please sign in to comment.