Skip to main content

Converting between ipython notebooks and sphinx docs

Project description

What it does

nb2plots currently only converts IPython notebooks to ReST files for Sphinx.

Use with:

nb2plots notebook.ipynb > with_plots.rst

This converts the IPython notebook to Restructured text using the normal nbconvert machinery, with the additional feature that code cells get converted to a custom nbplot plot directives based on the matplotlib plot directive.

Specifically, a notebook code cell like this:

a = 1

becomes (in the ReST document):

.. nbplot::

    >>> a = 1

This allows you to make the output ReST file testable using the Sphinx doctest builder, and the plots can be generated at Sphinx page build time.

In order to make this nbplot directive work for your sphinx builds, you should add the following to your conf.py file:

extensions = ["nb2plots.nbplots"]

The nbplot directive is very similar to the plot directive of matplotlib, and started life as a fork of that code. It differs mainly in that its default is to keep the namespace from one nbplot directive to the next in a given page, and has output defaults adapted to directive contents with source code rather than pointing to a standalone script. See the docstring of nb2plots/nbplots.py for details.

Dependencies

You will need pandoc installed and available as the pandoc command.

For OSX, we recommend homebrew for installing pandoc:

brew install pandoc

Code

See https://github.com/matthew-brett/nb2plots

Released under the BSD two-clause license - see the file LICENSE in the source distribution.

travis-ci kindly tests the code automatically under Python versions 2.6 through 2.7, and 3.2 through 3.5.

The latest released version is at https://pypi.python.org/pypi/nb2plots

Support

Please put up issues on the nb2plots issue tracker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

nb2plots-0.2.zip (57.9 kB view details)

Uploaded Source

nb2plots-0.2.tar.gz (50.0 kB view details)

Uploaded Source

File details

Details for the file nb2plots-0.2.zip.

File metadata

  • Download URL: nb2plots-0.2.zip
  • Upload date:
  • Size: 57.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nb2plots-0.2.zip
Algorithm Hash digest
SHA256 beb73b51a9c8ec1eef01e56d71fdb9ad06741f1dac1ab7418adaf0b5e2312848
MD5 b00ca8bb99b141a395139e555e97f37c
BLAKE2b-256 08a064bf19b480e7811ccbecdac47e570693dd3fd1e9d5919a05ef8e93478a85

See more details on using hashes here.

File details

Details for the file nb2plots-0.2.tar.gz.

File metadata

  • Download URL: nb2plots-0.2.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nb2plots-0.2.tar.gz
Algorithm Hash digest
SHA256 0782dd244122e6b064bfbdfc3c61fef42b1aef23d49f5716345392ff30205ac3
MD5 e845e56f93931a4aa4bc346212a9ed1b
BLAKE2b-256 80d25cb9ab700c12fcf8ca9ebdeb84edbf5453ab8baa16d172ffe5cfb9a7cf30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page