#!/bin/bash if [ -n "$debug" ] ; then set -x fi SRCDIR="$1" BASE_OUTPUT="$2" pushd "$SRCDIR" > /dev/null function header { local title="$1" local breadcrumb="$2" local output="$3" cat - > $output < $title
EOF } function footer { local output="$1" cat - >> $output < EOF } function proc_text { # Local links: [[...]] # Git links: [git:...] # Other remote links: [...] # Headings: == bleh == # Paragraphs: \n\n sed -re ' s/\[\[([-_a-zA-Z0-9]+)\]\]/\1<\/a>/g' - \ | sed -re ' s/\[git:([^]]+)\]/\1<\/a>/g' \ | sed -re ' s/\[([^]]+)\]/\1<\/a>/g' \ | sed -re ' s/====([^=]+)====/

\1<\/h4>/g' \ | sed -re ' s/===([^=]+)===/

\1<\/h3>/g' \ | sed -re ' s/==([^=]+)==/

\1<\/h2>/g' \ | sed -re ':a;N;$!ba;s/\n\n/<\/p>

/g' \ | awk 'BEGIN { print "

" } { print } END { print "

" }' } # generate entry page echo "generating index page" header "LibreOffice Modules" " " "$BASE_OUTPUT/index.html" for module_name in *; do if [ -d $module_name ]; then if [ -f $module_name/readme.txt ] ; then cur_file="$module_name/readme.txt" elif [ -f $module_name/README ] ; then cur_file="$module_name/README" fi if [ -n "$cur_file" ]; then # write index.html entry text="

${module_name}

\n" text="${text}$(head -n1 $cur_file | proc_text )" echo -e $text >> "$BASE_OUTPUT/index.html" # write detailed module content header "$module_name" "LibreOffice » ${module_name}" "$BASE_OUTPUT/${module_name}.html" text="

View module in:" text="${text}   cgit" if [ -d ./docs/${module_name} ] ; then text="${text}   Doxygen" fi text="${text}

 

" echo -e $text >> "$BASE_OUTPUT/${module_name}.html" proc_text < $cur_file >> "$BASE_OUTPUT/${module_name}.html" footer "$BASE_OUTPUT/${module_name}.html" else empty_modules[${#empty_modules[*]}]=$module_name fi fi done if [ ${#empty_modules[*]} -gt 0 ]; then echo -e "

 

READMEs were not available for these modules:

    \n" >> "$BASE_OUTPUT/index.html" for module_name in "${empty_modules[@]}"; do echo -e "
  • ${module_name}
  • \n" >> "$BASE_OUTPUT/index.html" done echo -e "
\n" >> "$BASE_OUTPUT/index.html" fi footer "$BASE_OUTPUT/index.html" popd > /dev/null ## done