https://github.com/fanchengyan/myst-sphinx-gallery

A Sphinx extension that builds galleries from myst-style markdown, notebook or rst files.

https://github.com/fanchengyan/myst-sphinx-gallery

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.5%) to scientific vocabulary

Keywords

docutils gallery jupyter markdown parser sphinx-extension
Last synced: 4 months ago · JSON representation

Repository

A Sphinx extension that builds galleries from myst-style markdown, notebook or rst files.

Basic Info
Statistics
  • Stars: 7
  • Watchers: 1
  • Forks: 2
  • Open Issues: 0
  • Releases: 6
Topics
docutils gallery jupyter markdown parser sphinx-extension
Created over 1 year ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md


Conda Recipe Documentation Status Language Conda Version PyPI Conda Downloads tests codecov

Introduction

MyST Sphinx Gallery is a Sphinx extension that allows you to build galleries from jupyter notebooks (.ipynb), markdown (.md) or reStructuredText (.rst) files.

This extension is functionally similar to the Sphinx-Gallery extension, but aim to provide a simple and efficient way to create galleries written in a variety of file formats.

gallery_example

Highlight Features

  • Easy to use - It provides a set of directives to generate galleries, as simple as adding toctree.
  • Flexible - You can easily generate a gallery of examples from your Jupyter Notebooks, Markdown, or reStructuredText files. It works with MyST Ecosystem, including MyST-parser and MyST-NB, to render markdown or jupyter notebooks in Sphinx documentation.
  • Fast and robust - It utilizes existing images to generate gallery thumbnails, eliminating code execution delays and potential accidental errors when building gallery.
  • Customizable - You can customize the gallery, such as thumbnail selection, and style of the gallery.

Documentation

The detailed documentation is available at: https://myst-sphinx-gallery.readthedocs.io/en/latest/

Quick Start

[!NOTE] The quick start guide here is a brief introduction to the MyST Sphinx Gallery extension. More detailed Quick Start guide is available at: Quick Start.

Installation

MyST Sphinx Gallery is a Python package, and requires Python >= 3.8. You can install the latest release using pip from the PyPI:

bash pip install myst_sphinx_gallery

or using conda / mamba from the conda-forge channel:

bash conda install -c conda-forge myst-sphinx-gallery

bash mamba install -c conda-forge myst-sphinx-gallery

Configuring the extension

Enable the extension

After installation, you can enable the extension in Sphinx conf.py file:

python extensions = [ ..., # other extensions "myst_sphinx_gallery", ]

[!IMPORTANT] MyST Sphinx Gallery only helps you to generate the gallery. You need to enable the MyST parsers to render the markdown or jupyter notebook files by yourself.

For instance, to enable the MyST-NB, you can add the following code to the conf.py file:

```python extensions = [ ..., "myst_nb", ]

source_suffix = { ".rst": "restructuredtext", ".md": "myst-nb", ".myst": "myst-nb", } ```

For more information, please refer to the documentation of MyST and MyST-NB.

Configuring the variables

MyST Sphinx Gallery has two main configuration variables that can be set in your conf.py file.

  • myst_sphinx_gallery_config : global configuration for all examples using gallery directives or used to generate galleries.
  • myst_sphinx_gallery_files_config : configuration for individual files to override the global configuration for those files.

[!TIP] Those two variables are optional and can be omitted if you don't need to customize the behavior of MyST-Sphinx-Gallery.

More details about the configuration variables can be found in the Configuration Variables section.

Generating gallery

There are two ways to generate galleries in MyST Sphinx Gallery:

  1. Using directives: MyST Sphinx Gallery provides three directives for generating galleries: base-gallery, gallery, and ref-gallery. You can directly use these directives to generate galleries in reStructuredText (.rst), Markdown (.md), and Jupyter Notebook (.ipynb) files.
  2. Configuring in conf.py: You can also generate gallery by specifying the examples and gallery directories in your conf.py file. This method is keeping in line with Sphinx Gallery extension.

[!NOTE] Using directives is highly recommended for generating galleries as it provides more options and flexibility. For instance, you can add tooltip to example cards, call different directives multi-times in a single file to generate a complex gallery. This cannot be done using the configuration method.

You can refer to the Generating Galleries Methods section for more details.

Select the thumbnail for an example file

  • one image - If there only one image in an example file, no additional configuration is needed, and that image will be used as the gallery thumbnail.
  • multiple images - If there are multiple figures in an example file, you can specify the strategy to determine which thumbnail will be used for the gallery. The following strategies are supported:
    1. alt - If the alt attribute of an image/figure is set to gallery_thumbnail, that image/figure will be used as the gallery thumbnail for this file.
    2. first/last - If there are multiple images that can be used as the gallery thumbnail, the first/last image will be selected. You can specify the strategy by setting the thumbnail_strategy in the configuration file. The default value is first.
    3. code/markdown - For Jupyter notebook files, both markdown and code cells can contain images. You can specify the strategy by setting the notebookthumbnailstrategy in the configuration file. The default value is code.
  • no image - If no image/figure is found, the default thumbnail will be used.

More details can be found in the Thumbnail Strategies.

Customizing style of thumbnail and card

You can customize the layout and thumbnail behaviors for the gallery using the MyST Sphinx Gallery extension. For more details, please refer to the section Customizing Style of Thumbnail and Card .

Owner

  • Name: Fanchengyan
  • Login: Fanchengyan
  • Kind: user

GitHub Events

Total
  • Watch event: 3
  • Fork event: 2
Last Year
  • Watch event: 3
  • Fork event: 2

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 59
  • Total Committers: 2
  • Avg Commits per committer: 29.5
  • Development Distribution Score (DDS): 0.017
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
fanchengyan f****4@l****n 58
Raphael Quast q****t@g****t 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 1
  • Total pull requests: 9
  • Average time to close issues: 3 days
  • Average time to close pull requests: about 6 hours
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 9
  • Average time to close issues: 3 days
  • Average time to close pull requests: about 6 hours
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • raphaelquast (1)
Pull Request Authors
  • Fanchengyan (16)
  • raphaelquast (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 1,286 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
pypi.org: myst-sphinx-gallery

A Sphinx extension that builds galleries of examples from any set of myst-style markdown/notebook or rst files.

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,286 Last month
Rankings
Dependent packages count: 10.5%
Average: 34.8%
Dependent repos count: 59.2%
Maintainers (1)
Last synced: 5 months ago

Dependencies

.github/workflows/python-publish.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
docs/requirements.txt pypi
  • Jinja2 *
  • myst-nb *
  • pydata_sphinx_theme *
  • recommonmark *
  • sphinx >=7
  • sphinx-copybutton *
  • sphinx-design *
  • sphinx-togglebutton *
pyproject.toml pypi
  • myst-nb *
  • pillow *
  • sphinx_design *