Skip to content
Extraits de code Groupes Projets
Vérifiée Valider e228571c rédigé par Kubat's avatar Kubat
Parcourir les fichiers

WIP: Generated manpages should work

parent e35d4dae
Branches
Étiquettes
1 requête de fusion!105Refactor and more
......@@ -137,6 +137,7 @@ AC_OUTPUT([
Makefile
inc/Makefile
src/Makefile
man/Makefile
])
################
......
.TH "___PAGE___" "1" "___DATE___" "LEKTOR MK 7"
notrans_dist_man1_MANS = lektor.man lektord.man lkt.man
MAN = $(abs_top_srcdir)/scripts/manpager.sh
.template.man:
$(MAN) $<
Fichier déplacé
Fichier déplacé
Fichier déplacé
Fichier déplacé
#!/bin/sh
#!/bin/bash
#########################################################
######################################
# Generate manpages from a directory #
# $0 input_folder output_folder header_file footer_file #
#########################################################
# $0 file footer_file #
######################################
function die ()
{
......@@ -11,56 +11,33 @@ function die ()
exit 1
}
[ $# -ne 4 ] && die "Invalid number of arguments, arguments were '$@'"
[ $# -ne 1 ] && die "Invalid number of arguments, arguments were '$@'"
####################
# Global variables #
####################
HEADER="$3" # Header file
FOOTER="$4" # Footer file
FOLDER_INPUT="$(readlink -f $1)" # Where to find template .1 files
FOLDER_OUTPUT="$(readlink -f $2)" # Where to put the generated files
[ "$FOLDER_INPUT" = "$FOLDER_OUTPUT" ] && die "output folder can't be the same as input folder"
FOOTER="./footer" # Footer file
INPUT="$1" # Where to find template .man files
OUTPUT="${INPUT/template/man}" # Where to put the generated files
#########################
# Functions and aliases #
#########################
function the_day ()
{
sed -i "s/___DATE___/$(date +'%B %d, %Y')/g" "$1"
}
function the_page ()
{
local FILE=$(basename "$1")
local FILE="${FILE%.*}"
local FILE="${FILE^^}"
sed -i "s/___PAGE___/$FILE/g" "$1"
}
function mk_manpage ()
{
# $1: input
# $2: output
cat $HEADER > $2
cat $1 >> $2
cat $FOOTER >> $2
the_day "$2"
the_page "$2"
sed -i "s/___DATE___/$(date +'%B %d, %Y')/g" "$2"
return $?
}
############
# The main #
############
for FILE in $(ls "$FOLDER_INPUT/*.1") ; do
FILE=$(basename "$FILE")
INPUT="$FOLDER_INPUT/$FILE"
OUTPUT="$FOLDER_OUTPUT/$FILE"
mk_manpage "$INPUT" "$OUTPUT"
done
exit 0
mk_manpage $INPUT $OUTPUT
exit $?
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter