From: <lyn...@us...> - 2009-08-01 15:14:20
|
Revision: 6780 http://gemrb.svn.sourceforge.net/gemrb/?rev=6780&view=rev Author: lynxlupodian Date: 2009-08-01 15:13:51 +0000 (Sat, 01 Aug 2009) Log Message: ----------- added guidoc_wikifier.sh, a script which was used for the wikification of the guiscript docs; this is an improved version (the wiki will be updated later) Added Paths: ----------- gemrb/trunk/admin/guidoc_wikifier.sh Added: gemrb/trunk/admin/guidoc_wikifier.sh =================================================================== --- gemrb/trunk/admin/guidoc_wikifier.sh (rev 0) +++ gemrb/trunk/admin/guidoc_wikifier.sh 2009-08-01 15:13:51 UTC (rev 6780) @@ -0,0 +1,80 @@ +#!/bin/bash +docdir="${1:-$PWD/gemrb/docs/en/GUIScript}" +out_dir="${2:-$PWD/guiscript-docs.wikified}" +scriptdir="${3:-$docdir/../../../GUIScripts}" +index_title="GUIScript function listing" +see_also_str="See also:" + +mkdir -p "$out_dir" +rm -f "$out_dir"/*.txt +test -d "$docdir" || exit 1 + +# intertwine the doc pages based on the "See also" entries +echo Linking ... +for txt_file in "$docdir"/*.txt; do + cp "$txt_file" "$out_dir/$(basename $txt_file)" || exit 2 + # get the linked pages (all are in one line) + links=$(grep -m1 "$see_also_str" "$txt_file") + if [[ -n $links ]]; then + # we have some links and first we strip off the "See also:" + links=${links##*:} + for link in $links; do + # when there's multiple links, we have to deal with the commas + if [[ ! -f $docdir/${link//,/}.txt ]]; then + echo "Dangling link in $(basename $txt_file): ${link//,/}" + continue + fi + if [[ ${link##*,} == "" ]]; then + # has comma, which we strip and readd, so it doesn't affect the link + sed_cmd="/$see_also_str/ s@$link@[[guiscript:${link//,/}]],@g" + else + sed_cmd="/$see_also_str/ s@$link\>@[[guiscript:$link]]@g" + fi + sed -i "$sed_cmd" "$out_dir/$(basename $txt_file)" + done + fi +done + +echo Formatting ... +cd "$out_dir" +echo > indexX +# add some formatting to the doc pages +for txt_file in *; do + # extra newlines + #sed -i "s,$,\n," $txt_file + + # format the title + if grep -qR --include="*.py" "GemRB\.${txt_file%.*}" "$scriptdir"; then + # actual script command + sed -i "1 s,^,===== ${txt_file%.*} =====," $txt_file + if [[ ${txt_file%.*} == controls ]]; then echo juhu0; fi +else + # miscellaneous doc + if [[ ${txt_file%.*} != indexX ]]; then + if [[ ${txt_file//_/} == $txt_file ]]; then + sed -i "1 s,^,===== ${txt_file%.*} =====\n," $txt_file + else + # misc doc with multiword title + sed -i "1 s,^\([^.]*\)\.*\s*$,===== \1 =====," $txt_file + fi + fi + fi + + # bold the headlines, itemize the parameters and add some links +# sed -i "s,Description:\|Return value:\|Prototype:\|Parameters:\|$see_also_str\|MD5:\|Examples*:,\n**&**," $txt_file + sed -i "s@^[^:]\{,15\}:@\n**&**@" $txt_file + sed -i "$ s,$,\n\n[[guiscript:index|Function index]]," $txt_file + sed -i "/Parameters:/,/^[^:]*:\*\*/ { /^[^:]*:\*\*/!s,^\(\s*\S\S*\), * \1,}" $txt_file + sed -i '/^\s*$/ {N; /\n\s*$/D }' $txt_file # squeeze repeats of more than 2 newlines + sed -i "1 s,$,\n * [[guiscript:${txt_file%.*}]]," indexX + + [[ ${txt_file%.*} == indexX ]] && continue + lo_file=$(tr '[[:upper:]]' '[[:lower:]]' <<< $txt_file) + if [[ $lo_file != $txt_file ]]; then + mv $txt_file $lo_file + fi +done +sort -o index.txt indexX +rm indexX +sed -i -e '/guiscript:index/d; /indexX/d' -e "1 s,^,===== $index_title =====\n," index.txt +echo Done. Property changes on: gemrb/trunk/admin/guidoc_wikifier.sh ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |