From c84375e8018d300e2ae43a932cff6948300b03c0 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sat, 2 Aug 2008 15:47:45 +0000 Subject: More cleanups. svn path=/trunk/; revision=919 --- codegen/docgen.py | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) (limited to 'codegen/docgen.py') diff --git a/codegen/docgen.py b/codegen/docgen.py index 8c47c94..b9e2f67 100644 --- a/codegen/docgen.py +++ b/codegen/docgen.py @@ -432,48 +432,55 @@ class DocbookDocWriter(DocWriter): info = self.parser.c_name.get(match.group(1), None) if info: if isinstance(info, defsparser.FunctionDef): - if info.is_constructor_of is not None: - # should have a link here - return '%s()' % \ - self.pyname(info.is_constructor_of) - else: - return '' + info.name + '()' + return self._format_funcdef(info) if isinstance(info, defsparser.MethodDef): - return '' + self.pyname(info.of_object) + '.' + \ - info.name + '()' + return self._format_method(info) + # fall through through - return '' + match.group(1) + '()' + return '%s()' % (match.group(1), ) + + def _format_funcdef(self, info): + if info.is_constructor_of is not None: + # should have a link here + return '%s()' % ( + self.pyname(info.is_constructor_of), ) + else: + return '%s()' % (info.name, ) def _format_param(self, match): - return '' + match.group(1) + '' + return '%s' % (match.group(1), ) def _format_const(self, match): - return '' + match.group(1) + '' + return '%s' % (match.group(1), ) + + def _format_method(self, info): + return ('' + '%s.%s' + '') % (self.make_method_ref(info), + self.pyname(info.of_object), + info.name) + + def _format_object(self, info): + return ('' + '%s' + '') % (self.make_class_ref(info.c_name), + self.pyname(info.c_name)) def _format_symbol(self, match): info = self.parser.c_name.get(match.group(1), None) if info: if isinstance(info, defsparser.FunctionDef): - if info.is_constructor_of is not None: - # should have a link here - return '%s' % ( - self.pyname(info.is_constructor_of), ) - else: - return '' + info.name + '' - if isinstance(info, defsparser.MethodDef): - return '' + self.pyname(info.of_object) + '.' + \ - info.name + '' - if isinstance(info, defsparser.ObjectDef) or \ - isinstance(info, defsparser.InterfaceDef) or \ - isinstance(info, defsparser.BoxedDef) or \ - isinstance(info, defsparser.PointerDef): - return '' + self.pyname(info.c_name) + \ - '' + return self._format_funcdef(info) + elif isinstance(info, defsparser.MethodDef): + return self._format_method(info) + elif isinstance(info, (defsparser.ObjectDef, + defsparser.InterfaceDef, + defsparser.BoxedDef, + defsparser.PointerDef)): + return self._format_object(info) + # fall through through - return '' + match.group(1) + '' + return '%s' % (match.group(1), ) def reformat_text(self, text, singleline=0): # replace special strings ... @@ -491,9 +498,7 @@ class DocbookDocWriter(DocWriter): if lines[index].strip() == '': lines[index] = '\n' continue - lines.insert(0, '') - lines.append('') - return '\n'.join(lines) + return '%s' % ('\n'.join(lines), ) # write out hierarchy -- cgit