~ubuntu-branches/debian/sid/pydoctor/sid

« back to all changes in this revision

Viewing changes to pydoctor/nevowhtml/util.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2013-09-15 13:58:49 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130915135849-g206zbvqwvz0ptdg
Tags: 0.5b1+bzr603-1
* New upstream snapshot.
* Switch from cdbs to dh.
* Bump standards version to 3.9.4 (no changes).
* Update Vcs header.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""Miscellaneous utilities."""
2
 
 
3
 
from pydoctor import model
4
 
 
5
 
from nevow import tags
6
 
 
7
 
import os, urllib
8
 
 
9
 
def link(o):
10
 
    if not o.isVisible:
11
 
        o.system.warning("html", "don't link to %s"%o.fullName())
12
 
    return o.system.urlprefix+urllib.quote(o.fullName()+'.html')
13
 
 
14
 
def srclink(o):
15
 
    return o.sourceHref
16
 
 
17
 
def templatefile(filename):
18
 
    abspath = os.path.abspath(__file__)
19
 
    pydoctordir = os.path.dirname(os.path.dirname(abspath))
20
 
    return os.path.join(pydoctordir, 'templates', filename)
21
 
 
22
 
def fillSlots(tag, **kw):
23
 
    for k, v in kw.iteritems():
24
 
        tag = tag.fillSlots(k, v)
25
 
    return tag
26
 
 
27
 
def taglink(o, label=None):
28
 
    if not o.isVisible:
29
 
        o.system.warning("html", "don't link to %s"%o.fullName())
30
 
    if label is None:
31
 
        label = o.fullName()
32
 
    if o.document_in_parent_page:
33
 
        p = o.parent
34
 
        if isinstance(p, model.Module) and p.name == '__init__':
35
 
            p = p.parent
36
 
        linktext = link(p) + '#' + urllib.quote(o.name)
37
 
    else:
38
 
        linktext = link(o)
39
 
    return tags.a(href=linktext)[label]