當前位置: 首頁>>代碼示例>>Python>>正文


Python nodes.authors方法代碼示例

本文整理匯總了Python中docutils.nodes.authors方法的典型用法代碼示例。如果您正苦於以下問題:Python nodes.authors方法的具體用法?Python nodes.authors怎麽用?Python nodes.authors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在docutils.nodes的用法示例。


在下文中一共展示了nodes.authors方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: extract_authors

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def extract_authors(self, field, name, docinfo):
        try:
            if len(field[1]) == 1:
                if isinstance(field[1][0], nodes.paragraph):
                    authors = self.authors_from_one_paragraph(field)
                elif isinstance(field[1][0], nodes.bullet_list):
                    authors = self.authors_from_bullet_list(field)
                else:
                    raise TransformError
            else:
                authors = self.authors_from_paragraphs(field)
            authornodes = [nodes.author('', '', *author)
                           for author in authors if author]
            if len(authornodes) >= 1:
                docinfo.append(nodes.authors('', *authornodes))
            else:
                raise TransformError
        except TransformError:
            field[-1] += self.document.reporter.warning(
                  'Bibliographic field "%s" incompatible with extraction: '
                  'it must contain either a single paragraph (with authors '
                  'separated by one of "%s"), multiple paragraphs (one per '
                  'author), or a bullet list with one paragraph (one author) '
                  'per item.'
                  % (name, ''.join(self.language.author_separators)),
                  base_node=field)
            raise 
開發者ID:skarlekar,項目名稱:faces,代碼行數:29,代碼來源:frontmatter.py

示例2: authors_from_one_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def authors_from_one_paragraph(self, field):
        text = field[1][0].astext().strip()
        if not text:
            raise TransformError
        for authorsep in self.language.author_separators:
            authornames = text.split(authorsep)
            if len(authornames) > 1:
                break
        authornames = [author.strip() for author in authornames]
        authors = [[nodes.Text(author)] for author in authornames if author]
        return authors 
開發者ID:skarlekar,項目名稱:faces,代碼行數:13,代碼來源:frontmatter.py

示例3: authors_from_bullet_list

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def authors_from_bullet_list(self, field):
        authors = []
        for item in field[1][0]:
            if len(item) != 1 or not isinstance(item[0], nodes.paragraph):
                raise TransformError
            authors.append(item[0].children)
        if not authors:
            raise TransformError
        return authors 
開發者ID:skarlekar,項目名稱:faces,代碼行數:11,代碼來源:frontmatter.py

示例4: authors_from_paragraphs

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def authors_from_paragraphs(self, field):
        for item in field[1]:
            if not isinstance(item, nodes.paragraph):
                raise TransformError
        authors = [item.children for item in field[1]]
        return authors 
開發者ID:skarlekar,項目名稱:faces,代碼行數:8,代碼來源:frontmatter.py

示例5: visit_author

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def visit_author(self, node):
        if isinstance(node.parent, nodes.authors):
            if self.author_in_authors:
                self.body.append('\n<br />')
        else:
            self.visit_docinfo_item(node, 'author') 
開發者ID:skarlekar,項目名稱:faces,代碼行數:8,代碼來源:__init__.py

示例6: depart_author

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def depart_author(self, node):
        if isinstance(node.parent, nodes.authors):
            self.author_in_authors = True
        else:
            self.depart_docinfo_item() 
開發者ID:skarlekar,項目名稱:faces,代碼行數:7,代碼來源:__init__.py

示例7: visit_authors

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def visit_authors(self, node):
        self.visit_docinfo_item(node, 'authors')
        self.author_in_authors = False  # initialize 
開發者ID:skarlekar,項目名稱:faces,代碼行數:5,代碼來源:__init__.py

示例8: visit_author

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def visit_author(self, node):
        if isinstance(node.parent, nodes.authors):
            el = self.append_p('blockindent')
        else:
            el = self.generate_labeled_block(node, 'author')
        self.set_current_element(el) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:8,代碼來源:__init__.py

示例9: visit_authors

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def visit_authors(self, node):
        label = '%s:' % (self.language.labels['authors'], )
        el = self.append_p('textbody')
        el1 = SubElement(el, 'text:span',
            attrib={'text:style-name': self.rststyle('strong')})
        el1.text = label 
開發者ID:skarlekar,項目名稱:faces,代碼行數:8,代碼來源:__init__.py

示例10: depart_author

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def depart_author(self, node):
        self.body.append('</p>')
        if isinstance(node.parent, nodes.authors):
            self.body.append('\n')
        else:
            self.depart_docinfo_item() 
開發者ID:skarlekar,項目名稱:faces,代碼行數:8,代碼來源:_html_base.py

示例11: visit_authors

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import authors [as 別名]
def visit_authors(self, node):
        self.visit_docinfo_item(node, 'authors') 
開發者ID:skarlekar,項目名稱:faces,代碼行數:4,代碼來源:_html_base.py


注:本文中的docutils.nodes.authors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。