فهرست منبع

generate TOC also for full_index

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59831 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 سال پیش
والد
کامیت
6d2ba7954d
2فایلهای تغییر یافته به همراه44 افزوده شده و 41 حذف شده
  1. 20 13
      man/build_full_index.py
  2. 24 28
      man/build_html.py

+ 20 - 13
man/build_full_index.py

@@ -15,33 +15,40 @@ if len(sys.argv) > 1:
 
 os.chdir(html_dir)
 
+class_labels = {
+    'd' : 'display',
+    'db' : 'database',
+    'g' : 'general',
+    'i' : 'imagery',
+    'm' : 'miscellaneous',
+    'ps' : 'postscript',
+    'r' : 'raster',
+    'r3' : '3d raster',
+    't' : 'temporal',
+    'v' : 'vector'
+}
+
 classes = []
 for cmd in html_files('*'):
     prefix = cmd.split('.')[0]
-    if prefix not in classes:
-	classes.append(prefix)
-classes.sort()
+    if prefix not in [item[0] for item in classes]:
+	classes.append((prefix, class_labels.get(prefix, prefix)))
+classes.sort(key=lambda tup: tup[0])
 
 #begin full index:
 filename = "full_index.html"
 f = open(filename + ".tmp", 'wb')
 
-write_html_header(f, "GRASS GIS %s Reference Manual: Full index" % grass_version)
+write_html_header(f, "GRASS GIS %s Reference Manual: Full index" % grass_version, body_width="80%")
 
 #generate main index of all modules:
 f.write(full_index_header)
-#"
-
-for cls in classes:
-    f.write(cmd1_tmpl.substitute(cmd = cls))
-    if cls != classes[-1]:
-	f.write(" | ")
 
-f.write(sections)
+f.write(toc)
 
 #for all module groups:
-for cls in classes:
-    f.write(cmd2_tmpl.substitute(cmd = cls))
+for cls, cls_label in classes:
+    f.write(cmd2_tmpl.substitute(cmd_label = cls_label.title(), cmd = cls))
     #for all modules:  
     for cmd in html_files(cls):
 	basename = os.path.splitext(cmd)[0]

+ 24 - 28
man/build_html.py

@@ -48,7 +48,7 @@ r"""
 header2_tmpl = string.Template(\
 r""" <link rel="stylesheet" href="grassdocs.css" type="text/css">
 </head>
-<body style="width: 99%">
+<body style="width: ${body_width}">
 
 <!-- this file is generated by man/build_html.py -->
 
@@ -174,13 +174,9 @@ r"""<hr class="header">
 """)
 #"
 
-cmd1_tmpl = string.Template(\
-r"""<b><a href="#${cmd}">${cmd}.*</a></b>""")
-#"
-
 cmd2_tmpl = string.Template(\
 r"""<a name="${cmd}"></a>
-<h3>${cmd}.* commands:</h3>
+<h3>${cmd_label} commands (${cmd}.*)</h3>
 <table>
 """)
 #"
@@ -190,23 +186,24 @@ r"""<tr><td valign="top"><a href="${cmd}">${basename}</a></td> <td>${desc}</td><
 """)
 #"
 
-sections = \
-r""" ]
-<table border=0>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#d">d.*</a> </td><td>display commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#db">db.*</a> </td><td>database commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#g">g.*</a> </td><td>general commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#i">i.*</a> </td><td>imagery commands</td></tr>
-
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#m">m.*</a> </td><td>miscellaneous commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#ps">ps.*</a> </td><td>postscript commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#r">r.*</a> </td><td>raster commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#r3">r3.*</a> </td><td>raster3D commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#t">t.*</a> </td><td>temporal commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="full_index.html#v">v.*</a> </td><td>vector commands</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="wxGUI.Nviz.html">nviz</a> </td><td>visualization suite</td></tr>
-<tr><td>&nbsp;&nbsp;<a href="wxGUI.html">wxGUI</a> </td><td>wxPython-based GUI frontend</td></tr>
-</table>
+toc = \
+r"""
+<div class="toc">
+<ul class="toc">
+<li class="toc"\><a class="toc" href="full_index.html#d">Display commands (d.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#db">Database commands (db.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#g">General commands (g.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#i">Imagery commands (i.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#m">Miscellaneous commands (m.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#ps">PostScript commands (ps.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#r">Raster commands (r.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#r3">3d raster commands (r3.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#t">Temporal commands (t.*)</a></li>
+<li class="toc"\><a class="toc" href="full_index.html#v">Vector commands (v.*)</a></li>
+<li class="toc"\><a class="toc" href="wxGUI.html">wxGUI Graphical User Interface</a></li>
+<li class="toc"\><a class="toc" href="wxGUI.nviz.html">3D visualization suite</a></li>
+</ul>
+</div>
 """
 #"
 
@@ -229,9 +226,8 @@ r"""<tr><td valign="top"><a href="${cmd}">${basename}</a></td> <td>${desc}</td><
 
 
 full_index_header = \
-r"""Go <a href="index.html">back to help overview</a>
-<h3>Full command index:</h3>
-[ 
+r"""
+Go <a href="index.html">back to help overview</a>
 """
 #"
 
@@ -335,12 +331,12 @@ def html_files(cls = None):
            not cmd.startswith("wxGUI."):
             yield cmd
 
-def write_html_header(f, title, ismain = False):
+def write_html_header(f, title, ismain = False, body_width = "99%"):
     f.write(header1_tmpl.substitute(title = title))
     if ismain and macosx:
         f.write(macosx_tmpl.substitute(grass_version = grass_version,
                                        grass_mmver = grass_mmver))
-    f.write(header2_tmpl.substitute(grass_version = grass_version))
+    f.write(header2_tmpl.substitute(grass_version = grass_version, body_width = body_width))
 
 def write_html_cmd_overview(f):
     box_color = "#e1ecd0"