Переглянути джерело

g.manual: add flag to display topics

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54551 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 роки тому
батько
коміт
4c9cbc862c
2 змінених файлів з 39 додано та 21 видалено
  1. 13 6
      scripts/g.manual/g.manual.html
  2. 26 15
      scripts/g.manual/g.manual.py

+ 13 - 6
scripts/g.manual/g.manual.html

@@ -5,21 +5,27 @@ format.
 
 <h2>NOTES</h2>
 
-The name of the HTML browser is defined in the environment variable
+The name of the browser is defined in the environment variable
 <tt>GRASS_HTML_BROWSER</tt>. For most platforms this should be an
 executable in your PATH, or the full path to an executable. See
 <a href="variables.html">variables</a> for details.
 
 <h2>EXAMPLES</h2>
 
+Show index page in the browser.
+
 <div class="code"><pre>
-# how index
-g.manual index
+g.manual -i
+</pre></div>
 
-# show module manual page in HTML browser
+Show manual page of <em><a href="d.vect.html">d.vect</a></em> module
+in the browser.
+<div class="code"><pre>
 g.manual d.vect
+</pre></div>
 
-# show module manual page in terminal
+Show module manual page in terminal.
+<div class="code"><pre>
 g.manual -m d.vect
 </pre></div>
 
@@ -27,4 +33,5 @@ g.manual -m d.vect
 
 Markus Neteler
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

+ 26 - 15
scripts/g.manual/g.manual.py

@@ -6,7 +6,7 @@
 # AUTHOR(S):	Markus Neteler
 #               Converted to Python by Glynn Clements
 # PURPOSE:	Display the HTML/MAN pages
-# COPYRIGHT:	(C) 2003, 2008, 2010 by the GRASS Development Team
+# COPYRIGHT:	(C) 2003, 2008, 2010-2012 by the GRASS Development Team
 #
 #		This program is free software under the GNU General Public
 #		License (>=v2). Read the file COPYING that comes with GRASS
@@ -15,7 +15,7 @@
 #############################################################################
 
 #%module
-#% description: Display the HTML manual pages of GRASS modules
+#% description: Displays the manual pages of GRASS modules.
 #% keywords: general
 #% keywords: manual
 #% keywords: help
@@ -26,6 +26,11 @@
 #% suppress_required: yes
 #%end
 #%flag
+#% key: t
+#% description: Display topics
+#% suppress_required: yes
+#%end
+#%flag
 #% key: m
 #% description: Display as MAN text page instead of HTML page in browser
 #%end
@@ -70,13 +75,25 @@ def start_man(entry):
 def main():
     global gisbase, browser, browser_name
     
-    index  = flags['i']
-    manual = flags['m']
+    if flags['i'] and flags['t']:
+        grass.fatal(_("Flags -%c and -%c are mutually exclusive") % ('i', 't'))
+    
+    special = None
+    if flags['i']:
+        special = 'index'
+    elif flags ['t']:
+        special = 'topics'
+    
+    if flags['m']:
+        start = start_man
+    else:
+        start = start_browser
+    
     entry  = options['entry']
     
     gisbase = os.environ['GISBASE']
     
-    browser = os.getenv('GRASS_HTML_BROWSER')
+    browser = os.getenv('GRASS_HTML_BROWSER', '')
     
     if sys.platform == 'darwin':
         # hack for MacOSX
@@ -89,17 +106,11 @@ def main():
     
     # keep order!
     # first test for index...
-    if index:
-	if manual:
-	    start_man('index')
-	else:
-	    start_browser('index')
-        return 0
-    
-    if manual:
-	start_man(entry)
+    if special:
+        start(special)
     else:
-	start_browser(entry)
+        start(entry)
+    
     return 0
 
 if __name__ == "__main__":