File: tweak-moin-manpage

package info (click to toggle)
moin 1.9.9-1+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 76,024 kB
  • sloc: python: 143,896; java: 10,704; php: 2,385; perl: 1,574; xml: 371; makefile: 214; sh: 81; sed: 5
file content (44 lines) | stat: -rw-r--r-- 1,081 bytes parent folder | download | duplicates (6)
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
#!/bin/bash
# Extract the list of moin sub-commands from the scripts source code,
# in order to improve the manpage.
# Copyright 2010, Frank lin Piat ; License GPL V2 or later.
set -e

IN=$1
OUT=$2

if echo "\\fB" | grep -vq "f" ; then
	# Dash needs more escaping (\\\\fB instead of \\fB)
	echo $0: Invalid shell >&2
	exit 2
fi

if [ ! -f "$IN" -o ! -d "$(dirname $OUT 2>/dev/null)" ]; then
	echo $0: Invalid parameters >&2
	exit 3
fi

# Let's generate a manpage with the list of moin commands and sub-comands.
sed -n -e '1,/TAG:INSERT_GENENERATED_START/p' \
	$IN > $OUT

for f in $(grep -l 'class PluginScript(' ./MoinMoin/script/*/*.py ); do
	cmd=$(dirname $f | sed -e 's,.*/,,' )
	subcmd=$(basename $f .py)

	(
	echo .sp
	echo .TP
	echo "\\fB$cmd\\fR \\fB$subcmd\\fR \\fB\\-\\-help\\fR \\fB[${subcmd}-option]\\fR"
	cat $f \
		| sed -n -e '/^Purpose:/,/^"""/p' \
		| sed -e '1d ; 2d' \
		| sed -e '/^=====/,$d' \
		| sed -e '$d' \
		| sed -e :a -e '/^\n*$/{$d;N;ba' -e '} # delete trailing blank lines'
	)>> $OUT
done

sed -n -e '/TAG:INSERT_GENENERATED_END/,$p' \
	$IN >> $OUT