libk  Diff

Differences From Artifact [fbe8d4ad27]:

To Artifact [b795aa8a1c]:


     1      1   #!/usr/bin/env sh
     2      2   (test -d global && test -f build.sh) || {
     3      3   	echo >&2 "($0) run $me from root of libk source directory"
     4      4   	exit 1
     5      5   }
     6      6   
     7      7   . global/common.sh
     8         -test "$out" = "" && {
     9         -	say "\$out environment variable must be set to your build directory - are you running this script by hand? run make doc in the root directory instead!"
    10         -	exit 2
    11         -}
    12         -
    13         -if ! has cmark; then
    14         -	say "to generate documentation for libk, install the cmark package and try again"
    15         -	exit 3
    16         -fi
            8  +reqpack cmark "generate documentation"
    17      9   
    18     10   
    19     11   file="$1"
    20     12   filename="$(basename "$file")"
    21     13   stem=${filename%%.md}
    22     14   mandest="$out/doc/man"
    23     15   section=${section:-4}
    24     16   out="$mandest/$stem.$section"
    25         -desc_rec="$(grep -m1 "^$name:" global/modules)"
    26         -if test $? -eq 0; then
           17  +desc_rec="$(grep -m1 "^$stem:" global/modules)"
           18  +if test "$desc_rec" != ""; then
    27     19   	desc=" - $(echo $desc_rec | cut -d: -f4)"
    28     20   else
    29     21   	desc=""
    30     22   fi
    31     23   date="$(date -r"$file" "+%d %A %Y")"
    32     24   
    33     25   mkdir -p "$mandest"
    34     26   
    35         -echo  >"$out" ".TH ${name^^} \"$section\" \"$date\" \"hale.su libk [r$build]\" \"modules\""
           27  +echo  >"$out" ".TH ${stem^^} \"$section\" \"$date\" \"hale.su libk [r$build]\" \"modules\""
    36     28   
    37     29   echo >>"$out" ".SH NAME"
    38     30   echo >>"$out" "$stem$desc"
    39     31   echo >>"$out" ".SH SYNOPSIS" 
    40     32   
    41     33   dhead=$(grep -m1 -n "^# description$" "$file")
    42     34   if test $? -eq 0; then