X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=doc%2FDocBook.py;h=90b384d7f189025b98f816f278b53dfe1b4e5cef;hb=refs%2Fheads%2Fremove-xmlrpc;hp=0185ab4da8bb2f081508c8b6b97a0fb8a2097b33;hpb=16c88e6e4e609facf12f7d36d63551089138d35b;p=plcapi.git diff --git a/doc/DocBook.py b/doc/DocBook.py index 0185ab4..90b384d 100755 --- a/doc/DocBook.py +++ b/doc/DocBook.py @@ -6,17 +6,12 @@ # Mark Huang # 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")