File: add_missing_gui_docs.sh

package info (click to toggle)
gemrb 0.8.5-1
  • links: PTS, VCS
  • area: contrib
  • in suites: buster
  • size: 32,476 kB
  • sloc: cpp: 125,206; python: 31,280; ansic: 2,012; objc: 756; sh: 568; makefile: 467; perl: 178; java: 105
file content (67 lines) | stat: -rw-r--r-- 2,390 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
# GemRB - Infinity Engine Emulator
# Copyright (C) 2009 The GemRB Project
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
#

if [[ ! -d admin ]]; then
  echo 'Run me from the top gemrb dir that contains the admin subdir!'
  exit 1
fi
docdir=gemrb/docs/en/GUIScript

cd admin
methods=$(./check_gui_doc.pl | grep ^+)
cd -

#+ SwapPCs : $md5_hash : SwapPCs(idx1, idx2)\n\n : Swaps the party order
#$1 $2    $3    $4    $5          $6                         $7
while read line; do
  set -- $line
  method=$2
  shift 5
  tmp="$@"

  prototype=$(cut -d: -f1 <<< "$tmp" | sed 's,nn\s*$,,')
  description=$(cut -d: -f2- <<< "$tmp")

  echo Adding $method stub with: $description
  cp $docdir/doc_template.txt $docdir/$method.txt

  return_value=$(awk '{ if(split($0,a,"=>")) print a[2]; }' <<< "$prototype")
  if [[ -n $return_value ]]; then
    # we also have the return "value", so remove it from the prototype
    prototype=$(awk '{ if(split($0,a,"=>")) print a[1]; }' <<< "$prototype")
    sed -i "s@^Return value:@& ${return_value# }@" $docdir/$method.txt
  fi
  sed -i "s@^Prototype:@& GemRB.${prototype% }@" $docdir/$method.txt
  sed -i "s@^Description:@& $description@" $docdir/$method.txt

  # get the parameters
  # eg: WindowIndex ControlID x y w h direction[ font]
  unset parameters
  for parameter in $(sed -n 's@^[^(]*(\([^)]*\)).*$@\1@p' <<< "$prototype"); do
    parameter=$(tr -d ',' <<< "$parameter")
    if [[ ${parameter:${#parameter}-1:1} == "]" ]]; then
      # optional parameter
      parameters="$parameters\n${parameter//]/} - (optional) "
    else
      parameters="$parameters\n${parameter//[/} - "
    fi
  done
  sed -i "s@^Parameters:@& $parameters@" $docdir/$method.txt
done <<< "$methods"