Browse Source

documentation: add link to source code (see https://trac.osgeo.org/grass/ticket/2864) (backport from relbranch72 in order to get the link also into addon manual pages: https://trac.osgeo.org/grass/changeset/69290 + https://trac.osgeo.org/grass/changeset/67566)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@70192 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 8 years ago
parent
commit
ec9c99d508
3 changed files with 24 additions and 8 deletions
  1. 3 3
      include/Make/GuiScript.make
  2. 1 1
      include/Make/Html.make
  3. 20 4
      tools/mkhtml.py

+ 3 - 3
include/Make/GuiScript.make

@@ -14,7 +14,7 @@ ifdef MINGW
 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 @@ guiscript: $(IMGDST) $(PYFILES) $(BATFILES)
 	$(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.%

+ 1 - 1
include/Make/Html.make

@@ -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

+ 20 - 4
tools/mkhtml.py

@@ -22,12 +22,15 @@ import string
 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 @@ header_pgm_desc = """<h2>NAME</h2>
 <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 @@ GRASS GIS ${GRASS_VERSION} Reference Manual
 </html>
 """)
 
-footer_noindex = string.Template(\
+footer_noindex = string.Template(
 """<hr class="header">
 <p>
 <a href="index.html">Main index</a> |
@@ -287,11 +296,18 @@ year = os.getenv("VERSION_DATE")
 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))