#!/bin/bash -p ############################################################################### # BRLTTY - A background process providing access to the console screen (when in # text mode) for a blind person using a refreshable braille display. # # Copyright (C) 1995-2018 by The BRLTTY Developers. # # BRLTTY comes with ABSOLUTELY NO WARRANTY. # # This is free software, placed under the terms of the # GNU Lesser General Public License, as published by the Free Software # Foundation; either version 2.1 of the License, or (at your option) any # later version. Please see the file LICENSE-LGPL for details. # # Web Page: http://brltty.com/ # # This software is maintained by Dave Mielke . ############################################################################### defaultOutputRoot="doc-ktb" . "`dirname "${0}"`/prologue.sh" addProgramOption s string.directory sourceRoot "top-level directory of source tree" "the location of this script" addProgramOption b string.directory buildRoot "top-level directory of build tree" "the source tree" addProgramOption o string.directory outputRoot "top-level directory of output tree" "${defaultOutputRoot}" addProgramOption k flag keepFiles "don't remove intermediate files" parseProgramArguments "${@}" set -e umask 022 shopt -s nullglob [ -n "${sourceRoot}" ] || sourceRoot="$(dirname "${0}")" verifyInputDirectory "${sourceRoot}" sourceRoot="$(cd "${sourceRoot}" && pwd)" [ -n "${buildRoot}" ] || buildRoot="${sourceRoot}" buildRoot="$(cd "${buildRoot}" && pwd)" [ -n "${outputRoot}" ] || outputRoot="${defaultOutputRoot}" verifyOutputDirectory "${outputRoot}" unset HOME export XDG_CONFIG_HOME=/ export XDG_CONFIG_DIRS=/ readonly newLine=$'\n' declare -a tocLines addTocLine() { local line="${1}" tocLines[${#tocLines[*]}]="${line}" } addTocEntry() { local title="${1}" local anchor="${2}" addTocLine "
  • ${title}
  • " } declare -a documentLines addLine() { local line="${1}" documentLines[${#documentLines[*]}]="${line}" } addAnchor() { local anchor="${1}" addLine "" } beginDocument() { local title="${1}" headerLevel=0 addLine "" addLine "" addLine "${title}" addLine "" addLine "" } endDocument() { local file="${1}" addLine "" addLine "" addTocLine "
    " local docCount="${#documentLines[*]}" local docIndex=0 local tocCount="${#tocLines[*]}" local tocIndex=0 exec 3>"${file}" while ((docIndex < tocStart)) do echo >&3 "${documentLines[docIndex++]}" done while ((tocIndex < tocCount)) do echo >&3 "${tocLines[tocIndex++]}" done while ((docIndex < docCount)) do echo >&3 "${documentLines[docIndex++]}" done exec 3>&- } beginSection() { local title="${1}" local anchor="${title,,?}" anchor="${anchor//[^a-zA-Z_0-9]/-}" addAnchor "${anchor}" headerLevel=$((headerLevel + 1)) addLine "${title}" if ((headerLevel == 1)) then tocStart="${#documentLines[*]}" addTocLine "" headerLevel=$((headerLevel - 1)) } beginLayoutList() { layoutListed=false } endLayoutList() { ! "${layoutListed}" || { addLine "" } } beginLayoutEntry() { local prefix="${1}" local outputExtension="${2}" local layout="${inputFile##*/}" layout="${layout%.*}" outputFile="${outputRoot}/${prefix}-${layout}.${outputExtension}" } endLayoutEntry() { local category="${1}" exec 4<"${outputFile%.*}.${plainTextExtension}" local description read -r -u 4 description exec 4<&- description="${description} " description="${description#*: }" [ -z "${category}" ] || description="${description#${category} }" description="${description% }" local prefix="All Models" [ -z "${description}" ] || { if [ "${description}" = "${description#(}" ] then prefix="" else prefix="${prefix} " fi } description="${prefix}${description}" "${layoutListed}" || { layoutListed=true addLine "