build_html_index.sh 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. #!/bin/sh
  2. #generates HTML man pages docs/html/index.html
  3. # Markus Neteler, 2003, 2004, 2005, 2006
  4. ## TODO: better fix this in include/Make/Html.make, see bug #5361
  5. #exclude following list of modules from help index:
  6. EXCLUDEMODS="\
  7. v.topo.check \
  8. i.ask \
  9. i.find \
  10. helptext.html \
  11. r.watershed.ram \
  12. r.watershed.seg \
  13. wxGUI.*"
  14. # these modules don't use G_parser()
  15. check_for_desc_override()
  16. {
  17. case "$BASENAME" in
  18. g.parser)
  19. SHORTDESC="Provides automated parser, GUI, and help support for GRASS scipts."
  20. ;;
  21. r.li.daemon)
  22. SHORTDESC="Support module for r.li landscape index calculations."
  23. ;;
  24. esac
  25. }
  26. ############# nothing to configure below ############
  27. # regex-proof module skip list
  28. EXCLUDEHTML="`echo "$EXCLUDEMODS" | tr ' ' '|' | sed -e 's+\.+\\\\.+g' -e 's+|+\\\\|+g'`"
  29. #fetch the ARCH for store the files:
  30. ARCH="`cat ../include/Make/Platform.make | grep '^ARCH' | sed 's+ ++g' | cut -d'=' -f2`"
  31. GEMDIR="../gem"
  32. HTMLDIR="../dist.$ARCH/docs/html"
  33. GRASSVERSION=`cat ../dist.$ARCH/etc/VERSIONNUMBER`
  34. GRASS_MMVER=`cut -d . -f 1-2 ../dist.$ARCH/etc/VERSIONNUMBER`
  35. MACOSX=`echo $ARCH | grep -i darwin`
  36. write_html_header()
  37. {
  38. # $1: not used
  39. # $2: page title
  40. # $3: is it main index
  41. cat <<EOF
  42. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  43. <html>
  44. <head>
  45. <title>$2</title>
  46. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  47. <meta name="Author" content="GRASS Development Team">
  48. EOF
  49. if [ "$3" ] && [ "$MACOSX" ] ; then
  50. cat <<EOF
  51. <meta name="AppleTitle" content="GRASS GIS $GRASSVERSION Help">
  52. <meta name="AppleIcon" content="GRASS-$GRASS_MMVER/grass_icon.png">
  53. <meta name="robots" content="anchors">
  54. EOF
  55. fi
  56. cat <<EOF
  57. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  58. </head>
  59. <body bgcolor="#FFFFFF">
  60. <!-- this file is generated by tools/build_html_index.sh -->
  61. <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
  62. <h2>GRASS GIS $GRASSVERSION Reference Manual</h2>
  63. <p>
  64. <em>Geographic Resources Analysis Support System</em>, commonly referred to as
  65. <a href="http://grass.osgeo.org">GRASS</a>,
  66. is a Geographic Information System (GIS) used for geospatial data management
  67. and analysis, image processing, graphics/maps production, spatial modeling,
  68. and visualization. GRASS is currently used in academic and commercial settings
  69. around the world, as well as by many governmental agencies and environmental
  70. consulting companies.</p>
  71. <p>This reference manual details the use of modules distributed with
  72. Geographic Resources Analysis Support System (GRASS), an open source (GNU
  73. GPLed), image processing and geographic information system (GIS).</p>
  74. <BR><BR>
  75. <h3>Quick Introduction</h3>
  76. <!-- the files grass7.html & helptext.html file live in lib/init/ -->
  77. <ul>
  78. <li><a href="grass7.html">GRASS startup manual page</a></li>
  79. <li><a href="helptext.html">How to start with GRASS</a></li>
  80. <li>Introductions
  81. <ul>
  82. <li><a href="rasterintro.html">2D raster map processing</a></li>
  83. <li><a href="raster3dintro.html">3D raster map (voxel) processing</a></li>
  84. <li><a href="imageryintro.html">Image processing</a></li>
  85. <li><a href="databaseintro.html">Database management</a></li>
  86. <li><a href="vectorintro.html">Vector map processing and network analysis</a></li>
  87. <li><a href="projectionintro.html">Projections and spatial transformations</a></li>
  88. <li><a href="sql.html">SQL support</a></li>
  89. <li><a href="displaydrivers.html">Display drivers</a></li>
  90. <li><a href="variables.html">GRASS variables and environment variables</a></li>
  91. </ul>
  92. <li><a href="gem/index.html">The GRASS Extensions Manager (GEM)</a></li>
  93. </ul>
  94. <P>
  95. EOF
  96. }
  97. write_html_footer()
  98. {
  99. # $1: unused
  100. # $2: help index url
  101. cat <<EOF
  102. <BR><BR>
  103. <hr>
  104. <p><a href="$2">Help Index</a> | <a href="full_index.html">Full Index</a><br>
  105. &copy; 2003-2008 <a href="http://grass.osgeo.org">GRASS Development Team</a></p>
  106. </body>
  107. </html>
  108. EOF
  109. }
  110. expand_module_class_name()
  111. {
  112. # $1: module class
  113. case "$1" in
  114. d) echo "display" ;;
  115. db) echo "database" ;;
  116. g) echo "general" ;;
  117. i) echo "imagery" ;;
  118. m) echo "misc" ;;
  119. ps) echo "postscript" ;;
  120. p) echo "paint" ;;
  121. r) echo "raster" ;;
  122. r3) echo "raster3D" ;;
  123. s) echo "sites" ;;
  124. v) echo "vector" ;;
  125. *) echo "$1" ;;
  126. esac
  127. }
  128. replace_file()
  129. {
  130. # $1: filename
  131. if [ -f $1 ] && cmp $1.tmp $1 >/dev/null ; then
  132. rm $1.tmp
  133. else
  134. mv $1.tmp $1
  135. fi
  136. }
  137. #are we in the tools/ dir?
  138. if [ ! -f build_html_index.sh ] ; then
  139. echo "ERROR: this script must be run from the tools/ directory" >&2
  140. exit 1
  141. fi
  142. FULLINDEX=full_index.html
  143. ################
  144. #copy over CSS:
  145. cp -f grassdocs.css $HTMLDIR/
  146. mkdir -p $HTMLDIR/nviz/
  147. cp -f grassdocs.css $HTMLDIR/nviz/
  148. chmod a+r $HTMLDIR/grassdocs.css $HTMLDIR/nviz/grassdocs.css
  149. #copy over GRASS logo:
  150. cp -f grass_logo.png $HTMLDIR/
  151. cp -f grass_logo.png $HTMLDIR/nviz/
  152. chmod a+r $HTMLDIR/grass_logo.png $HTMLDIR/nviz/grass_logo.png
  153. if [ "$MACOSX" ] ; then
  154. cp -f grass_icon.png $HTMLDIR/
  155. chmod a+r $HTMLDIR/grass_icon.png
  156. fi
  157. #copy over GEM docs:
  158. mkdir -p $HTMLDIR/gem
  159. cp -f $GEMDIR/docs/GEM-Manual/*.html $HTMLDIR/gem/
  160. cp -f $GEMDIR/docs/GEM-Manual/img* $HTMLDIR/gem/
  161. chmod a+r $HTMLDIR/gem/*.html $HTMLDIR/gem/img*
  162. #process all HTML pages:
  163. cd "$HTMLDIR"
  164. #get list of available GRASS modules:
  165. CMDLIST=`ls -1 *.*.html | grep -v "$FULLINDEX" | grep -v index.html | \
  166. grep -v "\($EXCLUDEHTML\)" | cut -d'.' -f1 | sort -u`
  167. CMDLISTNO=`echo $CMDLIST | wc -w | awk '{print $1}'`
  168. echo "Generating HTML manual pages index (help system)..." >&2
  169. ###############################################################################
  170. #begin full index:
  171. (
  172. write_html_header - "GRASS GIS $GRASSVERSION Reference Manual: Full index"
  173. cat <<EOF
  174. <BR><h3>Full command index:</h3>
  175. <table border=0>
  176. <tr><td>&nbsp;&nbsp;d.* </td><td>display commands</td></tr>
  177. <tr><td>&nbsp;&nbsp;db.* </td><td>database commands</td></tr>
  178. <tr><td>&nbsp;&nbsp;g.* </td><td>general commands</td></tr>
  179. <tr><td>&nbsp;&nbsp;i.* </td><td>imagery commands</td></tr>
  180. <tr><td>&nbsp;&nbsp;m.* </td><td>miscellaneous commands</td></tr>
  181. <tr><td>&nbsp;&nbsp;ps.* </td><td>postscript commands</td></tr>
  182. <tr><td>&nbsp;&nbsp;r.* </td><td>raster commands</td></tr>
  183. <tr><td>&nbsp;&nbsp;r3.* </td><td>raster3D commands</td></tr>
  184. <tr><td>&nbsp;&nbsp;v.* </td><td>vector commands</td></tr>
  185. <tr><td>&nbsp;&nbsp;<a href="nviz.html">nviz</a> </td><td>visualization suite</td></tr>
  186. <tr><td>&nbsp;&nbsp;<a href="wxGUI.html">wxGUI</a> </td><td>wxPython-based GUI frontend</td></tr>
  187. <tr><td>&nbsp;&nbsp;<a href="xganim.html">xganim</a> </td><td>raster map slideshow</td></tr>
  188. </table>
  189. EOF
  190. #generate main index of all modules:
  191. echo "<BR><BR>[ "
  192. k=0
  193. for i in $CMDLIST
  194. do
  195. k=`expr $k + 1`
  196. echo -n "<b><a href=\"#$i\">$i.*</a></b>"
  197. if [ $k -lt $CMDLISTNO ] ; then
  198. echo -n " | "
  199. fi
  200. done
  201. echo " ]"
  202. echo "<BR>"
  203. echo ""
  204. #for all module groups:
  205. for i in $CMDLIST
  206. do
  207. cat <<-EOF
  208. <a name="$i"></a>
  209. <BR><BR><h3>$i.* commands:</h3>
  210. <table>
  211. EOF
  212. #for all modules:
  213. for i in `ls -1 $i.*.html | grep -v "\($EXCLUDEHTML\)"`
  214. do
  215. BASENAME=`basename $i .html`
  216. SHORTDESC="`cat $i | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
  217. check_for_desc_override
  218. echo "<tr><td valign=\"top\"><a href=\"$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>"
  219. done
  220. echo "</table>"
  221. done
  222. write_html_footer - index.html
  223. ) > "$FULLINDEX.tmp"
  224. replace_file "$FULLINDEX"
  225. # done full index
  226. ###############################################################################
  227. #next write separate module pages:
  228. #for all module groups:
  229. for k in $CMDLIST
  230. do
  231. MODCLASS=`expand_module_class_name $k`
  232. FILENAME="$MODCLASS.html"
  233. (
  234. write_html_header - "GRASS GIS $GRASSVERSION Reference Manual: $MODCLASS"
  235. echo "<b>$MODCLASS commands:</b>"
  236. echo "<table>"
  237. #for all modules:
  238. for k in `ls -1 $k.*.html | grep -v "\($EXCLUDEHTML\)"`
  239. do
  240. BASENAME=`basename $k .html`
  241. SHORTDESC="`cat $k | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
  242. check_for_desc_override
  243. echo "<tr><td valign=\"top\"><a href=\"$k\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>"
  244. done
  245. echo "</table>"
  246. write_html_footer - index.html
  247. ) > "$FILENAME.tmp"
  248. replace_file "$FILENAME"
  249. done
  250. ###############################################################################
  251. #next write main page:
  252. FILENAME=index.html
  253. (
  254. write_html_header - "GRASS GIS $GRASSVERSION Reference Manual" 1
  255. #modules:
  256. echo "<h3>Manual sections:</h3>"
  257. echo "<ul>"
  258. #for all module groups:
  259. for k in $CMDLIST
  260. do
  261. MODCLASS=`expand_module_class_name $k`
  262. echo "<li><a href=\"$MODCLASS.html\">$MODCLASS commands</a></li>"
  263. done
  264. #extra stuff for 'nviz' and 'xganim' and GUI:
  265. cat <<EOF
  266. <li><a href="nviz.html">nviz</a> visualization and animation tool</li>
  267. <li><a href="wxGUI.html">wxGUI</a> wxPython-based GUI frontend</li>
  268. <li><a href="xganim.html">xganim</a> tool for animating a raster map series</li>
  269. </ul>
  270. <!-- GEM Extensions StartHTML. Do not delete or change this comment! -->
  271. EOF
  272. write_html_footer - index.html
  273. ) > "$FILENAME.tmp"
  274. replace_file "$FILENAME"
  275. ###############################################################################
  276. echo "Generated HTML docs in $HTMLDIR/index.html"
  277. echo "----------------------------------------------------------------------"
  278. echo "Following modules are missing the 'description.html' file in src code:"
  279. for i in `find . -name "*.*.html" | sort | grep -v "$FULLINDEX" | grep -v 'index.html' | grep -v "$EXCLUDEHTML"`
  280. do
  281. if grep 'DESCRIPTION' $i >/dev/null 2>&1 ; then
  282. :
  283. else
  284. echo `echo $i | sed 's?./??' | sed 's/.html//'`
  285. fi
  286. done
  287. echo "----------------------------------------------------------------------"