2
from nevow import loaders, page, tags
4
from pydoctor import ast_pp
5
from pydoctor.nevowhtml import util
6
from pydoctor.nevowhtml.pages import signature
8
class FunctionChild(page.Element):
10
docFactory = loaders.xmlfile(util.templatefile('function-child.html'))
12
def __init__(self, docgetter, ob, functionExtras):
13
self.docgetter = docgetter
15
self._functionExtras = functionExtras
18
def functionAnchor(self, request, tag):
19
return self.ob.fullName()
22
def shortFunctionAnchor(self, request, tag):
26
def decorator(self, request, tag):
27
if self.ob.decorators:
28
decorators = [ast_pp.pp(dec) for dec in self.ob.decorators]
32
if self.ob.kind == "Class Method" \
33
and 'classmethod' not in decorators:
34
decorators.append('classmethod')
35
elif self.ob.kind == "Static Method" \
36
and 'staticmethod' not in decorators:
37
decorators.append('staticmethod')
40
decorator = [('@' + dec, tags.br()) for dec in decorators]
47
def functionName(self, request, tag):
48
return [self.ob.name, '(', signature(self.ob.argspec), '):']
51
def sourceLink(self, request, tag):
52
if self.ob.sourceHref:
53
return tag.fillSlots('sourceHref', self.ob.sourceHref)
58
def functionExtras(self, request, tag):
59
return self._functionExtras
62
def functionBody(self, request, tag):
63
return self.docgetter.get(self.ob)