[GRASS-SVN] r39088 - grass/branches/develbranch_6/tools
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 9 00:08:22 EDT 2009
Author: hamish
Date: 2009-09-09 00:08:22 -0400 (Wed, 09 Sep 2009)
New Revision: 39088
Modified:
grass/branches/develbranch_6/tools/module_synopsis.sh
Log:
merge menu position finding code from trunk, add it as pretty HTML and TeX
Modified: grass/branches/develbranch_6/tools/module_synopsis.sh
===================================================================
--- grass/branches/develbranch_6/tools/module_synopsis.sh 2009-09-08 22:38:51 UTC (rev 39087)
+++ grass/branches/develbranch_6/tools/module_synopsis.sh 2009-09-09 04:08:22 UTC (rev 39088)
@@ -14,6 +14,8 @@
#############################################################################
#
# PDF output requires the Palatino font.
+# Run this script from the tools/ directory in the souce code.
+# (TeX needs to be able to find grasslogo_vector.pdf)
#
if [ -z "$GISBASE" ] ; then
@@ -58,36 +60,23 @@
XML_MENU="$GISBASE/etc/wxpython/xml/menudata.xml"
+# generate menu hierarchy
+MDPY="$GISBASE/etc/wxpython/gui_modules/menudata.py"
+# python menudata.py commands
+# python menudata.py tree
+# python menudata.py strings
+python "$MDPY" commands | sed -e 's/ | /|/' -e 's/[ -].*|/|/' \
+ | sort -u > "$TMP.menu_hierarchy"
+
+
+
# work in progress -- still rather buggy.
find_menu_hierarchy()
{
-unset MODULE_COUNT MODULE_LABEL MODULE_MENU1 MODULE_MENU2
+ MODL=$1
+ PLACEMENT=`grep "^$MODL|" "$TMP.menu_hierarchy" | cut -f2 -d'|'`
-MODULE_COUNT=`grep -c -w "$MODULE" "$XML_MENU"`
-
-if [ "$MODULE_COUNT" -ge 1 ] ; then
- MODULE_LABEL=`xml2 < "$XML_MENU" | grep -w -B5 "$MODULE" | \
- grep 'label=' | cut -f2 -d= | tr '\n' '>' | \
- sed -e 's/>$//' -e 's/[^ ]>/ > /'`
-
- MODULE_MENU1=`xml2 < "$XML_MENU" | grep -w -B5000 "$MODULE" | \
- sed -e 's+^/menudata/menubar/menu/++' | tac | \
- grep '/label=\|^label=' | grep -B1000 '^label=' -m 1 | \
- grep -v menuitem | tail -n 1 | cut -f2 -d=`
-
- MODULE_MENU2=`xml2 < "$XML_MENU" | grep -w -B5000 "$MODULE" | \
- sed -e 's+^/menudata/menubar/menu/++' | tac | \
- grep '/label=\|^label=' | grep -B1000 '^label=' -m 1 | \
- grep -v menuitem | head -n 1 | cut -f2 -d= | tr '\n' ' ' | \
- sed -e 's/ $//'`
-
- if [ "$MODULE_COUNT" -eq 1 ] ; then
- echo "$MODULE|$MODULE_MENU1 > $MODULE_MENU2 > $MODULE_LABEL"
- else
- # "*" indicates module appears more than once
- echo "$MODULE*|$MODULE_MENU1 > $MODULE_MENU2 > $MODULE_LABEL"
- fi
-fi
+ echo "$PLACEMENT"
}
for DIR in bin scripts ; do
@@ -104,18 +93,29 @@
;;
esac
-# find_menu_hierarchy
+ eval `$MODULE --tcltk | head -n 3 | tail -n 2 | tr '"' "'" | \
+ sed -e 's/^ //' -e 's/ {/="/' -e 's/}$/"/' -e 's/[^\."]"$/&./'`
- eval `$MODULE --tcltk | head -n 3 | tail -n 2 | tr '"' "'" | \
- sed -e 's/^ //' -e 's/ {/="/' -e 's/}$/"/'`
if [ -z "$label" ] && [ -z "$desc" ] ; then
continue
fi
+
+ MODULE_MENU_LOC=`find_menu_hierarchy "$MODULE"`
+
+ BUFF=""
if [ -z "$label" ] ; then
- echo "$MODULE: $desc" >> "$TMP"
+ BUFF="$MODULE: $desc"
else
- echo "$MODULE: $label" >> "$TMP"
+ BUFF="$MODULE: $label"
fi
+ if [ -n "$MODULE_MENU_LOC" ] ; then
+ BUFF="$BUFF {$MODULE_MENU_LOC}"
+ fi
+ if [ -n "$BUFF" ] ; then
+ #echo "$BUFF"
+ echo "$BUFF" >> "$TMP"
+ fi
+
done
cd ..
@@ -127,15 +127,27 @@
unset desc
eval `$MODULE --tcltk | head -n 3 | tail -n 2 | tr '"' "'" | \
- sed -e 's/^ //' -e 's/ {/="/' -e 's/}$/"/'`
+ sed -e 's/^ //' -e 's/ {/="/' -e 's/}$/"/' -e 's/[^\."]"$/&./'`
+
if [ -z "$label" ] && [ -z "$desc" ] ; then
continue
fi
+
+ MODULE_MENU_LOC=`find_menu_hierarchy "$MODULE"`
+
+ BUFF=""
if [ -z "$label" ] ; then
- echo "$MODULE: $desc" >> "$TMP"
+ BUFF="$MODULE: $desc"
else
- echo "$MODULE: $label" >> "$TMP"
+ BUFF="$MODULE: $label"
fi
+ if [ -n "$MODULE_MENU_LOC" ] ; then
+ BUFF="$BUFF {$MODULE_MENU_LOC}"
+ fi
+ if [ -n "$BUFF" ] ; then
+ #echo "$BUFF"
+ echo "$BUFF" >> "$TMP"
+ fi
done
@@ -158,12 +170,8 @@
sort "$TMP" > "$SYNOP"
\rm -f "$TMP"
+cp "$SYNOP" "${TMP}.txt"
-
-# add missing periods at end of descriptions
-sed -e 's/[^\.]$/&./' "$SYNOP" > "${TMP}.txt"
-
-
####### create HTML source #######
# poor cousin to full_index.html from tools/build_html_index.sh
# todo $MODULE.html links
@@ -188,6 +196,11 @@
</center>
<BR><BR><BR>
+<i><font size="-1" color="#778877">
+ Menu position follows if available.</font></i>
+
+<BR><BR>
+
<h4>Command types:</h4>
<ul>
<li> d.* - <a href="#d">display commands</a>
@@ -245,7 +258,10 @@
grep "^${SECTION}\." "${TMP}.txt" | \
sed -e 's/: /| /' -e 's/^.*|/<li> <a href="&.html">&<\/a>:/' \
-e 's/|.html">/.html">/' -e 's+|</a>:+</a>:+' \
- -e 's/&/\&/g' >> "${TMP}.html"
+ -e 's/&/\&/g' \
+ -e 's+ {+\n <BR><font size="-2" color="#778877"><i>+' \
+ -e 's+}+</i></font>+' \
+ -e 's+ > + \→ +g' >> "${TMP}.html"
if [ "$SECTION" = "i" ] ; then
# include imagery photo subsection
@@ -260,7 +276,10 @@
grep "^photo\." "${TMP}.txt" | \
sed -e 's/: /| /' -e 's/^.*|/<li> <a href="&.html">&<\/a>:/' \
-e 's/|.html">/.html">/' -e 's+|</a>:+</a>:+' \
- -e 's/&/\&/g' >> "${TMP}.html"
+ -e 's/&/\&/g' \
+ -e 's+ {+\n <BR><font size="-2" color="#778877"><i>+' \
+ -e 's+}+</i></font>+' \
+ -e 's+ > + \→ +g' >> "${TMP}.html"
fi
done
@@ -296,6 +315,8 @@
\usepackage[latin1]{inputenc}
\usepackage{a4wide}
\usepackage{graphicx}
+\usepackage{color}
+\definecolor{DarkSeaGreen3}{rgb}{0.412,0.545,0.412}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
@@ -376,8 +397,17 @@
grep "^${SECTION}\." "${TMP}.txt" | \
sed -e 's/^/\\item [/' -e 's/: /]/' \
+ -e 's+ {+ \\\\\n$+' -e 's/}$/$/' \
+ -e 's+ > +\\,\\triangleright\\,|+' \
-e 's/\*/{*}/g' -e 's/_/\\_/g' -e 's/&/\\\&/g' \
- >> "${TMP}.tex"
+ | awk '/^\$/ { STR=$0; \
+ gsub(" ", "\\, ", STR); \
+ sub(/\|/," ",STR); \
+ sub(/^/,"\\textcolor{DarkSeaGreen3}{\\footnotesize ",STR); \
+ sub(/$/,"}",STR); \
+ print STR \
+ } ;
+ /^\\/ {print}' >> "${TMP}.tex"
if [ "$SECTION" = "i" ] ; then
# include imagery photo subsection
More information about the grass-commit
mailing list