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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# utilities for generating HTML indices
# (c) 2003-2015 by the GRASS Development Team, Markus Neteler, Glynn Clements, Luca Delucchi
import sys
import os
import string
from datetime import datetime
## TODO: better fix this in include/Make/Html.make, see bug RT #5361
# exclude following list of modules from help index:
exclude_mods = [
"i.find",
"r.watershed.ram",
"r.watershed.seg",
"v.topo.check",
"helptext.html"]
# these modules don't use G_parser()
desc_override = {
"g.parser": "Provides automated parser, GUI, and help support for GRASS scipts.",
"r.li.daemon": "Support module for r.li landscape index calculations."
}
############################################################################
header1_tmpl = string.Template(\
r"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>${title}</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="GRASS Development Team">
""")
macosx_tmpl = string.Template(\
r"""
<meta name="AppleTitle" content="GRASS GIS ${grass_version} Help">
<meta name="AppleIcon" content="GRASS-${grass_mmver}/grass_icon.png">
<meta name="robots" content="anchors">
""")
header2_tmpl = string.Template(\
r""" <link rel="stylesheet" href="grassdocs.css" type="text/css">
</head>
<body style="width: ${body_width}">
<div id="container">
<!-- this file is generated by man/build_html.py -->
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
<hr class="header">
<h2>GRASS GIS ${grass_version} Reference Manual</h2>
<p><b>Geographic Resources Analysis Support System</b>, commonly
referred to as <a href="http://grass.osgeo.org">GRASS</a>, is a <a
href="http://en.wikipedia.org/wiki/Geographic_information_system">Geographic
Information System</a> (GIS) used for geospatial data management and
analysis, image processing, graphics/maps production, spatial
modeling, and visualization. GRASS is currently used in academic and
commercial settings around the world, as well as by many governmental
agencies and environmental consulting companies.</p>
<p>This reference manual details the use of modules distributed with
Geographic Resources Analysis Support System (GRASS), an open source
(<a href="http://www.gnu.org/licenses/gpl.html">GNU GPLed</a>), image
processing and geographic information system (GIS).</p>
""")
#"
overview_tmpl = string.Template(\
r"""<!-- the files grass${grass_version_major}.html & helptext.html file live in lib/init/ -->
<table align="center" border="0" cellspacing="8">
<tbody>
<tr>
<td width="33%" valign="top" class="box"><h3> Quick Introduction</h3>
<ul>
<li class="box"><a href="helptext.html">How to start with GRASS GIS</a></li>
<li class="box"><span>Index of <a href="topics.html">topics</a> and <a href="keywords.html">keywords</a></span></li>
</ul>
<p>
<ul>
<li class="box"><a href="projectionintro.html">Intro: projections and spatial transformations</a></li>
</ul>
<p>
<ul>
<li class="box"><span><a href="http://grasswiki.osgeo.org/wiki/Faq">FAQ - Frequently Asked Questions</a> (Wiki)</span></li>
</ul>
<p>
<ul>
<li class="box"><span><a href="graphical_index.html">Graphical index of functionality</a></span></li>
</ul>
</td>
<td width="33%" valign="top" class="box"><h3> Graphical User Interface</h3>
<ul>
<li class="box"><span><a href="wxGUI.html">wxGUI</a></span></li>
<li class="box"><a href="wxGUI.components.html">wxGUI components</a></li>
<li class="box"><a href="wxGUI.toolboxes.html">wxGUI toolboxes</a></li>
</ul>
<ul>
<li class="box"><a href="topic_GUI.html">GUI commands</a></li>
</ul>
<h3> Display</h3>
<ul>
<li class="box"><a href="display.html">Display commands manual</a></li>
<li class="box"><a href="displaydrivers.html">Display drivers</a></li>
</ul>
</td>
<td width="33%" valign="top" class="box"><h3> General</h3>
<ul>
<li class="box"><a href="grass${grass_version_major}.html">GRASS GIS startup manual</a></li>
<li class="box"><a href="general.html">General commands manual</a></li>
</ul>
<h3> Addons</h3>
<ul>
<li class="box"><a href="https://grass.osgeo.org/grass7/manuals/addons/">Addons manual pages</a></li>
</ul>
</td>
</tr>
<tr>
<td width="33%" valign="top" class="box"><h3> Raster processing</h3>
<ul>
<li class="box"><a href="rasterintro.html">Intro: 2D raster map processing</a></li>
<li class="box"><a href="raster.html">Raster commands manual</a></li>
</ul>
</td>
<td width="33%" valign="top" class="box"><h3> 3D raster processing</h3>
<ul>
<li class="box"><a href="raster3dintro.html">Intro: 3D raster map (voxel) processing</a></li>
<li class="box"><a href="raster3d.html">3D raster (voxel) commands manual</a></li>
</ul></td>
<td width="33%" valign="top" class="box"><h3> Image processing</h3>
<ul>
<li class="box"><a href="imageryintro.html">Intro: image processing</a></li>
<li class="box"><a href="imagery.html">Imagery commands manual</a></li>
</ul></td>
</tr>
<tr>
<td width="33%" valign="top" class="box"><h3> Vector processing</h3>
<ul>
<li class="box"><a href="vectorintro.html">Intro: vector map processing and network analysis</a></li>
<li class="box"><a href="vector.html">Vector commands manual</a></li>
<li class="box"><a href="vectorascii.html">GRASS ASCII vector format specification</a></li>
</ul></td>
<td width="33%" valign="top" class="box"><h3> Database</h3>
<ul>
<li class="box"><a href="databaseintro.html">Intro: database management</a></li>
<li class="box"><a href="sql.html">SQL support in GRASS GIS</a></li>
<li class="box"><a href="database.html">Database commands manual</a></li>
</ul>
</td>
<td width="33%" valign="top" class="box"><h3> Temporal processing</h3>
<ul>
<li class="box"><a href="temporalintro.html">Intro: temporal data processing</a></li>
<li class="box"><a href="temporal.html">Temporal commands manual</a></li>
</ul>
</td>
</tr>
<tr>
<td width="33%" valign="top" class="box"><h3> Cartography</h3>
<ul>
<li class="box"><a href="postscript.html">PostScript commands manual</a></li>
<li class="box"><a href="g.gui.psmap.html">wxGUI Cartographic Composer</a></li>
</ul>
</td>
<td width="33%" valign="top" class="box"><h3> Miscellaneous & Variables</h3>
<ul>
<li class="box"><a href="miscellaneous.html">Miscellaneous commands manual</a></li>
<li class="box"><a href="variables.html">GRASS variables and environment variables</a></li>
</ul>
</td>
<td width="33%" valign="top" class="box"><h3> Python</h3>
<ul>
<li class="box"><a href="http://grass.osgeo.org/grass${grass_version_major}${grass_version_minor}/manuals/libpython/index.html">GRASS GIS Python library documentation</a></li>
<li class="box"><a href="http://grass.osgeo.org/grass${grass_version_major}${grass_version_minor}/manuals/libpython/pygrass_index.html">PyGRASS documentation</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
""")
#"
footer_tmpl = string.Template(\
r"""<hr class="header">
<p>
<a href="${index_url}">Main index</a> |
<a href="topics.html">Topics index</a> |
<a href="keywords.html">Keywords index</a> |
<a href="graphical_index.html">Graphical index</a> |
<a href="full_index.html">Full index</a>
</p>
<p>
© 2003-${year}
<a href="http://grass.osgeo.org">GRASS Development Team</a>,
GRASS GIS ${grass_version} Reference Manual
</p>
</div>
</body>
</html>
""")
#"
cmd2_tmpl = string.Template(\
r"""<a name="${cmd}"></a>
<h3>${cmd_label} commands (${cmd}.*)</h3>
<table>
""")
#"
desc1_tmpl = string.Template(\
r"""<tr><td valign="top"><a href="${cmd}">${basename}</a></td> <td>${desc}</td></tr>
""")
#"
toc = \
r"""
<div class="toc">
<h4 class="toc">Table of contents</h4>
<ul class="toc">
<li class="toc"><a class="toc" href="full_index.html#d">Display commands (d.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#db">Database commands (db.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#g">General commands (g.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#i">Imagery commands (i.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#m">Miscellaneous commands (m.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#ps">PostScript commands (ps.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#r">Raster commands (r.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#r3">3D raster commands (r3.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#t">Temporal commands (t.*)</a></li>
<li class="toc"><a class="toc" href="full_index.html#v">Vector commands (v.*)</a></li>
<li class="toc"><a class="toc" href="wxGUI.html">wxGUI Graphical User Interface</a></li>
<li class="toc"><a class="toc" href="wxGUI.nviz.html">3D visualization suite</a></li>
</ul>
</div>
"""
#"
modclass_intro_tmpl = string.Template(\
r"""Go to <a href="${modclass_lower}intro.html">${modclass} introduction</a> | <a href="topics.html">topics</a> <p>
""")
#"
modclass_tmpl = string.Template(\
r"""Go <a href="index.html">back to help overview</a>
<h3>${modclass} commands:</h3>
<table>
""")
#"
desc2_tmpl = string.Template(\
r"""<tr><td valign="top"><a href="${cmd}">${basename}</a></td> <td>${desc}</td></tr>
""")
#"
full_index_header = \
r"""
Go <a href="index.html">back to help overview</a>
"""
#"
message_tmpl = string.Template(\
r"""Generated HTML docs in ${html_dir}/index.html
----------------------------------------------------------------------
Following modules are missing the 'modulename.html' file in src code:
""")
#"
moduletopics_tmpl = string.Template(\
r"""
<li> <a href="topic_${key}.html">${name}</a></li>
"""
)
#"
headertopics_tmpl = \
r"""
<link rel="stylesheet" href="grassdocs.css" type="text/css">
</head>
<body style="width: 99%">
<div id="container">
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
<hr class="header">
<h2>Topics</h2>
<ul>
"""
#"
headerkeywords_tmpl = \
r"""
<link rel="stylesheet" href="grassdocs.css" type="text/css">
</head>
<body style="width: 99%">
<div id="container">
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
<hr class="header">
<h2>Keywords - Index of GRASS GIS modules</h2>
"""
#"
headerkey_tmpl = string.Template(\
r"""
<link rel="stylesheet" href="grassdocs.css" type="text/css">
</head>
<body bgcolor="white">
<div id="container">
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
<hr class="header">
<h2>Topic: ${keyword}</h2>
<table>
""")
#"
headerpso_tmpl = \
r"""
<link rel="stylesheet" href="grassdocs.css" type="text/css">
<link rel="stylesheet" href="parser_standard_options.css" type="text/css">
<script src="jquery/jquery.min.js"></script>
<script type="text/javascript" src="jquery.fixedheadertable.min.js"></script>
<script type="text/javascript" src="parser_standard_options.js"></script>
</head>
<body style="width: 99%">
<div id="container">
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
<hr class="header">
<h2>Parser standard options</h2>
<ul>
"""
#"
############################################################################
def check_for_desc_override(basename):
return desc_override.get(basename)
def read_file(name):
f = open(name, 'rb')
s = f.read()
f.close()
return s
def write_file(name, contents):
f = open(name, 'wb')
f.write(contents)
f.close()
def try_mkdir(path):
try:
os.mkdir(path)
except OSError as e:
pass
def replace_file(name):
temp = name + ".tmp"
if os.path.exists(name) and os.path.exists(temp) and read_file(name) == read_file(temp):
os.remove(temp)
else:
try:
os.remove(name)
except OSError as e:
pass
os.rename(temp, name)
def copy_file(src, dst):
write_file(dst, read_file(src))
def html_files(cls=None, ignore_gui=True):
for cmd in sorted(os.listdir(html_dir)):
if cmd.endswith(".html") and \
(cls in [None, '*'] or cmd.startswith(cls + ".")) and \
(cls != '*' or len(cmd.split('.')) >= 3) and \
cmd not in ["full_index.html", "index.html"] and \
cmd not in exclude_mods and \
(ignore_gui and not cmd.startswith("wxGUI.") or not ignore_gui):
yield cmd
def write_html_header(f, title, ismain = False, body_width = "99%"):
f.write(header1_tmpl.substitute(title = title))
if ismain and macosx:
f.write(macosx_tmpl.substitute(grass_version = grass_version,
grass_mmver = grass_mmver))
f.write(header2_tmpl.substitute(grass_version = grass_version, body_width = body_width))
def write_html_cmd_overview(f):
f.write(overview_tmpl.substitute(grass_version_major = grass_version_major,
grass_version_minor = grass_version_minor))
def write_html_footer(f, index_url, year = None):
if year is None:
cur_year = default_year
else:
cur_year = year
f.write(footer_tmpl.substitute(grass_version = grass_version,
index_url = index_url, year = cur_year))
def get_desc(cmd):
f = open(cmd, 'r')
while True:
line = f.readline()
if not line:
return ""
if "NAME" in line:
break
while True:
line = f.readline()
if not line:
return ""
if "SYNOPSIS" in line:
break
if "<em>" in line:
sp = line.split('-',1)
if len(sp) > 1:
return sp[1].strip()
else:
return None
return ""
def to_title(name):
"""Convert name of command class/family to form suitable for title"""
if name == 'PostScript':
return name
return name.capitalize()
############################################################################
arch_dist_dir = os.environ['ARCH_DISTDIR']
html_dir = os.path.join(arch_dist_dir, "docs", "html")
gisbase = os.environ['GISBASE']
grass_version = os.getenv("VERSION_NUMBER", "unknown")
grass_version_major = grass_version.split('.')[0]
grass_version_minor = grass_version.split('.')[1]
grass_mmver = '.'.join(grass_version.split('.')[0:2])
macosx = "darwin" in os.environ['ARCH'].lower()
default_year = os.getenv("VERSION_DATE")
if not default_year:
default_year = str(datetime.now().year)
############################################################################
|