Esempio n. 1
0
    def run(self):
        # simplify env access
        self.env = self.state.document.settings.env

        # short setup path:
        # like it's used in nicos (setup_pkg/instr/setups/setup.py)
        self._shortSetupPath = self.arguments[0]
        self._absSetupPath = self._getAbsoluteSetupPath(self._shortSetupPath)
        self._setupName = path.basename(self._absSetupPath)[:-3]

        # relative to the doc source dir
        # rel_path = path.join(self.env.config.setupdoc_setup_base_dir,
        #                     self.arguments[0])

        # note actual setup as dependency
        self.env.note_dependency(self._absSetupPath)

        info = self._readSetup()
        node = nodes.paragraph()
        if info:
            content = self._buildSetupRst(info)
            content = ViewList(content.splitlines(), self._absSetupPath)
            nested_parse_with_titles(self.state, content, node)

        return node.children
Esempio n. 2
0
    def parse_nested(self, txt, source=None):
        """
        Parse text as reStructuredText if the ``literal`` option is not set.

        Otherwise, interpret the text as a line block.
        """
        if 'literal' in self.options:
            node = nodes.literal_block(txt, txt, classes=[])
            # Avoid syntax highlight
            node['language'] = 'text'
            return [node]
        else:
            txt = ViewList(txt.splitlines(), source)
            node = nodes.Element()
            self.state.nested_parse(txt, self.content_offset, node)
            return node.children