/usr/share/pyshared/pydoctor/templatewriter/util.py is in python-pydoctor 0.5b1+bzr603-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | """Miscellaneous utilities."""
from pydoctor import model
from twisted.web.template import tags
import os, urllib
def link(o):
if not o.isVisible:
o.system.warning("html", "don't link to %s"%o.fullName())
return o.system.urlprefix+urllib.quote(o.fullName()+'.html')
def srclink(o):
return o.sourceHref
def templatefile(filename):
abspath = os.path.abspath(__file__)
pydoctordir = os.path.dirname(os.path.dirname(abspath))
return os.path.join(pydoctordir, 'templates', filename)
def fillSlots(tag, **kw):
for k, v in kw.iteritems():
tag = tag.fillSlots(k, v)
return tag
def taglink(o, label=None):
if not o.isVisible:
o.system.warning("html", "don't link to %s"%o.fullName())
if label is None:
label = o.fullName()
if o.documentation_location == model.DocLocation.PARENT_PAGE:
p = o.parent
if isinstance(p, model.Module) and p.name == '__init__':
p = p.parent
linktext = link(p) + '#' + urllib.quote(o.name)
elif o.documentation_location == model.DocLocation.OWN_PAGE:
linktext = link(o)
else:
raise AssertionError(
"Unknown documentation_location: %s" % o.documentation_location)
return tags.a(href=linktext)(label)
|