# 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.Method import *
-import DocBookLocal
+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.
for subparam in param:
itemizedlist.appendChild(paramElement(None, subparam))
-api_func_list = DocBookLocal.get_func_list()
-for func in api_func_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")
+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")