[GRASS-SVN] r66038 - grass/trunk/man
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 26 18:22:08 PDT 2015
Author: wenzeslaus
Date: 2015-08-26 18:22:08 -0700 (Wed, 26 Aug 2015)
New Revision: 66038
Modified:
grass/trunk/man/build_graphical_index.py
Log:
docs: include module name in graphical index (gallery) and make image size dependent on em rather than percentage
Modified: grass/trunk/man/build_graphical_index.py
===================================================================
--- grass/trunk/man/build_graphical_index.py 2015-08-27 00:31:43 UTC (rev 66037)
+++ grass/trunk/man/build_graphical_index.py 2015-08-27 01:22:08 UTC (rev 66038)
@@ -5,7 +5,7 @@
#
# MODULE: build_graphical_index
# AUTHOR(S): Vaclav Petras <wenzeslaus gmail com>
-# PURPOSE: Build index from images from all HTML files
+# PURPOSE: Build index (gallery) from images from all HTML files
# COPYRIGHT: (C) 2015 by Vaclav Petras and the GRASS Development Team
#
# This program is free software under the GNU General Public
@@ -41,13 +41,48 @@
header_graphical_index_tmpl = """\
<link rel="stylesheet" href="grassdocs.css" type="text/css">
<style>
-img.linkimg {
- max-width: 20%;
- padding: 1%;
+.img-list {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ text-align: center;
}
-img.linkimg:hover {
+
+.img-list li {
+ display: inline-block;
+ position: relative;
+ width: 7em;
+ margin: 0;
+ padding: 0.5em;
+}
+
+.img-list li:hover {
background-color: #eee;
}
+
+.img-list li img {
+ float: left;
+ max-width: 100%;
+ background: white;
+}
+
+.img-list li span {
+ text-align: center;
+}
+
+.img-list li a {
+ color: initial;
+ text-decoration: none;
+}
+
+.img-list li .name {
+ margin: 0.1em;
+ display: block;
+ color: #409940;
+ font-weight: normal;
+ font-style: italic;
+ font-size: 80%;
+}
</style>
</head>
<body style="width: 99%">
@@ -76,14 +111,15 @@
return False
-def get_files(directory, patterns, exclude_name):
+def get_files(directory, patterns, exclude_patterns):
files = []
for filename in os.listdir(directory):
if file_matches(filename, patterns):
- if filename != exclude_name:
+ if not file_matches(filename, exclude_patterns):
files.append(filename)
return files
+
def remove_module_name(string, module):
string = string.replace(module.replace('wxGUI.', 'g.gui.'), '')
string = string.replace(module.replace('.', '_'), '') # using _
@@ -91,11 +127,11 @@
string = string.replace(module, '') # using original dots
return string
-def title_form_names(html_name, img_name):
+
+def title_from_names(module_name, img_name):
# we ignore the possibility of having extension at the end of image
# so possibly r.out.png fails but image name should use _ anyway
# strictly speaking, it could be also, e.g., index name
- module_name = html_name.replace('.html', '')
for extension in img_extensions:
img_name = img_name.replace('.' + extension, '')
img_name = remove_module_name(img_name, module_name)
@@ -107,10 +143,15 @@
return "{name}".format(name=module_name)
+def get_module_name(filename):
+ return filename.replace('.html', '')
+
+
def main():
html_dir = sys.argv[1]
- html_files = get_files(html_dir, ['*.html'], output_name)
+ html_files = get_files(html_dir, ['*.html'],
+ exclude_patterns=[output_name, '*_graphical.html'])
img_html_files = {}
for filename in os.listdir(html_dir):
@@ -126,13 +167,19 @@
output.write(header1_tmpl.substitute(title="GRASS GIS %s Reference "
"Manual: Graphical index" % grass_version))
output.write(header_graphical_index_tmpl)
+ output.write('<ul class="img-list">\n')
for image, html_file in img_html_files.iteritems():
- title = title_form_names(html_file, image)
+ name = get_module_name(html_file)
+ title = title_from_names(name, image)
output.write(
+ '<li>'
'<a href="{html}" title="{title}">'
- '<img class="linkimg" src="{img}">'
+ '<img src="{img}">'
+ '<span class="name">{name}</span>'
'</a>'
- .format(html=html_file, img=image, title=title))
+ '</li>\n'
+ .format(html=html_file, img=image, title=title, name=name))
+ output.write('</ul>')
write_html_footer(output, "index.html", year)
More information about the grass-commit
mailing list