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)]
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)]
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)]
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 _()
def ggirole_variable(self, node): return T.span(_class='variable')[self.children(node)]
def ggirole_function(self, node): return T.span(_class='function')[self.children(node)]
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), "'"]