build_html_index.sh 12 KB

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