[GRASS-SVN] r70192 - in grass/branches/releasebranch_7_0: include/Make tools

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 1 15:14:46 PST 2017


Author: neteler
Date: 2017-01-01 15:14:46 -0800 (Sun, 01 Jan 2017)
New Revision: 70192

Modified:
   grass/branches/releasebranch_7_0/include/Make/GuiScript.make
   grass/branches/releasebranch_7_0/include/Make/Html.make
   grass/branches/releasebranch_7_0/tools/mkhtml.py
Log:
documentation: add link to source code (see #2864) (backport from relbranch72 in order to get the link also into addon manual pages: r69290 + r67566)

Modified: grass/branches/releasebranch_7_0/include/Make/GuiScript.make
===================================================================
--- grass/branches/releasebranch_7_0/include/Make/GuiScript.make	2017-01-01 21:55:46 UTC (rev 70191)
+++ grass/branches/releasebranch_7_0/include/Make/GuiScript.make	2017-01-01 23:14:46 UTC (rev 70192)
@@ -14,7 +14,7 @@
 SCRIPTEXT = .py
 BATFILES  := $(patsubst %,$(BIN)/g.gui.%.bat,$(MODULES))
 else
-SCRIPTEXT = 
+SCRIPTEXT =
 BATFILES =
 endif
 PYFILES  := $(patsubst %,$(SCRIPTDIR)/g.gui.%$(SCRIPTEXT),$(MODULES))
@@ -25,12 +25,12 @@
 	$(MAKE) $(GUIHTML)
 
 $(HTMLDIR)/g.gui.%.html: g.gui.%.html g.gui.%.tmp.html | $(HTMLDIR)
-	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) \
+	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) MODULE_TOPDIR=$(MODULE_TOPDIR) \
         $(PYTHON) $(GISBASE)/tools/mkhtml.py g.gui.$* $(GRASS_VERSION_DATE) > $@
 
 $(HTMLDIR)/wxGUI.%.html: g.gui.%.html | $(HTMLDIR)
 	-rm -f g.gui.$*.tmp.html
-	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) \
+	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) MODULE_TOPDIR=$(MODULE_TOPDIR) \
         $(PYTHON) $(GISBASE)/tools/mkhtml.py g.gui.$* $(GRASS_VERSION_DATE) > $@
 
 g.gui.%.tmp.html: $(SCRIPTDIR)/g.gui.%

Modified: grass/branches/releasebranch_7_0/include/Make/Html.make
===================================================================
--- grass/branches/releasebranch_7_0/include/Make/Html.make	2017-01-01 21:55:46 UTC (rev 70191)
+++ grass/branches/releasebranch_7_0/include/Make/Html.make	2017-01-01 23:14:46 UTC (rev 70192)
@@ -4,7 +4,7 @@
 include $(MODULE_TOPDIR)/include/Make/HtmlRules.make
 
 $(HTMLDIR)/%.html: %.html %.tmp.html $(HTMLSRC) $(IMGDST) | $(HTMLDIR)
-	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) \
+	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) MODULE_TOPDIR=$(MODULE_TOPDIR) \
         $(PYTHON) $(GISBASE)/tools/mkhtml.py $* > $@
 
 $(MANDIR)/%.$(MANSECT): $(HTMLDIR)/%.html

Modified: grass/branches/releasebranch_7_0/tools/mkhtml.py
===================================================================
--- grass/branches/releasebranch_7_0/tools/mkhtml.py	2017-01-01 21:55:46 UTC (rev 70191)
+++ grass/branches/releasebranch_7_0/tools/mkhtml.py	2017-01-01 23:14:46 UTC (rev 70192)
@@ -22,12 +22,15 @@
 import re
 from datetime import datetime
 from HTMLParser import HTMLParser
+import urlparse
 
 pgm = sys.argv[1]
 
 src_file = "%s.html" % pgm
 tmp_file = "%s.tmp.html" % pgm
 
+source_url = "https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/"
+
 header_base = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
@@ -53,7 +56,13 @@
 <em><b>${PGM}</b></em> - ${PGM_DESC}
 """
 
-footer_index = string.Template(\
+sourcecode = string.Template(
+"""<h2>SOURCE CODE</h2>
+<p>Available at: <a href="${URL_SOURCE}">${PGM} source code</a> (<a href="${URL_LOG}">history</a>)</p>
+"""
+)
+
+footer_index = string.Template(
 """<hr class="header">
 <p>
 <a href="index.html">Main index</a> |
@@ -73,7 +82,7 @@
 </html>
 """)
 
-footer_noindex = string.Template(\
+footer_noindex = string.Template(
 """<hr class="header">
 <p>
 <a href="index.html">Main index</a> |
@@ -287,11 +296,18 @@
 if not year:
     year = str(datetime.now().year)
 
+# check the names of scripts to assign the right folder
+topdir = os.path.abspath(os.getenv("MODULE_TOPDIR"))
+curdir = os.path.abspath(os.path.curdir)
+pgmdir = curdir.replace(topdir, '').lstrip('/')
+url_source = urlparse.urljoin(source_url, pgmdir)
+
 if index_name:
+    sys.stdout.write(sourcecode.substitute(URL_SOURCE=url_source, PGM=pgm,
+                                           URL_LOG=url_source.replace('browser',  'log')))
     sys.stdout.write(footer_index.substitute(INDEXNAME=index_name,
                                              INDEXNAMECAP=index_name_cap,
-                                             YEAR=year,
-                                             GRASS_VERSION=grass_version))
+                                             YEAR=year, GRASS_VERSION=grass_version))
 else:
     sys.stdout.write(footer_noindex.substitute(YEAR=year,
                                                GRASS_VERSION=grass_version))



More information about the grass-commit mailing list