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
|
#!/bin/sh
# Generate manual page preview as rendered to a terminal, without colors or
# text attributes, encapsulated html, usable for CI summary
if ! [ -f "$1" ]; then
exit 0
fi
width=120
prefix=Documentation/
here=$(pwd)
if [ "$(basename \"$here\")" = 'Documentation' ]; then
prefix=
fi
fn="$1"
bn=$(basename "$fn" .rst)
if [ "$bn" = 'btrfs-man5' ]; then
# This is the only page that does not follow from the file name,
# the translation could be done using the man_pages table in conf.py
# but for one entry let's add a exception here
man="${prefix}_build/man/btrfs.5"
else
man=$(find "${prefix}"_build/man -name "$bn".'[0-9]')
fi
if ! [ -f "$man" ]; then
#echo "ERROR: cannot find manual page '$man' from bn $bn fn $fn <br/>"
exit 0
fi
cat << EOF
<details>
<summary>$fn</summary>
\`\`\`
EOF
COLUMNS="$width" man -P cat "$man"
cat << EOF
\`\`\`
</details>
EOF
|