01-generate-man.sh (2199B)
1 #!/bin/sh 2 3 # Copyright (C) 2017-2025 |Méso|Star> (contact@meso-star.com) 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 set -e 19 20 . "./config.sh.in" 21 22 ######################################################################## 23 # Helper function 24 ######################################################################## 25 man_pages() 26 { 27 find "${directory}/share/man" -name "schiff*.[15]" 28 } 29 30 # Man to convert is submitted on stdin 31 man2html() # output_filename 32 { 33 { 34 cd .. 35 sty-genhead "${OLDPWD##*/}/$1" 36 sh ./scripts/convert_man.sh 37 cat ./templates/footer.html 38 cd "${OLDPWD}" 39 } > "$1" 40 } 41 42 ######################################################################## 43 # The script 44 ######################################################################## 45 man_pages | while read -r i; do 46 filename="$(basename "${i}")" 47 section="${filename##*.}" 48 49 if ! [ -d "./man/man${section}" ]; then 50 mkdir -p "./man/man${section}"; 51 fi 52 53 dst="man/man${section}/${filename}.html" 54 man2html "${dst}" < "${i}" 55 56 # Check the result of the HTML conversion. Do this operation from the 57 # parent directory so that tidy displays the file name relative to the 58 # location where the make command is invoked. This makes the message 59 # clearer for the user. 60 cd .. 61 if ! tidy --show-info no --show-filename yes -qe "${OLDPWD##*/}/${dst}"; then 62 >&2 printf '%s: error converting %s\n' "${0##*/}" "${i}" 63 exit 1 64 fi 65 cd "${OLDPWD}" 66 67 # Write the generated files to standard output to inform the build 68 # system which files it needs to handle during installation. 69 printf '%s/%s\n' "${PWD##*/}" "${dst}" 70 done