Bladeren bron

improved parser standard option to have a better output table, added it to Makefile; TODO add link to a GRASS manual

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66263 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 9 jaren geleden
bovenliggende
commit
ce8963b0a9

+ 27 - 3
man/Makefile

@@ -7,7 +7,10 @@ MANPAGES := $(patsubst $(HTMLDIR)/%.html,$(MANDIR)/%.$(MANSECT),$(wildcard $(HTM
 DSTFILES := \
 	$(HTMLDIR)/grassdocs.css \
 	$(HTMLDIR)/grass_logo.png \
-	$(HTMLDIR)/grass_icon.png
+	$(HTMLDIR)/grass_icon.png \
+	$(HTMLDIR)/jquery.fixedheadertable.min.js \
+	$(HTMLDIR)/parser_standard_options.css \
+	$(HTMLDIR)/parser_standard_options.js
 
 categories = \
 	d:display \
@@ -23,7 +26,7 @@ categories = \
 
 IDXCATS := $(foreach cat,$(categories),$(lastword $(subst :, ,$(cat))))
 
-IDXSRC = full_index index topics keywords graphical_index manual_gallery class_graphical $(IDXCATS)
+IDXSRC = full_index index topics keywords graphical_index manual_gallery class_graphical parser_standard_options $(IDXCATS)
 
 INDICES := $(patsubst %,$(HTMLDIR)/%.html,$(IDXSRC))
 
@@ -79,6 +82,15 @@ GISBASE="$(RUN_GISBASE)" ARCH="$(ARCH)" ARCH_DISTDIR="$(ARCH_DISTDIR)" \
 	$(PYTHON) ./build_manual_gallery.py $(HTMLDIR)
 endef
 
+define build_pso
+GISBASE="$(RUN_GISBASE)" ARCH="$(ARCH)" ARCH_DISTDIR="$(ARCH_DISTDIR)" \
+	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) \
+	$(PYTHON) ./parser_standard_options.py -t $(MODULE_TOPDIR)/lib/gis/parser_standard_options.c \
+	-f grass -o $(HTMLDIR)/parser_standard_options.html -p 'id="opts_table" class="scroolTable"'
+endef
+
+$(HTMLDIR)/topics.html: $(ALL_HTML)
+
 define build_class_graphical
 GISBASE="$(RUN_GISBASE)" ARCH="$(ARCH)" ARCH_DISTDIR="$(ARCH_DISTDIR)" \
 	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) \
@@ -101,12 +113,16 @@ $(HTMLDIR)/keywords.html: $(ALL_HTML)
 	$(call build_keywords)
 	touch $@
 
+
 $(HTMLDIR)/graphical_index.html: $(ALL_HTML)
 	$(call build_graphical_index)
 	touch $@
 
 $(HTMLDIR)/manual_gallery.html: $(ALL_HTML)
-	$(call build_manual_gallery)
+       $(call build_manual_gallery)
+
+$(HTMLDIR)/parser_standard_options.html: $(ALL_HTML)
+	$(call build_pso)
 	touch $@
 
 # TODO: this should be done in the same way as category_rule
@@ -131,3 +147,11 @@ $(HTMLDIR)/grass_logo.png: grass_logo.png
 $(HTMLDIR)/grass_icon.png: grass_icon.png
 	$(INSTALL_DATA) $< $@
 
+$(HTMLDIR)/jquery.fixedheadertable.min.js: jquery.fixedheadertable.min.js
+	$(INSTALL_DATA) $< $@
+
+$(HTMLDIR)/parser_standard_options.js: parser_standard_options.js
+	$(INSTALL_DATA) $< $@
+
+$(HTMLDIR)/parser_standard_options.css: parser_standard_options.css
+	$(INSTALL_DATA) $< $@

+ 18 - 0
man/build_html.py

@@ -322,6 +322,24 @@ r"""
 """)
 #"
 
+headerpso_tmpl = \
+r"""
+<link rel="stylesheet" href="grassdocs.css" type="text/css">
+<link rel="stylesheet" href="parser_standard_options.css" type="text/css">
+<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
+<script type="text/javascript" src="jquery.fixedheadertable.min.js"></script>
+<script type="text/javascript" src="parser_standard_options.js"></script>
+</head>
+<body style="width: 99%">
+<div id="container">
+
+<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
+<hr class="header">
+<h2>Parser standard options</h2>
+<ul>
+"""
+#"
+
 ############################################################################
 
 def check_for_desc_override(basename):

File diff suppressed because it is too large
+ 19 - 0
man/jquery.fixedheadertable.min.js


+ 172 - 0
man/parser_standard_options.css

@@ -0,0 +1,172 @@
+/*!
+* jquery.fixedHeaderTable. The jQuery fixedHeaderTable plugin
+*
+* Copyright (c) 2011 Mark Malek
+* http://fixedheadertable.com
+*
+* Licensed under MIT
+* http://www.opensource.org/licenses/mit-license.php
+*
+* http://docs.jquery.com/Plugins/Authoring
+* jQuery authoring guidelines
+*
+* Launch  : October 2009
+* Version : 1.3
+* Released: May 9th, 2011
+*
+*
+* all CSS sizing (width,height) is done in pixels (px)
+*/
+
+/* @group Reset */
+
+.fht-table,
+.fht-table thead,
+.fht-table tfoot,
+.fht-table tbody,
+.fht-table tr,
+.fht-table th,
+.fht-table td {
+        /* position */
+    margin: 0;
+
+    /* size */
+        padding: 0;
+
+        /* text */
+        font-size: 100%;
+        font: inherit;
+        vertical-align: top;
+        }
+
+.fht-table {
+        /* appearance */
+    border-collapse: collapse;
+    border-spacing: 0;
+        }
+
+/* @end */
+
+/* @group Content */
+
+.fht-table-wrapper,
+.fht-table-wrapper .fht-thead,
+.fht-table-wrapper .fht-tfoot,
+.fht-table-wrapper .fht-fixed-column .fht-tbody,
+.fht-table-wrapper .fht-fixed-body .fht-tbody,
+.fht-table-wrapper .fht-tbody {
+        /* appearance */
+        overflow: hidden;
+
+        /* position */
+        position: relative;
+        }
+
+        .fht-table-wrapper .fht-fixed-body .fht-tbody,
+        .fht-table-wrapper .fht-tbody {
+                /* appearance */
+            overflow: auto;
+                }
+
+                .fht-table-wrapper .fht-table .fht-cell {
+                        /* appearance */
+                        overflow: hidden;
+
+                        /* size */
+                    height: 1px;
+                        }
+
+        .fht-table-wrapper .fht-fixed-column,
+        .fht-table-wrapper .fht-fixed-body {
+            /* position */
+            top: 0;
+            left: 0;
+            position: absolute;
+            }
+
+        .fht-table-wrapper .fht-fixed-column {
+            /* position */
+            z-index: 1;
+            }
+
+/* @end */
+
+.scroolTable td, .scroolTable th {
+        /* appearance */
+        border: 1px solid #778899;
+
+        /* size */
+        padding: 5px;
+        }
+
+.scroolTable {
+        /* text */
+        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+        }
+
+.scroolTable tbody tr td {
+        /* appearance */
+        background-color: rgb(100%, 100%, 100%);
+        background-image: -moz-linear-gradient(
+                top,
+                rgba(255,255,255,0.4) 0%,
+                rgba(255,255,255,0.2) 50%,
+                rgba(255,255,255,0.1) 51%,
+                rgba(255,255,255,0.0) 100%);
+
+        background-image: -webkit-gradient(
+                linear, left top, left bottom,
+                color-stop(0%,rgba(255,255,255,0.4)),
+                color-stop(50%,rgba(255,255,255,0.2)),
+                color-stop(51%,rgba(255,255,255,0.1)),
+                color-stop(100%,rgba(255,255,255,0.0)));
+
+        /* text */
+        color: #262c31;
+        font-size: 11px;
+        }
+
+.scroolTable tbody tr.odd td {
+        /* appearance */
+        background-color: #d6e0ef;
+        background-image: -moz-linear-gradient(
+                top,
+                rgba(255,255,255,0.4) 0%,
+                rgba(255,255,255,0.2) 50%,
+                rgba(255,255,255,0.1) 51%,
+                rgba(255,255,255,0.0) 100%);
+
+        background-image: -webkit-gradient(
+                linear, left top, left bottom,
+                color-stop(0%,rgba(255,255,255,0.4)),
+                color-stop(50%,rgba(255,255,255,0.2)),
+                color-stop(51%,rgba(255,255,255,0.1)),
+                color-stop(100%,rgba(255,255,255,0.0)));
+        }
+
+.scroolTable thead tr th,
+.scroolTable thead tr td,
+.scroolTable tfoot tr th,
+.scroolTable tfoot tr td {
+        /* appearance */
+        background-color: rgb(25%, 60%, 25%);
+        background-image: -moz-linear-gradient(
+                top,
+                rgba(255,255,255,0.4) 0%,
+                rgba(255,255,255,0.2) 50%,
+                rgba(255,255,255,0.1) 51%,
+                rgba(255,255,255,0.0) 100%);
+
+        background-image: -webkit-gradient(
+                linear, left top, left bottom,
+                color-stop(0%,rgba(255,255,255,0.4)),
+                color-stop(50%,rgba(255,255,255,0.2)),
+                color-stop(51%,rgba(255,255,255,0.1)),
+                color-stop(100%,rgba(255,255,255,0.0)));
+
+        /* text */
+        color: #121517;
+        font-size: 12px;
+        font-weight: bold;
+        text-shadow: 0 1px 1px #e8ebee;
+        }

+ 4 - 0
man/parser_standard_options.js

@@ -0,0 +1,4 @@
+$(document).ready(function() {
+  $('#opts_table').fixedHeaderTable({footer: false, cloneHeadToFoot: true,
+                                     fixedColumn: true});
+});

+ 26 - 8
tools/parser_standard_options.py

@@ -6,10 +6,9 @@ Created on Fri Jun 26 19:10:58 2015
 """
 from __future__ import print_function
 import argparse
-from pprint import pprint
 import sys
 from urllib import urlopen
-
+from build_html import *
 
 def parse_options(lines, startswith='Opt'):
     def split_in_groups(lines):
@@ -108,13 +107,16 @@ class OptTable(object):
 
     def html(self, endline='\n', indent='  ', toptions='border=1'):
         """Return a HTML table with the options"""
-        html = ["<table{}>".format(' ' + toptions if toptions else '')]
+        html = ['<table{}>'.format(' ' + toptions if toptions else '')]
         # write headers
+        html.append(indent + "<thead>")
         html.append(indent + "<tr>")
-        html.append(indent * 2 + "<td>{0}</td>".format('option'))
+        html.append(indent * 2 + "<th>{0}</th>".format('option'))
         for col in self.columns:
-            html.append(indent * 2 + "<td>{0}</td>".format(col))
+            html.append(indent * 2 + "<th>{0}</th>".format(col))
         html.append(indent + "</tr>")
+        html.append(indent + "</thead>")
+        html.append(indent + "<tbody>")
         for optname, options in self.options:
             html.append(indent + "<tr>")
             html.append(indent * 2 + "<td>{0}</td>".format(optname))
@@ -122,6 +124,7 @@ class OptTable(object):
                 html.append(indent * 2 +
                             "<td>{0}</td>".format(options.get(col, '')))
             html.append(indent + "</tr>")
+        html.append(indent + "</tbody>")
         html.append("</table>")
         return endline.join(html)
 
@@ -136,7 +139,7 @@ if __name__ == "__main__":
     parser = argparse.ArgumentParser(description='Extract GRASS default '
                                                  'options from link.')
     parser.add_argument('-f', '--format', default='html', dest='format',
-                        choices=['html', 'csv'],
+                        choices=['html', 'csv', 'grass'],
                         help='Define the output format')
     parser.add_argument('-l', '--link', default=URL, dest='url', type=str,
                         help='Provide the url with the file to parse')
@@ -149,11 +152,26 @@ if __name__ == "__main__":
     parser.add_argument('-s', '--starts-with', default='Opt',
                         dest='startswith', type=str,
                         help='Extract only the options that starts with this')
+    parser.add_argument('-p', '--html_params', default='border=1', type=str,
+                        dest='htmlparmas', help="Options for the HTML table")
     args = parser.parse_args()
 
     cfile = args.text if args.text else urlopen(args.url, proxies=None)
 
     options = OptTable(parse_options(cfile.readlines(),
                                      startswith=args.startswith))
-    print(getattr(options, args.format)(), file=args.output)
-    args.output.close()
+    outform = args.format
+    if outform in ['csv', 'html']:
+        print(getattr(options, outform)(), file=args.output)
+        args.output.close()
+    else:
+        year = os.getenv("VERSION_DATE")
+        name = args.output.name
+        args.output.close()
+        topicsfile = open(name, 'w')
+        topicsfile.write(header1_tmpl.substitute(title="GRASS GIS " \
+                        "%s Reference Manual: Parser standard options index" % grass_version))
+        topicsfile.write(headerpso_tmpl)
+        topicsfile.write(options.html(toptions=args.htmlparmas))
+        write_html_footer(topicsfile, "index.html", year)
+        topicsfile.close()