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


Python nodes.compound方法代碼示例

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


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

示例1: visit_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def visit_paragraph(self, node):
        # insert blank line, unless
        # * the paragraph is first in a list item,
        # * follows a non-paragraph node in a compound,
        # * is in a table with auto-width columns
        index = node.parent.index(node)
        if (index == 0 and (isinstance(node.parent, nodes.list_item) or
                            isinstance(node.parent, nodes.description))):
            pass
        elif (index > 0 and isinstance(node.parent, nodes.compound) and
              not isinstance(node.parent[index - 1], nodes.paragraph) and
              not isinstance(node.parent[index - 1], nodes.compound)):
            pass
        elif self.active_table.colwidths_auto:
            if index == 1: # second paragraph
                self.warn('LaTeX merges paragraphs in tables '
                          'with auto-sized columns!', base_node=node)
            if index > 0:
                self.out.append('\n')
        else:
            self.out.append('\n')
        if node.get('ids'):
            self.out += self.ids_to_labels(node) + ['\n']
        if node['classes']:
            self.visit_inline(node) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:27,代碼來源:__init__.py

示例2: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def run(self):
        """ returns an array of nodes for the tableofcontents directive declaration
        """
        ret = []
        wrappernode = nodes.compound(classes=["tableofcontents-wrapper"])
        self.add_name(wrappernode)
        depth = 0

        globaltoc = self._process_toc_dict(copy.deepcopy(self.config.globaltoc))

        # remove master_doc from the dict
        if "file" in globaltoc and globaltoc["file"] == self.config.master_doc:
            del globaltoc["file"]

        wncopy = wrappernode.deepcopy()
        self._has_toc_yaml(wncopy, globaltoc, depth)

        ret.append(wncopy)
        return ret 
開發者ID:executablebooks,項目名稱:jupyter-book,代碼行數:21,代碼來源:toc.py

示例3: visit_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def visit_paragraph(self, node):
        # insert blank line, unless
        # * the paragraph is first in a list item or compound,
        # * follows a non-paragraph node in a compound,
        # * is in a table with auto-width columns
        index = node.parent.index(node)
        if index == 0 and isinstance(node.parent,
                (nodes.list_item, nodes.description, nodes.compound)):
            pass
        elif (index > 0 and isinstance(node.parent, nodes.compound) and
              not isinstance(node.parent[index - 1], nodes.paragraph) and
              not isinstance(node.parent[index - 1], nodes.compound)):
            pass
        elif self.active_table.colwidths_auto:
            if index == 1: # second paragraph
                self.warn('LaTeX merges paragraphs in tables '
                          'with auto-sized columns!', base_node=node)
            if index > 0:
                self.out.append('\n')
        else:
            self.out.append('\n')
        if node.get('ids'):
            self.out += self.ids_to_labels(node) + ['\n']
        if node['classes']:
            self.visit_inline(node) 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:27,代碼來源:__init__.py

示例4: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def run(self):
        self.filenames = set()
        if self.arguments[0] == 'lexers':
            out = self.document_lexers()
        elif self.arguments[0] == 'formatters':
            out = self.document_formatters()
        elif self.arguments[0] == 'filters':
            out = self.document_filters()
        else:
            raise Exception('invalid argument for "pygmentsdoc" directive')
        node = nodes.compound()
        vl = ViewList(out.split('\n'), source='')
        nested_parse_with_titles(self.state, vl, node)
        for fn in self.filenames:
            self.state.document.settings.record_dependencies.add(fn)
        return node.children 
開發者ID:joxeankoret,項目名稱:pigaios,代碼行數:18,代碼來源:sphinxext.py

示例5: apply

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def apply(self):
        for compound in self.document.traverse(nodes.compound):
            first_child = True
            for child in compound:
                if first_child:
                    if not isinstance(child, nodes.Invisible):
                        first_child = False
                else:
                    child['classes'].append('continued')
            # Substitute children for compound.
            compound.replace_self(compound[:]) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:13,代碼來源:writer_aux.py

示例6: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def run(self):
        self.assert_has_content()
        text = '\n'.join(self.content)
        node = nodes.compound(text)
        node['classes'] += self.options.get('class', [])
        self.add_name(node)
        self.state.nested_parse(self.content, self.content_offset, node)
        return [node] 
開發者ID:skarlekar,項目名稱:faces,代碼行數:10,代碼來源:body.py

示例7: should_be_compact_paragraph

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def should_be_compact_paragraph(self, node):
        """
        Determine if the <p> tags around paragraph ``node`` can be omitted.
        """
        if (isinstance(node.parent, nodes.document) or
            isinstance(node.parent, nodes.compound)):
            # Never compact paragraphs in document or compound.
            return False
        for key, value in node.attlist():
            if (node.is_not_default(key) and
                not (key == 'classes' and value in
                     ([], ['first'], ['last'], ['first', 'last']))):
                # Attribute which needs to survive.
                return False
        first = isinstance(node.parent[0], nodes.label) # skip label
        for child in node.parent.children[first:]:
            # only first paragraph can be compact
            if isinstance(child, nodes.Invisible):
                continue
            if child is node:
                break
            return False
        parent_length = len([n for n in node.parent if not isinstance(
            n, (nodes.Invisible, nodes.label))])
        if ( self.compact_simple
             or self.compact_field_list
             or self.compact_p and parent_length == 1):
            return True
        return False 
開發者ID:skarlekar,項目名稱:faces,代碼行數:31,代碼來源:__init__.py

示例8: duclass_open

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def duclass_open(self, node):
        """Open a group and insert declarations for class values."""
        if not isinstance(node.parent, nodes.compound):
             self.out.append('\n')
        for cls in node['classes']:
            if cls.startswith('language-'):
                language = self.babel.language_name(cls[9:])
                if language:
                    self.babel.otherlanguages[language] = True
                    self.out.append('\\begin{selectlanguage}{%s}\n' % language)
            else:
                self.fallbacks['DUclass'] = PreambleCmds.duclass
                self.out.append('\\begin{DUclass}{%s}\n' % cls) 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:15,代碼來源:__init__.py

示例9: visit_comment

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def visit_comment(self, node):
        if not isinstance(node.parent, nodes.compound):
             self.out.append('\n')
        # Precede every line with a comment sign, wrap in newlines
        self.out.append('%% %s\n' % node.astext().replace('\n', '\n% '))
        raise nodes.SkipNode 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:8,代碼來源:__init__.py

示例10: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import compound [as 別名]
def run(self):
        self.assert_has_content()

        hidden_until = self.arguments[0]
        try:
            hidden_until = parse_date(hidden_until)
        except:
            raise self.error('Unknown date format in the "%s" directive; '
                             '%s' % (self.name, hidden_until))

        force_show = self.state.document.settings.force_show_hidden_until
        translation = _get_inginious_translation()

        after_deadline = hidden_until <= datetime.now()
        if after_deadline or force_show:
            output = []

            # Add a warning for teachers/tutors/...
            if not after_deadline and force_show:
                node = nodes.caution()
                self.add_name(node)
                text = translation.gettext("The feedback below will be hidden to the students until {}.").format(
                    hidden_until.strftime("%d/%m/%Y %H:%M:%S"))
                self.state.nested_parse(StringList(text.split("\n")), 0, node)
                output.append(node)

            text = '\n'.join(self.content)
            node = nodes.compound(text)
            self.add_name(node)
            self.state.nested_parse(self.content, self.content_offset, node)
            output.append(node)

            return output
        else:
            node = nodes.caution()
            self.add_name(node)
            text = translation.gettext(
                "A part of this feedback is hidden until {}. Please come back later and reload the submission to see the full feedback.").format(
                hidden_until.strftime("%d/%m/%Y %H:%M:%S"))
            self.state.nested_parse(StringList(text.split("\n")), 0, node)
            return [node] 
開發者ID:UCL-INGI,項目名稱:INGInious,代碼行數:43,代碼來源:parsable_text.py


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