Commits

Anonymous committed e1e44fc

move css from template to external file, dump procedure to file

Comments (0)

Files changed (1)

 body
 {
         width:578px;
-        margin:0px auto 0px 36px;
+        margin:24px auto 0px 36px;
 }
 
 p, table
         text-align:center;
 }
 
+h1
+{
+        margin-top:0px;
+}
+
 h1, h4
 {
         margin-bottom:0px;
         </body>
 </html>
 """
-INDEX_TEMPLATE = ""
+TR_HTML = """
+                                <tr ${class}>
+                                        <td>
+                                                ${type}
+                                        </td>
+                                        <td>
+                                                ${name}
+                                        </td>
+                                        <td>
+                                                ${desc}
+                                        </td>
+                                </tr>
+
+"""
+INDEX_TEMPLATE = """
+"""
+
+def escape(html):
+    """
+    Returns the given HTML with ampersands, quotes and angle brackets encoded.
+
+    Based on code in: Django
+    """
+    html = force_unicode(html)
+    html = html.replace('&', '&amp;')
+    html = html.replace('<', '&lt;')
+    html = html.replace('>', '&gt;')
+    html = html.replace('"', '&quot;')
+    html = html.replace("'", '&#39;')
+
+    return html
 
 def slugify(value):
     """
 
         return None
 
-def dump_proc(proc, outFile, mode) :
+def var_type_str(t) :
 
-        from gimpfu import *
+        if (PF_INT8 == t) :
+                return "PF_INT8"
+        if (PF_INT16 == t) :
+                return "PF_INT16"
+        if (PF_INT32 == t) :
+                return "PF_INT32"
+        if (PF_INT == t) :
+                return "PF_INT"
+        if (PF_FLOAT == t) :
+                return "PF_FLOAT"
+        if (PF_STRING == t) :
+                return "PF_STRING"
+        if (PF_VALUE == t) :
+                return "PF_VALUE"
+        if (PF_COLOR == t) :
+                return "PF_COLOR"
+        if (PF_COLOUR == t) :
+                return "PF_COLOUR"
+        """
+        in the documentation, but not defined in gimpfu
+        if (PF_REGION == t) :
+                return "PF_REGION"
+        """
+        if (PF_IMAGE == t) :
+                return "PF_IMAGE"
+        if (PF_LAYER == t) :
+                return "PF_LAYER"
+        if (PF_CHANNEL == t) :
+                return "PF_CHANNEL"
+        if (PF_DRAWABLE == t) :
+                return "PF_DRAWABLE"
+        if (PF_TOGGLE == t) :
+                return "PF_TOGGLE"
+        if (PF_BOOL == t) :
+                return "PF_BOOL"
+        if (PF_RADIO == t) :
+                return "PF_RADIO"
+        if (PF_SLIDER == t) :
+                return "PF_SLIDER"
+        if (PF_SPINNER == t) :
+                return "PF_SPINNER"
+        if (PF_ADJUSTMENT == t) :
+                return "PF_ADJUSTMENT"
+        if (PF_FONT == t) :
+                return "PF_FONT"
+        if (PF_FILE == t) :
+                return "PF_FILE"
+        if (PF_BRUSH == t) :
+                return "PF_BRUSH"
+        if (PF_PATTERN == t) :
+                return "PF_PATTERN"
+        if (PF_GRADIENT == t) :
+                return "PF_GRADIENT"
+        if (PF_PALETTE == t) :
+                return "PF_PALETTE"
 
+        return "unknown"
+
+def proc_type_str(t) :
+        if (PLUGIN == t) :
+                return "PROC_PLUG_IN"
+        if (EXTENSION == t) :
+                return "PROC_EXTENSION"
+        if (TEMPORARY == t) :
+                return "PROC_TEMPORARY"
+
+        return "unknown"
+
+def dump_table(lst) :
+        row = dict()
+        html = ""
+        alt = False
+        for item in lst :
+                row["class"] = ""
+                if (True == alt) :
+                        row["class"] = ' class="alt"'
+                row["type"] = var_type_str(item[0])
+                row["name"] = item[1]
+                row["desc"] = item[2]
+
+                html += Template(TR_HTML).safe_substitute(row)
+                alt = not alt
+
+        return html
+
+def dump_proc(proc, outFile, mode, links) :
         d = dict()
+
+        d["prev_link"] = links[0]
+        d["index_link"] = links[1]
+        d["next_link"] = links[2]
+
         d["proc_name"] = proc.proc_name
         d["proc_author"] = proc.proc_author
         d["proc_date"] = proc.proc_date
         d["proc_copyright"] = proc.proc_copyright
         d["proc_blurb"] = proc.proc_blurb
         d["proc_help"] = proc.proc_help
+        d["proc_type"] = proc_type_str(proc.proc_type)
 
-        d["proc_type"] = "unknown"
-        if (PLUGIN == proc.proc_type) :
-                d["proc_type"] = "PROC_PLUG_IN"
-        elif (EXTENSION == proc.proc_type) :
-                d["proc_type"] = "PROC_EXTENSION"
-        elif (TEMPORARY == proc.proc_type) :
-                d["proc_type"] = "PROC_TEMPORARY"
+        d["parameters"] = dump_table(proc.params)
+        d["results"] = dump_table(proc.return_vals)
 
         with open(outFile, mode) as f :
                 f.write(Template(PROC_HTML).safe_substitute(d))
                 name = procs[i]
                 outFile = os.path.join(
                         outDirectory,
-                        "%s%s"%(slugify(name), ".html")
+                        "%s.html"%(slugify(name))
                 )
+                
+                links = list()
+                if (0 < i) :
+                        link = "%s.html"%(slugify(procs[i-1]))
+                        links.append(link)
+                else :
+                        links.append("")
 
-                dump_proc(pdb[name], outFile, 'w+')
-                break
+                links.append("../index.html")
+
+                if (len(procs) - 1 >  i) :
+                        link = "%s.html"%(slugify(procs[i+1]))
+                        links.append(link)
+                else :
+                        links.append("")
+
+                dump_proc(pdb[name], outFile, 'w+', links)
+                #break
 
         # write index file