File: docsrc2man.sh

package info (click to toggle)
vdr-plugin-epgsearch 2.2.0+git20170817-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 2,788 kB
  • sloc: ansic: 23,630; perl: 1,330; sh: 634; makefile: 226
file content (92 lines) | stat: -rwxr-xr-x 1,810 bytes parent folder | download
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
#
# Creates the man pages
#
# Needs: pod2man and nroff
#
# Mike Constabel
#
# Version 0.1 - 31.07.2006
# jasmin.j 24. May 2017:
#   Added dependency generation by "--depend <tag>"
#

DOCSRC="doc-src"

if [ ! -s "epgsearch.c" ]; then
	echo "Cannot find epgsearch.c. Call this script from epgsearch source directory."
	exit
fi

PRINT_DEPS=0
if [ "$1" = "--depend" ]; then
	PRINT_DEPS=1
	PRINT_DEPS_STMP=$2
	echo "$PRINT_DEPS_STMP: \\"
fi

VERSION="$(awk -F\" '/VERSION/ {print $2; exit;}' epgsearch.c)"

function man_dir () {
    if [ $PRINT_DEPS -eq 0 ]; then
		mkdir -p man/$1
		rm man/$1/* 2>/dev/null
    fi
}

function man_gen () {
	for i in "$DOCSRC"/$1/*.txt; do
		if [ $PRINT_DEPS -eq 0 ]; then
			echo -ne "create man page: ($1) $(basename "$i" ".txt")..."
			name=$(echo "$(basename "$i")" | sed -e 's/\.[0-9]\..*$//')
			sect=$(echo "$i" | sed -e 's/.*\.\([0-9]\)\.txt/\1/')
			pod2man -c "Epgsearch Version $VERSION" -n "$name" --section="$sect" "$i" >"man/$1/$(basename "$i" ".txt")"
			if [ $? -eq 0 ]; then
				echo " done."
			else
				echo " failed."
			fi
		else
			echo -e "\t$i \\"
		fi
	done
}

function man_gz () {
	if [ $PRINT_DEPS -eq 0 ]; then
		rm "$DOCSRC"/$1/*~ 2>/dev/null
		gzip -f man/$1/*.[0-9]
	fi
}

for LANGUAGE in $(ls "$DOCSRC"/); do

	[ ! -d ""$DOCSRC"/$LANGUAGE" ] && continue

	man_dir $LANGUAGE
	man_gen $LANGUAGE
	man_gz  $LANGUAGE

done

echo

if [ $PRINT_DEPS -eq 0 ]; then
	for LANGUAGE in $(ls "$DOCSRC"/); do

		[ ! -d "$DOCSRC/$LANGUAGE" ] && continue
		mkdir -p doc/$LANGUAGE
		rm doc/$LANGUAGE/* 2>/dev/null

		for i in man/$LANGUAGE/*.gz; do
			echo -ne "create doc file from man page: ($LANGUAGE) $(basename "$i")..."
			zcat "$i" | nroff -man - | col -xbp > "doc/$LANGUAGE/$(basename "$i" ".gz").txt"
			echo " done"
		done

	done

	echo
fi

#EOF