2
# -*- coding: utf-8 -*-
4
# utilities for generating HTML indices
5
# (c) 2003-2015 by the GRASS Development Team, Markus Neteler, Glynn Clements, Luca Delucchi
10
from datetime import datetime
12
## TODO: better fix this in include/Make/Html.make, see bug RT #5361
14
# exclude following list of modules from help index:
23
# these modules don't use G_parser()
26
"g.parser": "Provides automated parser, GUI, and help support for GRASS scipts.",
27
"r.li.daemon": "Support module for r.li landscape index calculations."
30
############################################################################
32
header1_tmpl = string.Template(\
33
r"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
36
<title>${title}</title>
37
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
38
<meta name="Author" content="GRASS Development Team">
41
macosx_tmpl = string.Template(\
43
<meta name="AppleTitle" content="GRASS GIS ${grass_version} Help">
44
<meta name="AppleIcon" content="GRASS-${grass_mmver}/grass_icon.png">
45
<meta name="robots" content="anchors">
48
header2_tmpl = string.Template(\
49
r""" <link rel="stylesheet" href="grassdocs.css" type="text/css">
51
<body style="width: ${body_width}">
53
<!-- this file is generated by man/build_html.py -->
55
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
58
<h2>GRASS GIS ${grass_version} Reference Manual</h2>
60
<p><b>Geographic Resources Analysis Support System</b>, commonly
61
referred to as <a href="http://grass.osgeo.org">GRASS</a>, is a <a
62
href="http://en.wikipedia.org/wiki/Geographic_information_system">Geographic
63
Information System</a> (GIS) used for geospatial data management and
64
analysis, image processing, graphics/maps production, spatial
65
modeling, and visualization. GRASS is currently used in academic and
66
commercial settings around the world, as well as by many governmental
67
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
71
(<a href="http://www.gnu.org/licenses/gpl.html">GNU GPLed</a>), image
72
processing and geographic information system (GIS).</p>
77
overview_tmpl = string.Template(\
78
r"""<!-- the files grass${grass_version_major}.html & helptext.html file live in lib/init/ -->
80
<table align="center" border="0" cellspacing="8">
83
<td width="33%" valign="top" class="box"><h3> Quick Introduction</h3>
85
<li class="box"><a href="helptext.html">How to start with GRASS GIS</a></li>
86
<li class="box"><span>Index of <a href="topics.html">topics</a> and <a href="keywords.html">keywords</a></span></li>
90
<li class="box"><a href="projectionintro.html">Intro: projections and spatial transformations</a></li>
94
<li class="box"><span><a href="http://grasswiki.osgeo.org/wiki/Faq">FAQ - Frequently Asked Questions</a> (Wiki)</span></li>
97
<td width="33%" valign="top" class="box"><h3> Graphical User Interface</h3>
99
<li class="box"><span><a href="wxGUI.html">wxGUI</a></span></li>
100
<li class="box"><a href="wxGUI.components.html">wxGUI components</a></li>
101
<li class="box"><a href="wxGUI.toolboxes.html">wxGUI toolboxes</a></li>
105
<li class="box"><a href="topic_gui.html">GUI commands</a></li>
107
<h3> Display</h3>
109
<li class="box"><a href="display.html">Display commands manual</a></li>
110
<li class="box"><a href="displaydrivers.html">Display drivers</a></li>
113
<td width="33%" valign="top" class="box"><h3> General</h3>
115
<li class="box"><a href="grass${grass_version_major}.html">GRASS GIS startup manual</a></li>
116
<li class="box"><a href="general.html">General commands manual</a></li>
118
<h3> Addons</h3>
120
<li class="box"><a href="http://grass.osgeo.org/grass70/manuals/addons/">Addons manual pages</a></li>
125
<td width="33%" valign="top" class="box"><h3> Raster processing</h3>
127
<li class="box"><a href="rasterintro.html">Intro: 2D raster map processing</a></li>
128
<li class="box"><a href="raster.html">Raster commands manual</a></li>
131
<td width="33%" valign="top" class="box"><h3> 3D raster processing</h3>
133
<li class="box"><a href="raster3dintro.html">Intro: 3D raster map (voxel) processing</a></li>
134
<li class="box"><a href="raster3d.html">3D raster (voxel) commands manual</a></li>
136
<td width="33%" valign="top" class="box"><h3> Image processing</h3>
138
<li class="box"><a href="imageryintro.html">Intro: image processing</a></li>
139
<li class="box"><a href="imagery.html">Imagery commands manual</a></li>
143
<td width="33%" valign="top" class="box"><h3> Vector processing</h3>
145
<li class="box"><a href="vectorintro.html">Intro: vector map processing and network analysis</a></li>
146
<li class="box"><a href="vector.html">Vector commands manual</a></li>
147
<li class="box"><a href="vectorascii.html">GRASS ASCII vector format specification</a></li>
149
<td width="33%" valign="top" class="box"><h3> Database</h3>
151
<li class="box"><a href="databaseintro.html">Intro: database management</a></li>
152
<li class="box"><a href="sql.html">SQL support in GRASS GIS</a></li>
153
<li class="box"><a href="database.html">Database commands manual</a></li>
156
<td width="33%" valign="top" class="box"><h3> Temporal processing</h3>
158
<li class="box"><a href="temporalintro.html">Intro: temporal data processing</a></li>
159
<li class="box"><a href="temporal.html">Temporal commands manual</a></li>
164
<td width="33%" valign="top" class="box"><h3> Cartography</h3>
166
<li class="box"><a href="postscript.html">Postscript commands manual</a></li>
167
<li class="box"><a href="g.gui.psmap.html">wxGUI Cartographic Composer</a></li>
170
<td width="33%" valign="top" class="box"><h3> Miscellaneous & Variables</h3>
172
<li class="box"><a href="misc.html">Miscellaneous commands manual</a></li>
173
<li class="box"><a href="variables.html">GRASS variables and environment variables</a></li>
176
<td width="33%" valign="top" class="box"><h3> Python</h3>
178
<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>
187
footer_tmpl = string.Template(\
188
r"""<hr class="header">
189
<p><a href="${index_url}">Help Index</a> | <a href="topics.html">Topics Index</a> | <a href="keywords.html">Keywords Index</a> | <a href="full_index.html">Full Index</a></p>
190
<p>© 2003-${year} <a href="http://grass.osgeo.org">GRASS Development Team</a>, GRASS GIS ${grass_version} Reference Manual</p>
198
cmd2_tmpl = string.Template(\
199
r"""<a name="${cmd}"></a>
200
<h3>${cmd_label} commands (${cmd}.*)</h3>
205
desc1_tmpl = string.Template(\
206
r"""<tr><td valign="top"><a href="${cmd}">${basename}</a></td> <td>${desc}</td></tr>
213
<h4 class="toc">Table of contents</h4>
215
<li class="toc"><a class="toc" href="full_index.html#d">Display commands (d.*)</a></li>
216
<li class="toc"><a class="toc" href="full_index.html#db">Database commands (db.*)</a></li>
217
<li class="toc"><a class="toc" href="full_index.html#g">General commands (g.*)</a></li>
218
<li class="toc"><a class="toc" href="full_index.html#i">Imagery commands (i.*)</a></li>
219
<li class="toc"><a class="toc" href="full_index.html#m">Miscellaneous commands (m.*)</a></li>
220
<li class="toc"><a class="toc" href="full_index.html#ps">PostScript commands (ps.*)</a></li>
221
<li class="toc"><a class="toc" href="full_index.html#r">Raster commands (r.*)</a></li>
222
<li class="toc"><a class="toc" href="full_index.html#r3">3D raster commands (r3.*)</a></li>
223
<li class="toc"><a class="toc" href="full_index.html#t">Temporal commands (t.*)</a></li>
224
<li class="toc"><a class="toc" href="full_index.html#v">Vector commands (v.*)</a></li>
225
<li class="toc"><a class="toc" href="wxGUI.html">wxGUI Graphical User Interface</a></li>
226
<li class="toc"><a class="toc" href="wxGUI.nviz.html">3D visualization suite</a></li>
232
modclass_intro_tmpl = string.Template(\
233
r"""Go to <a href="${modclass_lower}intro.html">${modclass} introduction</a> | <a href="topics.html">topics</a> <p>
237
modclass_tmpl = string.Template(\
238
r"""Go <a href="index.html">back to help overview</a>
239
<h3>${modclass} commands:</h3>
244
desc2_tmpl = string.Template(\
245
r"""<tr><td valign="top"><a href="${cmd}">${basename}</a></td> <td>${desc}</td></tr>
250
full_index_header = \
252
Go <a href="index.html">back to help overview</a>
257
message_tmpl = string.Template(\
258
r"""Generated HTML docs in ${html_dir}/index.html
259
----------------------------------------------------------------------
260
Following modules are missing the 'modulename.html' file in src code:
264
moduletopics_tmpl = string.Template(\
266
<li> <a href="topic_${key}.html">${name}</a></li>
271
headertopics_tmpl = \
273
<link rel="stylesheet" href="grassdocs.css" type="text/css">
275
<body style="width: 99%">
278
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
285
headerkeywords_tmpl = \
287
<link rel="stylesheet" href="grassdocs.css" type="text/css">
289
<body style="width: 99%">
292
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
294
<h2>Keywords - Index of GRASS GIS modules</h2>
298
headerkey_tmpl = string.Template(\
300
<link rel="stylesheet" href="grassdocs.css" type="text/css">
302
<body bgcolor="white">
305
<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
308
<h2>Topic: ${keyword}</h2>
309
<i>Note: see also the corresponding keyword <a href="keywords.html#${keyword}">${keyword}</a> for additional references.</i>
315
############################################################################
317
def check_for_desc_override(basename):
318
return desc_override.get(basename)
326
def write_file(name, contents):
337
def replace_file(name):
339
if os.path.exists(name) and os.path.exists(temp) and read_file(name) == read_file(temp):
346
os.rename(temp, name)
348
def copy_file(src, dst):
349
write_file(dst, read_file(src))
351
def html_files(cls = None):
352
for cmd in sorted(os.listdir(html_dir)):
353
if cmd.endswith(".html") and \
354
(cls in [None, '*'] or cmd.startswith(cls + ".")) and \
355
(cls != '*' or len(cmd.split('.')) >= 3) and \
356
cmd not in ["full_index.html", "index.html"] and \
357
cmd not in exclude_mods and \
358
not cmd.startswith("wxGUI."):
361
def write_html_header(f, title, ismain = False, body_width = "99%"):
362
f.write(header1_tmpl.substitute(title = title))
363
if ismain and macosx:
364
f.write(macosx_tmpl.substitute(grass_version = grass_version,
365
grass_mmver = grass_mmver))
366
f.write(header2_tmpl.substitute(grass_version = grass_version, body_width = body_width))
368
def write_html_cmd_overview(f):
369
f.write(overview_tmpl.substitute(grass_version_major = grass_version_major,
370
grass_version_minor = grass_version_minor))
372
def write_html_footer(f, index_url, year = None):
374
cur_year = default_year
377
f.write(footer_tmpl.substitute(grass_version = grass_version,
378
index_url = index_url, year = cur_year))
393
if "SYNOPSIS" in line:
396
sp = line.split('-',1)
405
"""Convert name of command class/family to form suitable for title"""
406
return name.capitalize()
408
############################################################################
410
arch_dist_dir = os.environ['ARCH_DISTDIR']
411
html_dir = os.path.join(arch_dist_dir, "docs", "html")
412
gisbase = os.environ['GISBASE']
413
grass_version = os.getenv("VERSION_NUMBER", "unknown")
414
grass_version_major = grass_version.split('.')[0]
415
grass_version_minor = grass_version.split('.')[1]
416
grass_mmver = '.'.join(grass_version.split('.')[0:2])
417
macosx = "darwin" in os.environ['ARCH'].lower()
418
default_year = os.getenv("VERSION_DATE")
420
default_year = str(datetime.now().year)
422
############################################################################