#!/usr/bin/env bash # Title : build-doc.sh # Description : WSJT-X Documentation build script # Author : KI7MT # Email : ki7mt@yahoo.com # Date : FEB-02-2014 # Version : 0.5 # Usage : ./build-doc.sh [ option ] # Notes : requires asciidoc, source-highlight #============================================================================== # exit on error set -e #add some color red='\033[01;31m' green='\033[01;32m' yellow='\033[01;33m' cyan='\033[01;36m' no_col='\033[01;37m' # misc var's base_dir=$(pwd) src_dir="$base_dir/source" c_asciidoc="asciidoc -b xhtml11 -a max-width=1024px" script_name=$(basename $0) doc_version="1.3" # declare build array's declare -a no_toc_ary=('head_wording' 'build_no_toc') declare -a top_toc_ary=('head_wording' 'build_toc1') declare -a left_toc_ary=('head_wording' 'build_toc2') declare -a all_docs_ary=('head_wording' 'build_no_toc' 'build_toc1' 'build_toc2' \ 'build_quick_ref' 'build_dev_guide') declare -a web_package_ary=('package_wording' 'build_toc2') ####################### # clean-exit ####################### function clean_exit() { clear echo -e ${yellow}'Signal caught, cleaning up and exiting.'${no_col} sleep 1 [ -d "$base_dir/tmp" ] && rm -r $base_dir/tmp echo -e ${yellow}'. Done'${no_col} exit 0 } # Trap Ctrl+C, Ctrl+Z and quit signals trap clean_exit SIGINT SIGQUIT SIGTSTP ####################### # general functions ####################### # build with no table of contents function build_no_toc() { # no toc echo -e ${yellow}'Building Main With No TOC'${no_col} $c_asciidoc -o wsjtx-main.html $src_dir/wsjtx-main.adoc echo -e ${green}'.. wsjtx-main.html'${no_col} } # build with top table of contents function build_toc1() { echo -e ${yellow}'Building Main with Top TOC'${no_col} $c_asciidoc -a toc -o wsjtx-main-toc1.html $src_dir/wsjtx-main.adoc echo -e ${green}'.. wsjtx-main-toc1.html'${no_col} } # build with left table of contents function build_toc2() { echo -e ${yellow}'Building Main with Left TOC'${no_col} $c_asciidoc -a toc2 -o wsjtx-main-toc2.html $src_dir/wsjtx-main.adoc echo -e ${green}'.. wsjtx-main-toc2.html'${no_col} } # end left toc # build all table of content versions function build_support_pages() { echo echo -e ${yellow}'Building Rig Pages'${no_col} $c_asciidoc -o rig-config-main.html $src_dir/rig-config-main.adoc echo -e ${green}'.. rig-config-main.html'${no_col} # setup rig file array declare -a rig_page_ary=('adat' 'alinco' 'aor' 'drake' 'elecraft' 'flexrad' 'icom' \ 'kenwood' 'softrock' 'tentec' 'yaesu') } # end all toc version # build quick-reference guide function build_quick_ref() { echo -e ${yellow}'Building Quick Reference Guide'${no_col} $c_asciidoc -a toc2 -o quick-reference.html $src_dir/quick-reference.adoc echo -e ${green}'.. quick-reference.html'${no_col} } # end quick-ref # build dev-guide function build_dev_guide() { echo -e ${yellow}'Building Development Guide'${no_col} $c_asciidoc -a toc2 -o dev-guide.html $src_dir/dev-guide.adoc echo -e ${green}'.. dev-guide.html'${no_col} } # end dev-guide function head_wording() { clear echo -e ${yellow}"Building WSJT-X Documentation "${cyan}'v'$doc_version"\n" ${no_col} } function quick_ref_wording() { clear echo -e ${yellow}"Building Quick Reference Documentation\n"${no_col} } function dev_guide_wording() { clear echo -e ${yellow}"Building Quick Reference Documentation\n"${no_col} } function package_wording() { clear echo -e ${yellow}"Building Transfer Package\n"${no_col} } # help menu options function help_menu() { clear echo -e ${green}"BUILD SCRIPT HELP MENU\n"${no_col} echo 'USAGE: build-doc.sh [ option ]' echo echo 'OPTIONS: toc1 toc2 all dev-guide quick-ref help web' echo echo -e ${yellow}'WSJT-X User Guide Options:'${no_col} echo ' [1] No Table of Contents' echo ' [2] Top Table of Contents ' echo ' [3] Left Table of Contents' echo ' [4] All Guide Versions' echo -e ${yellow}"\nSingle Guide Builds"${no_col} echo ' [5] Development Guide' echo ' [6] Quick Reference Guide' echo ' [0] Exit' echo } # WSJT-X User Guide transfer for Joe function build_index_html(){ # create re-direct index.html cat << EOF > ./index.html