Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build gallery with Jupyter-Book #668

Closed
mdtanker opened this issue Aug 29, 2022 · 2 comments
Closed

Build gallery with Jupyter-Book #668

mdtanker opened this issue Aug 29, 2022 · 2 comments

Comments

@mdtanker
Copy link

Hi, I'm using jupyter-books to create the docs for my python package Antarctic-Plots and I'm trying to set up a gallery of examples from a series of jupyter notebooks, following this guide.

I've managed to create a .html of the gallery, but instead of thumbnails, it's just a bullet point list of the .ipynb's, as in the following screenshot.

image

To do this, I've added the following to the _config.yml:

  config:
    sphinx_gallery_conf : {
      'examples_dirs': "examples",
      'gallery_dirs': "auto_examples",
      'image_scrapers': pygmt.sphinx_gallery.PyGMTScraper(),
                          }

and I've added this to my _toc.yml:

  - title: 👀 Gallery
    file: gallery/gallery

which points to the file gallery.ipynb, which has a metadata cell tag nbsphinx-gallery:

# Gallery

* [Basic Plot](basic_plot.ipynb)
* [Extend PyGMT](extend_pygmt.ipynb)

Any advice for how to fix this and have the thumbnails display properly? This issue persists whether or not the ipynb's have the metadata cell tag: nbsphinx-thumbnail.

Possibly unrelated, but I've had to add source_suffix: ['.rst', '.ipynb'] to my _config.yml, or else I got the following error:

sphinx.errors.ExtensionError: source_suffix '.ipynb' is already registered
@mgeier
Copy link
Member

mgeier commented Sep 5, 2022

jupyter-book and nbsphinx are two separate projects. The former doesn't seem to support galleries yet (see executablebooks/jupyter-book#1785).

Your setting sphinx_gallery_conf is from yet another project: sphinx-gallery. You might be able to use that, but the usage is different than in nbsphinx. Have a look at their docs for how to set it up. You won't need nbsphinx for that.

If you want to use the gallery feature from nbsphinx, you'll also have to use nbsphinx to parse your notebooks (instead of jupyter-book), otherwise the thumbnails will not be generated. Note that when you use nbsphinx, you'll have to remove .ipynb from source_suffix again.

@mdtanker
Copy link
Author

mdtanker commented Sep 7, 2022

Thanks for the response. I couldn't manage to get nbsphinx to work with my jupyter-book setup, but have resorted to a simple mardown file with the gallery examples for now.

@mdtanker mdtanker closed this as completed Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants