示例#1
0
 def _unknown_node(self, node):
     yield T.span(style="color:blue")[node.tagname]
     if node.tagname == '#text':
         yield ': ', node.astext()
     c = get_children(node)
     if c:
         yield T.ul[self._unknown_nodes(c)]
示例#2
0
 def ggirole_default(self, node):
     token = node.astext()
     if hasattr(self.root, 'manpage') and token in self.root.manpage.pages:
         return T.span(_class='function')[token]
     cand = self.context.findTerm(token)
     if not cand:
         return T.span(_class='default')[self.children(node)]
     if cand[0].type == 'man':
         c = cand[0]
         href = 'documentation/%s/%s/%s.%s.html' % (c.pkgname, c.branch,
                                                    c.entry, c.volume)
         return T.a(_class='manpage',
                    href='../' * self.context.depth +
                    href)['%s(%s)' % (token, c.volume)]
     else:
         return T.a(_class='term')[self.children(node)]
示例#3
0
 def ggirole_man(self, node):
     cand = self.context.findPage(node.manref[0], node.manref[1])
     if cand:
         c = cand[0]
         href = 'documentation/%s/%s/%s.%s.html' % (c.pkgname, c.branch,
                                                    c.entry, c.volume)
         return T.a(_class='manpage',
                    href='../' * self.context.depth +
                    href)['%s(%s)' % (node.manref[0], c.volume)]
     return T.span(_class='manpage')[self.children(node)]
示例#4
0
    def node_reference(self, node):
        href = '/'
        if node.has_key('refuri'):
            href = node['refuri']
        elif node.has_key('refid'):
            href = '#' + node['refid']
        elif node.has_key('refname'):
            href = '#' + self.document.nameids[node['refname']]
        else:
            yield T.span(style="color: red")['Unresolved:']

        def _():
            for i in 'https://', 'ftp://', 'http://':
                if href.startswith(i):
                    return T.a(href=href, _class='external')[node.astext(),
                                                             T.span[u'\u25B8']]
            return T.a(href=href)[node.astext()]  # ,T.span[u'\u25C2']]

        yield _()
示例#5
0
 def ggirole_variable(self, node):
     return T.span(_class='variable')[self.children(node)]
示例#6
0
 def ggirole_function(self, node):
     return T.span(_class='function')[self.children(node)]
示例#7
0
 def node_literal(self, node):
     if hasattr(node, 'ggirole'):
         return getattr(self, 'ggirole_%s' % node.ggirole)(node)
     return T.span(_class='literal')["'", self.children(node), "'"]