

def begin_text_resource(self, resource, text):
    'Event hook for processing an individual resource.\n\n        If the input resource is a sphinx input file, this method will replace\n        replace the text of the file with the sphinx-generated documentation.\n\n        Sphinx itself is run lazily the first time this method is called.\n        This means that if no sphinx-related resources need updating, then\n        we entirely avoid running sphinx.\n        '
    suffix = self.sphinx_config.get('source_suffix', '.rst')
    if (not resource.source_file.path.endswith(suffix)):
        return text
    if (self.sphinx_build_dir is None):
        self._run_sphinx()
    output = []
    settings = self.settings
    sphinx_output = self._get_sphinx_output(resource)
    if (not settings.block_map):
        output.append(sphinx_output['body'])
    else:
        for (nm, content) in iteritems(sphinx_output):
            try:
                block = getattr(settings.block_map, nm)
            except AttributeError:
                pass
            else:
                output.append(('{%% block %s %%}' % (block,)))
                output.append(content)
                output.append('{% endblock %}')
    return '\n'.join(output)

dataset/ETHPy150Open hyde/hyde/hyde/ext/plugins/sphinx.py SphinxPlugin.begin_text_resource/original