File: html-preview.sh

package info (click to toggle)
btrfs-progs 6.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,504 kB
  • sloc: ansic: 126,181; sh: 7,642; python: 1,386; makefile: 900; asm: 296
file content (41 lines) | stat: -rwxr-xr-x 784 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
# Generate manual page preview as rendered by 'make html', removed some styling
# so there can be visual artifacts, usable for CI summary

if ! [ -f "$1" ]; then
	exit 0
fi

prefix=Documentation/
here=$(pwd)

if [ "$(basename \"$here\")" = 'Documentation' ]; then
	prefix=
fi

fn="$1"
bn=$(basename "$fn" .rst)
html=$(find "${prefix}"_build/html -name "$bn".'html')

if ! [ -f "$html" ]; then
	#echo "ERROR: cannot find html page '$html' from bn $bn fn $fn <br/>"
	exit 0
fi

cat << EOF
<details>
<summary>$fn</summary>

EOF

# Up to <div itemprop="articleBody">, before that there's left bar navigation

cat "$html" | sed -e 's/^\s\+//' | awk '
/^<div itemprop=.articleBody.>/ { doit=1; next; }
/^<\/body>/ { doit=0; next; }
doit==1 { print; }'

cat << EOF

</details>
EOF