[GRASS-dev] [GRASS GIS] #2864: Add link to source code in the documentation pages.

GRASS GIS trac at osgeo.org
Tue Jan 12 04:52:49 PST 2016


#2864: Add link to source code in the documentation pages.
--------------------------+----------------------------------
  Reporter:  pmav99       |      Owner:  grass-dev@…
      Type:  enhancement  |     Status:  new
  Priority:  normal       |  Milestone:  7.0.4
 Component:  Docs         |    Version:  svn-releasebranch70
Resolution:               |   Keywords:  open science, access
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+----------------------------------

Comment (by pmav99):

 Thank you all,
 As far as I am concerned, the two lines seems cleaner to me. Now with
 regard to the link itself.

 1. I am not sure if hard-coding the link to trunk is the best option.
 Since the documentation of multiple GRASS versions are online (i.e. 6.4,
 7.0, 7.1) I think that the link should point to the respective branch.
 2. Since I guess that many users like myself don't have any particular
 knowledge of the GRASS code structure, in order to make this even more
 useful I think that the links themselves should directly point to the
 directory that contains the command in question.

 I think that these two goals are not too hard to be achieved. E.g.
 assuming that we know on which branch we are something like this would
 give as a dictionary mapping each command to the correct link (you need to
 execute it from the repository's root directory.
 {{{
 import os, fnmatch, urlparse

 grass_branch = 70
 grass_base_dir = "."
 branch_source_url = {
     64:
 "https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/",
     70:
 "https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/",
     71: "https://trac.osgeo.org/grass/browser/grass/trunk/",
 }
 base_url = branch_source_url[grass_branch]

 grass_command_paths = {}
 grass_command_pattern = r'[a-zA-Z0-9]*.[a-zA-Z0-9]*'
 for root, dirs, files in os.walk(grass_base_dir):
     for name in dirs:
         if fnmatch.fnmatch(name, grass_command_pattern):
             grass_command_paths[name] = urlparse.urljoin(base_url,
 os.path.join(root, name))

 from pprint import pprint
 pprint(grass_command_paths)
 }}}

 Expected output:
 {{{
 {'English.lproj':
 'https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/macosx/app/English.lproj',
  'MainMenu.nib':
 'https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/macosx/app/English.lproj/MainMenu.nib',
  'd.barscale':
 'https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/display/d.barscale',
  'd.colorlist':
 'https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/display/d.colorlist',
  'd.colortable':
 'https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/display/d.colortable',
  'd.correlate':
 'https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/scripts/d.correlate',
  # ...
 }
 }}}

 Mind you that there are a few false positives, but they should not be a
 problem since `pgm` in
 `mkhtml.py` will not match them. Of course, making the regex stricter is
 always possible.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2864#comment:8>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list