#!/bin/bash # file manuals_for_web.sh # This file is part of LyX, the document processor. # Licence details can be found in the file COPYING. # # \author Tommaso Cucinotta # \author Pavel Sanda # # Full author contact details are available in file CREDITS # Usage: # manuals_for_web.sh (just launch from the LyX git root folder) # # optional env vars that customize behavior: # $LYX - abs path to LyX executable # $OUT - final folder where all converted manuals are placed # $TOC - final index.html that links all converted manuals # $TMP - temporary folder where all the conversion is done #MAIN_DOCS=${MAIN_DOCS:-"Intro Tutorial UserGuide Math Additional Customization Shortcuts LFUNs"} MAIN_DOCS=${MAIN_DOCS:-"Math"} LYX=${LYX:-${PWD}/src/lyx} OUT=${OUT:-$HOME/web/lyxdoc} TOC=${TOC:-lyxdoc/index.html} TMP=${TMP:-$(mktemp -d)} echo LYX=$LYX echo OUT=$OUT echo TOC=$TOC echo TMP=$TMP mycpus=$(grep -c processor /proc/cpuinfo) function pexec { while [ $(pidof lyx | wc -w) -ge $[$mycpus*15/10] -o $(pidof lyx | wc -w) -ge $[$mycpus*15/10] ]; do sleep $(echo "$RANDOM * 5 / 32767" | bc -l) done echo -e "\e[39mRunning $@ ..." eval "$@ > /dev/null 2>&1 && echo -e ... \\\\e[32mDONE\\\\e[39m with $@ || echo -e ... \\\\e[31mERROR\\\\e[39m on $@" & } if [ ! -d lib/doc -o ! -f lib/doc/Intro.lyx ]; then echo "Run me from the LyX top dir" exit 1 fi if [ ! -f $LYX ]; then echo "Cannot find the LyX executable at: $LYX" exit 1 fi mkdir -p $TMP/lyxdoc cp -a lib/doc/* $TMP cd $TMP echo "" echo "Manuals being processed in $TMP" echo "Index of built manuals available at: file://$TMP/$TOC" echo "" cat > $TOC <

LyX manuals

EOF for m in $MAIN_DOCS; do echo "" >> $TOC done echo "
ManualBrowse Link(s)PDF Download(s)
$m" >> $TOC find . -name $m.lyx | while read f; do if [ ! -f lyxdoc/${f%%.lyx}.html.LyXconv/$m.html ]; then pexec $LYX -E xhtml lyxdoc/${f%%.lyx}.html $f; else echo "Skipping already existing lyxdoc/${f%%.lyx}.html" fi if echo $f | grep '/[a-zA-Z_]\+/' > /dev/null 2>&1; then lang=$(echo $f | sed -e 's#.*/\([a-zA-Z_]\+\)/.*#\1#') else lang=en fi echo "[$lang]" >> $TOC done echo "" >> $TOC find . -name $m.lyx | while read f; do if [ ! -f lyxdoc/${f%%.lyx}.pdf ]; then pexec $LYX -E pdf lyxdoc/${f%%.lyx}.pdf $f; else echo "Skipping already existing lyxdoc/${f%%.lyx}.pdf" fi if echo $f | grep '/[a-zA-Z_]\+/' > /dev/null 2>&1; then lang=$(echo $f | sed -e 's#.*/\([a-zA-Z_]\+\)/.*#\1#') else lang=en fi echo "[$lang]" >> $TOC done echo "
" >> $TOC echo "Waiting for child processes to complete..." wait echo "" echo "Manuals processed in $TMP" echo "Index of built manuals available at: file://$TMP/$TOC" echo ""