File: create_README.source

package info (click to toggle)
dh-r 20210303
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 224 kB
  • sloc: perl: 1,935; sh: 393; makefile: 21
file content (81 lines) | stat: -rwxr-xr-x 2,585 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
# You can call this script from inside your debian/ dir and redirect
# the output to README.Debian.
#
# This script helps to create README.source for R packages
# featuring large amounts of binary data files

cat <<EOT
Explanation for binary files inside source package according to
  https://lists.debian.org/debian-devel/2013/09/msg00332.html

EOT

GuessDocName () {
  if [ -e $1.Rd ] ; then
    echo $1.Rd
  else
    rdoc=`echo $1 | sed 's/\.[RDArdat]\+$/.Rd/'`
    if [ -e $rdoc ] ; then
      echo $rdoc
    else
      if [ -e "${rdoc}.rd"  ] ; then
        echo ${rdoc}.rd
      else
        find ../man -iname $(basename $1).rd
      fi
    fi
  fi
}

for rda in `find .. -iname "*.rda" -o -iname "*.rdata" | sort` ; do
  if echo $rda | grep -q -e "^\.\./data" -e "^\.\./.*/extdata" ; then
    rdoc=`GuessDocName "../man/$(basename $rda .rda)"`
    if [ ! -e "$rdoc"  ] ; then
      # try lower case doc name if nothing else was found
      rdoc=`GuessDocName "../man/"$(basename $rda .rda | tr 'A-Z' 'a-z')`
    fi
    if [ ! -e "$rdoc"  ] ; then
      # Pick a doc file that is featuring the full name of the binary
      rdanoext=`basename $rda .rda | sed 's/\.RData$//'`
      rdoc=`grep -l -w $rdanoext ../man/* | head -n1`
    fi
    rdaname=$(echo $rda | sed 's#^\.\./##')
    if [ ! -e "$rdoc"  ] ; then
      >&2 echo "Verify documentation for $rda manually"
    else
        echo "Files: $rdaname"
        echo $rdoc | sed 's#^\.\./#Documented: #'
        TITLE=$(grep '\\title' $rdoc | sed -e 's/^\\title{/  /' -e 's/ *} *$//')
        DESCRIPTION=$(grep -A 3 '\\description' $rdoc  | sed -e 's/^\\description{/  /' -e 's/ *} *$//' -e '/}/,$d' -e '/^[[:space:]]*$/d' -e 's/^ \+//')
        if ! echo $TITLE | grep -q ' ' ; then
            if [ "$DESCRIPTION" != "" ] ; then
                TITLE=$DESCRIPTION
            fi
        fi
        if echo $TITLE | grep -q '^[[:space:]]*$' ; then
            sed -e '0,/^\\title{/d' -e '/^}/,$d' -e 's/^\\description{//' -e 's/^\([^ ]\)/  \1/' $rdoc
        else
            echo $TITLE | sed -e 's/}[[:space:]]*$//' -e 's/^ */  /'
        fi
        echo ""
    fi
  else
    echo $rda | sed 's#^\.\./#Files: #'
    if echo $rda | grep -q "^\.\./tests" ; then
      echo "Documentation: Test data for comparison in unit test"
    else
      if echo $rda | grep -q "sysdata.rda" ; then
        echo "Documentation: dump of system data of R run."
      else
        echo "FIXME: Needs documentation"
      fi
    fi
    echo ""
  fi
done

cat <<EOT
 -- `echo ${DEBFULLNAME}` <`echo ${DEBEMAIL}`>  `date -R`
EOT