From: <zw...@us...> - 2004-02-27 18:54:00
|
Update of /cvsroot/archetypes/ArchGenXML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14520 Modified Files: ArchGenXML.py XMIParser.py Log Message: if strip-o-gram is installed and the option '--strip-html' is set all document strings are converted from html 2 text (e.g. necessary for Poseideon) Index: ArchGenXML.py =================================================================== RCS file: /cvsroot/archetypes/ArchGenXML/ArchGenXML.py,v retrieving revision 1.105 retrieving revision 1.106 diff -u -d -r1.105 -r1.106 --- ArchGenXML.py 27 Feb 2004 14:13:16 -0000 1.105 +++ ArchGenXML.py 27 Feb 2004 18:44:48 -0000 1.106 @@ -58,6 +58,7 @@ ape_support=0 #generate ape config and serializers/gateways for APE method_preservation=1 #should the method bodies be preserved? defaults now to 0 will change to 1 i18n_support=0 + striphtml=0 reservedAtts=['id',] portal_tools=['portal_tool'] @@ -456,7 +457,7 @@ 'type': attr.getType(), 'other':defexp+indent(other_attributes,3) } - doc=attr.getDocumentation() + doc=attr.getDocumentation(striphtml=self.striphtml) if doc: res=indent(doc,2,'#')+'\n'+' '*8+res else: @@ -636,7 +637,7 @@ else: print >> outfile,' def %s(self%s):' % (m.getName(),paramstr) code=m.taggedValues.get('code','') - doc=m.taggedValues.get('documentation','') + doc=m.getDocumentation(striphtml=self.striphtml) if doc: print >> outfile, indent("'''\n%s\n'''" % doc ,2) @@ -731,7 +732,7 @@ s1 = 'class %s%s(%s):\n' % (self.prefix, name, parents) wrt(s1) - doc=element.getDocumentation() + doc=element.getDocumentation(striphtml=self.striphtml) if doc: print >>outfile,indent("'''\n%s\n'''" % doc, 1) @@ -784,7 +785,7 @@ return #deal with multiline docstring - purposeline='\n# '.join((element.getDocumentation() or 'unknown').split('\n')) + purposeline='\n# '.join((element.getDocumentation(striphtml=self.striphtml) or 'unknown').split('\n')) author= element.getTaggedValue('author', self.author) or 'unknown' @@ -1183,7 +1184,8 @@ 'method-preservation','no-method-preservation', 'i18n-support','i18n','no-module-info-header', 'author=','e-mail=','copyright=','licence=','creation-permission=', - 'detailled-creation-permissions','no-detailled-creation-permissions']) + 'detailled-creation-permissions','no-detailled-creation-permissions', + 'strip-html']) prefix = '' outfileName = None yesno={'yes':1,'y': 1, 'no':0, 'n':0} @@ -1241,6 +1243,8 @@ options['detailled_creation_permissions'] = 1 elif option[0] == '--no-detailled-creation-permissions': options['detailled_creation_permissions'] = 0 + if option[0] in (['--strip-html']): + options['striphtml'] = 1 if len(args) < 1 and not options.get('noclass',0): @@ -1326,6 +1330,10 @@ set default licence string for module info-headers, taggedValue will override this + --strip-html + strips HTML tags from the document strings (e.g. for Poseidon which + uses HTML inside the entity documentation ) + """ def usage(): Index: XMIParser.py =================================================================== RCS file: /cvsroot/archetypes/ArchGenXML/XMIParser.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- XMIParser.py 27 Feb 2004 14:13:16 -0000 1.40 +++ XMIParser.py 27 Feb 2004 18:44:48 -0000 1.41 @@ -16,6 +16,11 @@ from utils import mapName from xml.dom import minidom +try: + from stripogram import html2text +except ImportError: + def html2text(s,*args,**kwargs): + return s #tag constants @@ -555,8 +560,11 @@ def getTaggedValues(self): return self.taggedValues - def getDocumentation(self): - return self.getTaggedValue('documentation') + def getDocumentation(self,striphtml=0): + if striphtml: + return html2text(self.getTaggedValue('documentation')) + else: + return self.getTaggedValue('documentation') def getUnmappedCleanName(self): return self.unmappedCleanName def setName(self, name): self.name = name |