File: listkeys

package info (click to toggle)
texlive-extra 2014.20141024-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,016,484 kB
  • ctags: 21,582
  • sloc: perl: 140,144; python: 16,926; makefile: 12,969; sh: 9,285; ansic: 3,415; java: 3,090; csh: 2,987; xml: 1,050; lisp: 630; ruby: 487; lex: 358; tcl: 142; sed: 36; pascal: 25; cpp: 18; awk: 10; haskell: 5
file content (50 lines) | stat: -rwxr-xr-x 1,678 bytes parent folder | download
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
#!/bin/bash
#shopt -s extglob

# after the addition of new options, two regions of the documentation in
# isodoc.dtx need to be updated:
# 1. the body of the definition of \showkeys
#    listkeys will print that body with the argument `show'
# 2. The body of the tabular (in the section `Commands'), which shows
#    the options having a corresponding command.
#    listkeys will print that body with the argument `defs'
#    
# An easy way to replace the data in isodoc.dtx is, using the vim editor: 
# 1. select the lines (the contents of \def\showkeys, say) with V and then
# 2. type :!listkeys show 


usage() { echo "Usage: listkeys defs|show"; exit; }
[[ -z $1 ]] && usage

type=$1
[[ $type =~ ^(defs|show)$ ]] || usage

minipage='^(acceptdesc|copyto|enclosures|logoaddres|signature|returnaddress)$'
undef='^(accountname|accountno|bic|iban|routingno|vatno)$'
# find keys which have a corresponding command:
a=($(
   while read -r x; do
     [[ $x =~ define@key ]] || continue
     # \define@key{isodoc}{closing}     {\def\closing{#1}}
     re='\\define@key\{isodoc\}\{([[:alpha:]]+)\}.*\\def\\\1\{'
     #                            ----word----            ^^-same word  
     [[ $x =~ $re ]] || continue
     echo ${BASH_REMATCH[1]}
   done<isodoc.dtx |sort
))

if [[ $type == defs ]]; then
   for i in ${a[@]}; do 
      if [[ $i =~ $minipage ]]; then
         printf "%20s & \\%s\\NN\n" $i "@isodocmp{$i}"
      elif [[ $i =~ $undef ]]; then
         printf "%20s & \\%s\\NN\n" $i "@isodocun{$i}"
      else
         printf "%20s & \\%s\\NN\n" $i $i
      fi
   done
else
   for i in ${a[@]}; do echo $i; done |
	cols -5 --squeeze --sep=' & ' --suf='\NN' --pre='% '
fi