trying out the hint from github issue
[plcapi.git] / doc / DocBook.py
index 0185ab4..90b384d 100755 (executable)
@@ -6,17 +6,12 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: DocBook.py,v 1.3 2006/10/25 19:35:36 mlhuang Exp $
-#
 
 import xml.dom.minidom
 from xml.dom.minidom import Element, Text
 import codecs
 
-from PLC.API import PLCAPI
-from PLC.Method import *
-
-api = PLCAPI(None)
+from PLC.Parameter import Parameter, Mixed, xmlrpc_type, python_type
 
 # xml.dom.minidom.Text.writexml adds surrounding whitespace to textual
 # data when pretty-printing. Override this behavior.
@@ -105,45 +100,52 @@ class paramElement(Element):
             for subparam in param:
                 itemizedlist.appendChild(paramElement(None, subparam))
 
-for method in api.methods:
-    func = api.callable(method)
-
-    if func.status == "deprecated":
-        continue
-
-    (min_args, max_args, defaults) = func.args()
-
-    section = Element('section')
-    section.setAttribute('id', func.name)
-    section.appendChild(simpleElement('title', func.name))
-
-    prototype = "%s (%s)" % (method, ", ".join(max_args))
-    para = paraElement('Prototype:')
-    para.appendChild(blockquoteElement(prototype))
-    section.appendChild(para)
-
-    para = paraElement('Description:')
-    para.appendChild(blockquoteElement(func.__doc__))
-    section.appendChild(para)
-
-    para = paraElement('Allowed Roles:')
-    para.appendChild(blockquoteElement(", ".join(func.roles)))
-    section.appendChild(para)
-
-    section.appendChild(paraElement('Parameters:'))
-    params = Element('itemizedlist')
-    if func.accepts:
-        for name, param, default in zip(max_args, func.accepts, defaults):
-            params.appendChild(paramElement(name, param))
-    else:
-        listitem = Element('listitem')
-        listitem.appendChild(paraElement('None'))
-        params.appendChild(listitem)
-    section.appendChild(params)
-
-    section.appendChild(paraElement('Returns:'))
-    returns = Element('itemizedlist')
-    returns.appendChild(paramElement(None, func.returns))
-    section.appendChild(returns)
-
-    print section.toprettyxml(encoding = "UTF-8")
+class DocBook:
+    
+    def __init__ (self,functions_list):
+        self.functions_list = functions_list
+
+    def Process (self):
+        
+        for func in self.functions_list:
+            method = func.name
+
+            if func.status == "deprecated":
+                continue
+
+            (min_args, max_args, defaults) = func.args()
+
+            section = Element('section')
+            section.setAttribute('id', func.name)
+            section.appendChild(simpleElement('title', func.name))
+
+            prototype = "%s (%s)" % (method, ", ".join(max_args))
+            para = paraElement('Prototype:')
+            para.appendChild(blockquoteElement(prototype))
+            section.appendChild(para)
+
+            para = paraElement('Description:')
+            para.appendChild(blockquoteElement(func.__doc__))
+            section.appendChild(para)
+
+            para = paraElement('Allowed Roles:')
+            para.appendChild(blockquoteElement(", ".join(func.roles)))
+            section.appendChild(para)
+
+            section.appendChild(paraElement('Parameters:'))
+            params = Element('itemizedlist')
+            if func.accepts:
+                for name, param, default in zip(max_args, func.accepts, defaults):
+                    params.appendChild(paramElement(name, param))
+            else:
+                listitem = Element('listitem')
+                listitem.appendChild(paraElement('None'))
+                params.appendChild(listitem)
+            section.appendChild(params)
+
+            section.appendChild(paraElement('Returns:'))
+            returns = Element('itemizedlist')
+            returns.appendChild(paramElement(None, func.returns))
+            section.appendChild(returns)
+
+            print section.toprettyxml(encoding = "UTF-8")