qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jr...@apache.org
Subject [1/3] qpid-site git commit: Interactive spec maintenance - add ascii art diagrams
Date Wed, 15 Aug 2018 12:39:14 GMT
Repository: qpid-site
Updated Branches:
  refs/heads/asf-site f17c8263f -> cc6f81e8f


http://git-wip-us.apache.org/repos/asf/qpid-site/blob/cc6f81e8/scripts/gen-amqp-type-reference
----------------------------------------------------------------------
diff --git a/scripts/gen-amqp-type-reference b/scripts/gen-amqp-type-reference
index daedc60..fb95eb4 100755
--- a/scripts/gen-amqp-type-reference
+++ b/scripts/gen-amqp-type-reference
@@ -38,7 +38,7 @@
 #
 
 from __future__ import print_function
-import sys, optparse, os, time
+import sys, optparse, os, time, cgi
 import xml.etree.ElementTree as ET
 
 #
@@ -127,6 +127,7 @@ class XmlStore():
         self.sections = self.root.findall("section")
         self.types = []
         self.definitions = []
+        self.pictures = []
         for section in self.sections:
             ltypes = section.findall("type")
             for type in ltypes:
@@ -160,7 +161,20 @@ class XmlStore():
                 definition.text = self.rootName + ":" + section.get("name")
                 definitionsAll.append(definition)
             self.definitions += section.findall("definition")
-        
+            sTitle = section.get("title")
+            if sTitle is None:
+                sTitle = ""
+            docs = section.findall("doc")
+            for doc in docs:
+                dTitle = doc.get("title")
+                if dTitle is None:
+                    dTitle = ""
+                pics = doc.findall("picture")
+                for pic in pics:
+                    pTitle = pic.get("title")
+                    pic.caption = (self.rootName.capitalize() + " : " + sTitle + " : " +
dTitle).strip()
+                    self.pictures.append(pic)
+
     def trimNamespace(self, node):
         ''' Strip out the "{amqp namespace}" ahead of each tag'''
         pos = node.tag.find("}")
@@ -169,6 +183,24 @@ class XmlStore():
         for child in node:
             self.trimNamespace(child)
 
+    def showPics(self):
+        nodeName = self.rootName.capitalize() + "Diag"
+        print("<a name=\"%sDiagrams\"</a><br>" % self.rootName.capitalize())
+        print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%s%s<br>"
%
+              ((nodeName), lozenge(), nbsp(), self.rootName.capitalize() + " Diagrams"))
+        print("<div style=\"display: none; margin-bottom: 2px; margin-left: 10px\" id=\"%s\">"
%
+              (nodeName))
+        for i in range(len(self.pictures)):
+            pic = self.pictures[i]
+            print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%s<strong>%s</strong><br>"
%
+                  ((nodeName + str(i)), lozenge(), nbsp(), pic.caption))
+            print("<div style=\"display: none; margin-bottom: 2px; margin-left: 10px\"
id=\"%s\">" %
+                  (nodeName + str(i)))
+            print("<pre>%s</pre><br>" % cgi.escape(pic.text))
+            print("</div>")
+        print("</div>")
+        print("<br>")
+
 file_dir = sys.argv[1]
 
 xmlTypes        = XmlStore(os.path.join(file_dir, "types.xml"))
@@ -177,6 +209,8 @@ xmlMessaging    = XmlStore(os.path.join(file_dir, "messaging.xml"))
 xmlSecurity     = XmlStore(os.path.join(file_dir, "security.xml"))
 xmlTransactions = XmlStore(os.path.join(file_dir, "transactions.xml"))
 
+xmlStoreList = [xmlTypes, xmlTransport, xmlMessaging, xmlTransactions, xmlSecurity]
+
 #
 # Utilities
 #
@@ -314,10 +348,16 @@ function go_back()
     print("{")
     print("  show_node('Constants');")
     print("  show_node('PrimTypeName');")
+    print("  show_node('PrimTypeCode');")
     print("  show_node('DescrTypes');")
     print("  show_node('EnumTypes');")
     print("  show_node('RestrTypes');")
     print("  show_node('ProvTypes');")
+    print("  show_node('TypesDiag');")
+    print("  show_node('TransportDiag');")
+    print("  show_node('MessagingDiag');")
+    print("  show_node('TransactionsDiag');")
+    print("  show_node('SecurityDiag');")
     print("  show_node('TypIndex');")
     print("  show_node('FldIndex');")
     print("  show_node('EnuIndex');")
@@ -333,10 +373,16 @@ function go_back()
     print("{")
     print("  hide_node('Constants');")
     print("  hide_node('PrimTypeName');")
+    print("  hide_node('PrimTypeCode');")
     print("  hide_node('DescrTypes');")
     print("  hide_node('EnumTypes');")
     print("  hide_node('RestrTypes');")
     print("  hide_node('ProvTypes');")
+    print("  hide_node('TypesDiag');")
+    print("  hide_node('TransportDiag');")
+    print("  hide_node('MessagingDiag');")
+    print("  hide_node('TransactionsDiag');")
+    print("  hide_node('SecurityDiag');")
     print("  hide_node('TypIndex');")
     print("  hide_node('FldIndex');")
     print("  hide_node('EnuIndex');")
@@ -361,6 +407,7 @@ def print_toc():
     print("%s%s<a href=\"#RestrictedTypes\">Restricted Types</a><br/>"
% (nbsp(), nbsp()))
     print("%s%s<a href=\"#DescribedTypes\">Described Types</a><br/>" %
(nbsp(), nbsp()))
     print("%s%s<a href=\"#ProvidedTypes\">Provided Types</a><br/>" % (nbsp(),
nbsp()))
+    print("<a href=\"#Diagrams\">Diagrams</a><br>")
     print("<a href=\"#Indices\">Indices</a><br/>")
     print("%s%s<a href=\"#TypeIndex\">Types</a><br/>" % (nbsp(), nbsp()))
     print("%s%s<a href=\"#FieldIndex\">Fields</a><br/>" % (nbsp(), nbsp()))
@@ -380,7 +427,7 @@ def print_constants():
     print("<a id=\"ConstantTypes\"></a>")
     print("<h2>Constants</h2>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sConstants<br/>"
% ("Constants", lozenge(), nbsp()))
-    print("<div style=\"display:none; margin-bottom: 2px\" id=\"Constants\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"Constants\">")
     print("<table>")
     print("<tr>")
     print(" <th>Section</th>")
@@ -438,7 +485,7 @@ def print_primitive_types():
     print("<a id=\"PrimitiveTypes\"></a>")
     print("<h3>Primitive Types</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sby Name<br/>"
% ("PrimTypeName", lozenge(), nbsp()))
-    print("<div style=\"display:none; margin-bottom: 2px\" id=\"PrimTypeName\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"PrimTypeName\">")
     print("<table>")
     print("<tr>")
     print(" <th>Section</th>")
@@ -491,7 +538,7 @@ def print_primitive_types():
 
     # print types sorted by class code
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sby Code<br/>"
% ("PrimTypeCode", lozenge(), nbsp()))
-    print("<div style=\"display:none; margin-bottom: 2px\" id=\"PrimTypeCode\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"PrimTypeCode\">")
     print("<table>")
     print("<tr>")
     print(" <th>Section</th>")
@@ -551,7 +598,7 @@ def print_described_types():
     print("<a id=\"DescribedTypes\"></a>")
     print("<h3>Described Types</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sDescribed Types<br/>"
% ("DescrTypes", lozenge(), nbsp()))
-    print("<div style=\"display:none; margin-bottom: 2px\" id=\"DescrTypes\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"DescrTypes\">")
     print("<table>")
     print("<tr>")
     print(" <th>Section</th>")
@@ -589,7 +636,7 @@ def print_described_types():
         print("<a id=\"details_%s\"></a>" % descr_typename)
         print("%s%s<a href=\"javascript:toggle_node('%s')\"> %s </a>%s %s<strong><a
href=\"#TYPE_%s\">%s</a></strong><br/>" % \
               (nbsp(), nbsp(), "DT"+descr_typename, lozenge(), nbsp(), "Described type: "
+ section + " - ", descr_typename, descr_typename))
-        print("<div style=\"display: none; margin-bottom: 2px\" id=\"%s\">" % ("DT"+descr_typename))
+        print("<div style=\"display: block; margin-bottom: 2px\" id=\"%s\">" % ("DT"+descr_typename))
         print("<table>")
         print("<tr>")
         print(" <th>Tag</th>")
@@ -667,7 +714,7 @@ def print_enumerated_types():
     print("<a id=\"EnumeratedTypes\"></a>")
     print("<h3>Enumerated Types</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sEnumerated Types<br/>"
% ("EnumTypes", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"EnumTypes\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"EnumTypes\">")
     print("<table>")
     print("<tr>")
     print(" <th>Section</th>")
@@ -698,7 +745,7 @@ def print_enumerated_types():
         print("<a id=\"details_%s\"></a>" % (enum_typename))
         print("%s%s<a href=\"javascript:toggle_node('%s')\"> %s </a>%s %s<strong><a
href=\"#TYPE_%s\">%s</a></strong><br/>" % \
               (nbsp(), nbsp(), "ET"+enum_typename, lozenge(), nbsp(), "Enumerated type: "
+ section + " - ", enum_typename, enum_typename))
-        print("<div style=\"display:none; margin-bottom: 2px\" id=\"%s\">" % ("ET"+enum_typename))
+        print("<div style=\"display: block; margin-bottom: 2px\" id=\"%s\">" % ("ET"+enum_typename))
         print("<table>")
         print("<tr>")
         print(" <th>Name</th>")
@@ -729,7 +776,7 @@ def print_restricted_types():
     print("<a id=\"RestrictedTypes\"></a>")
     print("<h3>Restricted Types</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sRestricted Types<br/>"
% ("RestrTypes", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"RestrTypes\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"RestrTypes\">")
     print("<table>")
     print("<tr>")
     print(" <th>Section</th>")
@@ -770,7 +817,7 @@ def print_provided_types():
     print("<a id=\"ProvidedTypes\"></a>")
     print("<h3>Provided Types</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sProvided Types<br/>"
% ("ProvTypes", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"ProvTypes\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"ProvTypes\">")
     print("<table>")
     print("<tr>")
     print(" <th>Provided Type</th>")
@@ -795,6 +842,18 @@ def print_provided_types():
         
 #
 #
+def print_asciiart():
+    print("<a id=\"Diagrams\"></a>")
+    print("<h2>Diagrams</h2>")
+    print("These diagrams may not make sense when taken out of the context of the ")
+    print("<a href=\"http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html\">")
+    print("AMQP 1.0 Specification</a>. Please refer to the spec to get the complete
narrative.<br>")
+    for x in xmlStoreList:
+        x.showPics()
+
+
+#
+#
 def print_type_index():
     typeNameIndex.sort()
     print("<a id=\"Indices\"></a>")
@@ -802,7 +861,7 @@ def print_type_index():
     print("<a id=\"TypeIndex\"></a>")
     print("<h3>Type Index</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sType Index<br/>"
% ("TypIndex", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"TypIndex\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"TypIndex\">")
     print("<table>")
     print("<tr>")
     print(" <th>Type Name</th>")
@@ -833,7 +892,7 @@ def print_field_index():
     print("<a id=\"FieldIndex\"></a>")
     print("<h3>Field Index</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sField Index<br/>"
% ("FldIndex", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"FldIndex\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"FldIndex\">")
     print("<table>")
     print("<tr>")
     print(" <th>Field Name</th>")
@@ -865,7 +924,7 @@ def print_enumeration_index():
     print("<a id=\"EnumerationIndex\"></a>")
     print("<h3>Enumeration Index</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sEnumeration Index<br/>"
% ("EnuIndex", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"EnuIndex\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"EnuIndex\">")
     print("<table>")
     print("<tr>")
     print(" <th>Enum Value</th>")
@@ -897,7 +956,7 @@ def print_grand_index():
     print("<a id=\"GrandIndex\"></a>")
     print("<h3>Grand Index</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sGrand Index<br/>"
% ("GndIndex", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"GndIndex\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"GndIndex\">")
     print("<table>")
     print("<tr>")
     print(" <th>Name</th>")
@@ -998,7 +1057,7 @@ def print_xref_index():
     print("<a id=\"XrefIndex3\"></a>")
     print("<h3>Cross Reference Index</h3>")
     print("<a href=\"javascript:toggle_node('%s')\"> %s </a>%sType Cross Reference<br/>"
% ("XrefIndex", lozenge(), nbsp()))
-    print("<div style=\"display: none; margin-bottom: 2px\" id=\"XrefIndex\">")
+    print("<div style=\"display: block; margin-bottom: 2px\" id=\"XrefIndex\">")
     print("<table>")
     print("<tr>")
     print(" <th>Referenced Type</th>")
@@ -1072,6 +1131,7 @@ def main_except(argv):
     print_restricted_types()
     print_described_types()
     print_provided_types()
+    print_asciiart()
     print_type_index()
     print_field_index()
     print_enumeration_index()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message