File: guidoc_wikifier.sh

package info (click to toggle)
gemrb 0.9.4%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 21,960 kB
  • sloc: cpp: 140,145; python: 30,926; ansic: 4,405; objc: 731; sh: 311; java: 105; xml: 69; makefile: 7
file content (52 lines) | stat: -rwxr-xr-x 1,833 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
51
52
#!/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.
#
#
# this script takes the guiscript docs and prepares them to shine as markdown

out_dir="${1:-$PWD/guiscript-docs.wikified}"
plugincpp="${2:-gemrb/plugins/GUIScript/GUIScript.cpp}"

mkdir -p "$out_dir"
rm -f "$out_dir"/*.md

function dumpDocs() {
  # extract the functions docs from the doc strings into individual files
  sed -n '/PyDoc_STRVAR/,/PyObject/ { /"=/,/"$/ { s,\\n,,; s,\\,,; p} }' "$plugincpp" |
    awk -v RS='"' -v out="$out_dir" \
    '{ split($0, t)
       title=t[2]
       if (title) {
         filename = out "/" title ".md"
         module = index(title, "_") ? "_GemRB" : "GemRB"
         # remove old title
         sub("^=====.*=====.", "")

         # dump frontmatter and contents
         print "---" > filename
         print "title: " title >> filename
         print "module: " module >> filename
         print "---" >> filename
         print $0 >> filename
       }
     }' || return 1

  echo "Done, now manually copy the contents of $out_dir to the website repo, review, commit and push."
}

dumpDocs