[GRASS-SVN] r55313 - grass/trunk/man
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 11 05:43:20 PDT 2013
Author: lucadelu
Date: 2013-03-11 05:43:20 -0700 (Mon, 11 Mar 2013)
New Revision: 55313
Added:
grass/trunk/man/build_keywords.py
Modified:
grass/trunk/man/Makefile
Log:
add first version of script to create keywords page
Modified: grass/trunk/man/Makefile
===================================================================
--- grass/trunk/man/Makefile 2013-03-11 12:30:46 UTC (rev 55312)
+++ grass/trunk/man/Makefile 2013-03-11 12:43:20 UTC (rev 55313)
@@ -23,7 +23,7 @@
IDXCATS := $(foreach cat,$(categories),$(lastword $(subst :, ,$(cat))))
-IDXSRC = full_index index topics $(IDXCATS)
+IDXSRC = full_index index topics keywords $(IDXCATS)
INDICES := $(patsubst %,$(HTMLDIR)/%.html,$(IDXSRC))
@@ -54,6 +54,12 @@
$(PYTHON) ./build_topics.py $(HTMLDIR)
endef
+define build_keywords
+GISBASE="$(RUN_GISBASE)" ARCH="$(ARCH)" ARCH_DISTDIR="$(ARCH_DISTDIR)" \
+ VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) \
+ $(PYTHON) ./build_keywords.py $(HTMLDIR)
+endef
+
$(HTMLDIR)/topics.html: $(ALL_HTML)
$(call build_topics)
touch $@
@@ -66,6 +72,10 @@
$(call build,index)
touch $@
+$(HTMLDIR)/keywords.html: $(ALL_HTML)
+ $(call build_keywords)
+ touch $@
+
define category_rule
$$(HTMLDIR)/$(2).html: $$(wildcard $$(HTMLDIR)/$(1).*.html) build_class.py build_html.py
$$(call build,class,$(1) $(2))
Added: grass/trunk/man/build_keywords.py
===================================================================
--- grass/trunk/man/build_keywords.py (rev 0)
+++ grass/trunk/man/build_keywords.py 2013-03-11 12:43:20 UTC (rev 55313)
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# generates topics.html and topic_*.html
+# (c) 2013 by the GRASS Development Team, Luca Delucchi
+
+import os
+import sys
+import glob
+import string
+from build_html import *
+
+blacklist = ['Display', 'Database', 'General', 'Imagery', 'Misc', 'Postscript',
+ 'Raster', 'Raster3D', 'Temporal', 'Vector']
+
+path = sys.argv[1]
+year = os.getenv("VERSION_DATE")
+
+keywords = {}
+
+htmlfiles = glob.glob1(path, '*.html')
+
+for fname in htmlfiles:
+ fil = open(os.path.join(path, fname))
+ # TODO maybe move to Python re (regex)
+ lines=fil.readlines()
+ try:
+ index_keys = lines.index('<h2>KEYWORDS</h2>\n') + 1
+ index_desc = lines.index('<h2>NAME</h2>\n') + 1
+ except:
+ continue
+ try:
+ keys = lines[index_keys].split(',')
+ except:
+ continue
+ for key in keys:
+ key = key.strip().title()
+ if key not in keywords.keys():
+ keywords[key] = []
+ keywords[key].append(fname)
+ elif fname not in keywords[key]:
+ keywords[key].append(fname)
+
+for black in blacklist:
+ try:
+ del keywords[black]
+ except:
+ continue
+
+topicsfile = open(os.path.join(path, 'keywords.html'), 'w')
+topicsfile.write(header1_tmpl.substitute(title = "GRASS GIS " \
+ "%s Reference Manual: Topics index" % grass_version))
+topicsfile.write(headertopics_tmpl)
+for key, values in sorted(keywords.iteritems()):
+ keyword_line = "<li><b>%s</b>:" % key
+ for value in values:
+ keyword_line += ' <a href="%s">%s</a>,' % (value, value.replace('.html',
+ ''))
+ keyword_line = keyword_line.rstrip(',')
+ keyword_line += '</li>\n'
+ topicsfile.write(keyword_line)
+
+topicsfile.write("</ul>\n")
+write_html_footer(topicsfile, "index.html", year)
+topicsfile.close()
+
More information about the grass-commit
mailing list