How to use the nbsite.nbbuild.notebook_node function in nbsite

To help you get started, we’ve selected a few nbsite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyviz-dev / nbsite / nbsite / nbbuild.py View on Github external
substring=self.options.get('substring'),
                                           end=self.options.get('end'),
                                           skip_execute=self.options.get('skip_execute'),
                                           skip_output=self.options.get('skip_output'),
                                           offset=self.options.get('offset', 0),
                                           timeout=setup.config.nbbuild_cell_timeout,
                                           ipython_startup=setup.config.nbbuild_ipython_startup,
                                           patterns_to_take_with_me=setup.config.nbbuild_patterns_to_take_along)

        # Insert evaluated notebook HTML into Sphinx

        self.state_machine.insert_input([link_rst], rst_file)

        # create notebook node
        attributes = {'format': 'html', 'source': 'nb_path'}
        nb_node = notebook_node('', evaluated_text, **attributes)
        (nb_node.source, nb_node.line) = \
            self.state_machine.get_source_and_line(self.lineno)

        # add dependency
        self.state.document.settings.record_dependencies.add(nb_abs_path)

        # TODO: doubt this isdoing anyting
        # clean up png files left behind by notebooks.
        png_files = glob.glob("*.png")
        for file in png_files:
            os.remove(file)

        return [nb_node]
github pyviz-dev / nbsite / nbsite / nbbuild.py View on Github external
def setup(app):
    setup.app = app
    setup.config = app.config
    setup.confdir = app.confdir

    app.add_config_value('nbbuild_cell_timeout',300,'html')
    app.add_config_value('nbbuild_ipython_startup',"from nbsite.ipystartup import *",'html')
    app.add_config_value('nbbuild_patterns_to_take_along',["*.json", "json_*"],'html')

    app.add_node(notebook_node,
                 html=(visit_notebook_node, depart_notebook_node))

    app.add_directive('notebook', NotebookDirective)