Add extra flags and info to enable template specialization typdefs to be documented like a class. Use it with wxScrolledWindow and wxScrolledCanvas.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71722 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-06-12 20:56:21 +00:00
parent f697317ebc
commit e7359ac55a
3 changed files with 57 additions and 8 deletions

View File

@@ -199,6 +199,8 @@ class TypedefDef(VariableDef):
def __init__(self, element=None, **kw):
super(TypedefDef, self).__init__()
self.noTypeName = False
self.docAsClass = False
self.bases = []
self.__dict__.update(**kw)
if element is not None:
self.extract(element)

View File

@@ -174,20 +174,41 @@ class PiWrapperGenerator(generators.WrapperGeneratorBase):
stream.write('%s = 0\n' % (define.pyName or define.name))
#-----------------------------------------------------------------------
def generateTypedef(self, typedef, stream):
def generateTypedef(self, typedef, stream, indent=''):
assert isinstance(typedef, extractors.TypedefDef)
if typedef.ignored:
return
# If the typedef is for a template instantiation then write a mock
# class for it that combines the template and class, otherwise write
# nothing.
if '<' in typedef.type and '>' in typedef.type:
# If it's not a template instantiation, or has not been flagged by
# the tweaker script that it should be treated as a class, then just
# ignore the typedef and return.
if not ('<' in typedef.type and '>' in typedef.type) and not typedef.docAsClass:
return
# Otherwise write a mock class for it that combines the template and class.
# First, extract the info we need.
if typedef.docAsClass:
bases = [removeWxPrefix(b) for b in typedef.bases]
name = removeWxPrefix(typedef.name)
elif '<' in typedef.type and '>' in typedef.type:
t = typedef.type.replace('>', '')
t = t.replace(' ', '')
bases = t.split('<')
bases = [removeWxPrefix(b) for b in bases]
name = removeWxPrefix(typedef.name)
stream.write('class %s(%s):\n pass\n\n' % (name, ', '.join(bases)))
# Now write the Python equivallent class for the typedef
if not bases:
bases = ['object'] # this should not happpen, but just in case...
stream.write('%sclass %s(%s):\n' % (indent, name, ', '.join(bases)))
indent2 = indent + ' '*4
if typedef.briefDoc:
stream.write('%s"""\n' % indent2)
stream.write(nci(typedef.briefDoc, len(indent2)))
stream.write('%s"""\n' % indent2)
else:
stream.write('%spass\n\n' % indent2)
#-----------------------------------------------------------------------