X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=doc%2FDocBook.py;h=a91975d777157a0efbb0be16b4b0747cde73016a;hb=cf5ac5e45df14dd98e935fa258454145cd2a5db9;hp=254e99eb78cf6412e4c22f8ccfa0ce887ce95928;hpb=c2e30b90f21457b64846ebf41d6b04e61b417d60;p=plcapi.git diff --git a/doc/DocBook.py b/doc/DocBook.py index 254e99e..a91975d 100755 --- a/doc/DocBook.py +++ b/doc/DocBook.py @@ -7,14 +7,14 @@ # Copyright (C) 2006 The Trustees of Princeton University # # $Id$ +# $URL$ # 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. @@ -103,46 +103,52 @@ class paramElement(Element): 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")