NbConvertApp

See also

Configuration options
Configurable options for the nbconvert application
class nbconvert.nbconvertapp.NbConvertApp(**kwargs)

Application used to convert from notebook file type (*.ipynb)

init_notebooks()

Construct the list of notebooks. If notebooks are passed on the command-line, they override notebooks specified in config files. Glob each notebook to replace notebook patterns with filenames.

convert_notebooks()

Convert the notebooks in the self.notebook traitlet

convert_single_notebook(notebook_filename, input_buffer=None)

Convert a single notebook. Performs the following steps:

  1. Initialize notebook resources
  2. Export the notebook to a particular format
  3. Write the exported notebook to file
  4. (Maybe) postprocess the written file

If input_buffer is not None, convertion is done using buffer as source into a file basenamed by the notebook_filename argument.

init_single_notebook_resources(notebook_filename)

Step 1: Initialize resources

This intializes the resources dictionary for a single notebook. This method should return the resources dictionary, and MUST include the following keys:

  • config_dir: the location of the Jupyter config directory
  • unique_key: the notebook name
  • output_files_dir: a directory where output files (not including the notebook itself) should be saved
export_single_notebook(notebook_filename, resources, input_buffer=None)

Step 2: Export the notebook

Exports the notebook to a particular format according to the specified exporter. This function returns the output and (possibly modified) resources from the exporter.

notebook_filename: a filename input_buffer: a readable file like object returning unicode, if not None notebook_filename is ignored

write_single_notebook(output, resources)

Step 3: Write the notebook to file

This writes output from the exporter to file using the specified writer. It returns the results from the writer.

postprocess_single_notebook(write_results)

Step 4: Postprocess the notebook

This postprocesses the notebook after it has been written, taking as an argument the results of writing the notebook to file. This only actually does anything if a postprocessor has actually been specified.