genelements.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:deviation-manual 作者: DeviationTX 项目源码 文件源码
def gather_elements(self, client, node, style):
        # I need to catch the classifiers here
        tt = []
        dt = []
        ids = []
        for n in node.children:
            if isinstance(n, docutils.nodes.term):
                for i in n['ids']: # Used by sphinx glossary lists
                    if i not in client.targets:
                        ids.append('<a name="%s"/>' % i)
                        client.targets.append(i)
                o, c = client.styleToTags("definition-list-term")
                tt.append(o + client.gather_pdftext(n) + c)
            elif isinstance(n, docutils.nodes.classifier):
                o, c = client.styleToTags("definition-list-classifier")
                tt.append(o + client.gather_pdftext(n) + c)
            else:
                dt.extend(client.gen_elements(n, style))

        # FIXME: make this configurable from the stylesheet
        t_style = TableStyle (client.styles['definition'].commands)
        cw = getattr(client.styles['definition'],'colWidths',[])

        if client.splittables:
            node.elements = [
                Paragraph(''.join(ids)+' : '.join(tt), client.styles['definition-list-term']),
                SplitTable([['',dt]] , colWidths=cw, style = t_style )]
        else:
            node.elements = [
                Paragraph(''.join(ids)+' : '.join(tt), client.styles['definition-list-term']),
                DelayedTable([['',dt]] , colWidths=[10,None], style = t_style )]

        return node.elements
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号