<h1 align="center">
<img src="https://raw.githubusercontent.com/Fanchengyan/myst-sphinx-gallery/main/docs/source/_static/logo/logo.svg" width="400">
</h1><br>
[![Conda Recipe](https://img.shields.io/badge/recipe-myst--sphinx--gallery-green.svg)](https://anaconda.org/conda-forge/myst-sphinx-gallery)
[![Documentation Status](https://readthedocs.org/projects/myst-sphinx-gallery/badge/?version=latest)](https://myst-sphinx-gallery.readthedocs.io/en/latest/?badge=latest)
[![Language](https://img.shields.io/badge/python-3.8%2B-blue.svg?style=flat-square)](https://www.python.org/)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/myst-sphinx-gallery.svg)](https://anaconda.org/conda-forge/myst-sphinx-gallery)
[![PyPI](https://img.shields.io/pypi/v/myst-sphinx-gallery)](https://pypi.org/project/myst-sphinx-gallery/)
[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/myst-sphinx-gallery.svg)](https://anaconda.org/conda-forge/myst-sphinx-gallery)
[![tests](https://github.com/Fanchengyan/myst-sphinx-gallery/actions/workflows/tests.yml/badge.svg)](https://github.com/Fanchengyan/myst-sphinx-gallery/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/Fanchengyan/myst-sphinx-gallery/graph/badge.svg?token=IHXYE1K1G9)](https://codecov.io/gh/Fanchengyan/myst-sphinx-gallery)
## 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](https://sphinx-gallery.github.io/stable/index.html)
extension, but aim to provide a simple and efficient way to create
galleries written in a variety of file formats.
![gallery_example](docs/source/_static/gallery_example.png)
## 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](https://myst-parser.readthedocs.io/en/latest/) and [MyST-NB](https://myst-nb.readthedocs.io/en/latest/), 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/](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](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/quick_start.html).
## 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](https://myst-parser.readthedocs.io/en/latest/) and [MyST-NB]( https://myst-nb.readthedocs.io/en/latest/).
## 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](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/config.html) 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](https://sphinx-gallery.github.io/stable/index.html) 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](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/gen_gallery.html) 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 notebook_thumbnail_strategy 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](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/thumb.html).
## 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
](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/custom.html).
Raw data
{
"_id": null,
"home_page": null,
"name": "myst-sphinx-gallery",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "gallery, markdown, parser, jupyter, docutils, sphinx",
"author": null,
"author_email": "\"Chengyan Fan (Fancy)\" <fanchengyan@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/cc/3a/8136546c8265f998aaf8b6914249e0655c1232aa1d7f22b20b4bbd1ddebe/myst_sphinx_gallery-0.3.0.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">\n<img src=\"https://raw.githubusercontent.com/Fanchengyan/myst-sphinx-gallery/main/docs/source/_static/logo/logo.svg\" width=\"400\">\n</h1><br>\n\n\n[![Conda Recipe](https://img.shields.io/badge/recipe-myst--sphinx--gallery-green.svg)](https://anaconda.org/conda-forge/myst-sphinx-gallery)\n[![Documentation Status](https://readthedocs.org/projects/myst-sphinx-gallery/badge/?version=latest)](https://myst-sphinx-gallery.readthedocs.io/en/latest/?badge=latest)\n[![Language](https://img.shields.io/badge/python-3.8%2B-blue.svg?style=flat-square)](https://www.python.org/)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/myst-sphinx-gallery.svg)](https://anaconda.org/conda-forge/myst-sphinx-gallery)\n[![PyPI](https://img.shields.io/pypi/v/myst-sphinx-gallery)](https://pypi.org/project/myst-sphinx-gallery/)\n[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/myst-sphinx-gallery.svg)](https://anaconda.org/conda-forge/myst-sphinx-gallery)\n[![tests](https://github.com/Fanchengyan/myst-sphinx-gallery/actions/workflows/tests.yml/badge.svg)](https://github.com/Fanchengyan/myst-sphinx-gallery/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/Fanchengyan/myst-sphinx-gallery/graph/badge.svg?token=IHXYE1K1G9)](https://codecov.io/gh/Fanchengyan/myst-sphinx-gallery)\n\n\n## Introduction\n\n**MyST Sphinx Gallery** is a Sphinx extension that allows you to build\ngalleries from jupyter notebooks (`.ipynb`), markdown (`.md`) or\nreStructuredText (`.rst`) files.\n\nThis extension is functionally similar to the\n[Sphinx-Gallery](https://sphinx-gallery.github.io/stable/index.html)\nextension, but aim to provide a simple and efficient way to create\ngalleries written in a variety of file formats.\n\n\n![gallery_example](docs/source/_static/gallery_example.png)\n\n## Highlight Features\n\n- **Easy to use** - It provides a set of `directives` to generate\n galleries, as simple as adding `toctree`.\n- **Flexible** - You can easily generate a gallery of examples from your\n Jupyter Notebooks, Markdown, or reStructuredText files. It works with `MyST` Ecosystem, including [MyST-parser](https://myst-parser.readthedocs.io/en/latest/) and [MyST-NB](https://myst-nb.readthedocs.io/en/latest/), to render markdown or jupyter notebooks in Sphinx documentation.\n- **Fast and robust** - It utilizes existing images to generate gallery\n thumbnails, eliminating code execution delays and potential accidental errors\n when building gallery.\n- **Customizable** - You can customize the gallery, such as thumbnail\n selection, and style of the gallery.\n\n\n## Documentation\n\nThe detailed documentation is available at: [https://myst-sphinx-gallery.readthedocs.io/en/latest/](https://myst-sphinx-gallery.readthedocs.io/en/latest/)\n\n## Quick Start\n\n> [!NOTE]\n> 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](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/quick_start.html).\n\n\n## Installation\n\n**MyST Sphinx Gallery** is a Python package, and requires `Python >= 3.8`. You can install the latest release using `pip` from the PyPI:\n\n```bash\npip install myst_sphinx_gallery\n```\n\nor using `conda` / `mamba` from the conda-forge channel:\n\n```bash\nconda install -c conda-forge myst-sphinx-gallery\n```\n\n```bash\nmamba install -c conda-forge myst-sphinx-gallery\n```\n\n## Configuring the extension\n\n### Enable the extension\n\nAfter installation, you can enable the extension in Sphinx `conf.py` file:\n\n```python\n extensions = [\n ..., # other extensions\n \"myst_sphinx_gallery\",\n ]\n```\n\n>[!IMPORTANT]\n>**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.\n>\n>For instance, to enable the MyST-NB, you can add the following code to the `conf.py` file:\n>\n>```python\n>extensions = [\n> ...,\n> \"myst_nb\",\n>]\n>\n>source_suffix = {\n> \".rst\": \"restructuredtext\",\n> \".md\": \"myst-nb\",\n> \".myst\": \"myst-nb\",\n>}\n>```\n>\n>For more information, please refer to the documentation of [MyST](https://myst-parser.readthedocs.io/en/latest/) and [MyST-NB]( https://myst-nb.readthedocs.io/en/latest/).\n\n## Configuring the variables\n\n\nMyST Sphinx Gallery has two main configuration variables that can be set in\nyour `conf.py` file.\n\n- `myst_sphinx_gallery_config` : **global configuration** for all examples\n using gallery directives or used to **generate galleries**.\n- `myst_sphinx_gallery_files_config` : **configuration for individual files**\n to override the global configuration for those files.\n\n> [!TIP]\n>Those two variables are optional and can be omitted if you don't need to customize the behavior of MyST-Sphinx-Gallery.\n\nMore details about the configuration variables can be found in the\n[Configuration Variables](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/config.html) section.\n\n## Generating gallery\n\nThere are two ways to generate galleries in MyST Sphinx Gallery:\n\n1. **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.\n2. **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](https://sphinx-gallery.github.io/stable/index.html) extension.\n\n\n> [!NOTE]\n>**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.\n\nYou can refer to the [Generating Galleries Methods](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/gen_gallery.html) section for more details.\n\n\n\n## Select the thumbnail for an example file\n\n- **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.\n- **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:\n 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.\n 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.\n 3. **code/markdown** - For Jupyter notebook files, both markdown and code cells can contain images. You can specify the strategy by setting the notebook_thumbnail_strategy in the configuration file. The default value is code.\n- **no image** - If no image/figure is found, the default thumbnail will be used.\n\n\nMore details can be found in the [Thumbnail Strategies](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/thumb.html).\n\n## Customizing style of thumbnail and card\n\nYou 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\n](https://myst-sphinx-gallery.readthedocs.io/en/latest/user_guide/custom.html).\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A Sphinx extension that builds galleries of examples from any set of myst-style markdown/notebook or rst files.",
"version": "0.3.0",
"project_urls": {
"Documentation": "https://myst-sphinx-gallery.readthedocs.io/en/latest/",
"Source": "https://github.com/Fanchengyan/myst-sphinx-gallery"
},
"split_keywords": [
"gallery",
" markdown",
" parser",
" jupyter",
" docutils",
" sphinx"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b44129933c950e353ec15f8dd65ca3ac08b14939f616dca8ad054b8cf58273d6",
"md5": "5b7a315a9c588a82d684f7530780e2d8",
"sha256": "6ebac1d4fec8f20ac0c59d75e63db62445b2613a01722c62d1e54bb61a709b3c"
},
"downloads": -1,
"filename": "myst_sphinx_gallery-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5b7a315a9c588a82d684f7530780e2d8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 37264,
"upload_time": "2024-09-06T08:29:37",
"upload_time_iso_8601": "2024-09-06T08:29:37.367281Z",
"url": "https://files.pythonhosted.org/packages/b4/41/29933c950e353ec15f8dd65ca3ac08b14939f616dca8ad054b8cf58273d6/myst_sphinx_gallery-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cc3a8136546c8265f998aaf8b6914249e0655c1232aa1d7f22b20b4bbd1ddebe",
"md5": "c201fe3cb0b5fbfd2049d99c3a3703f7",
"sha256": "bc22d6ad4e486f8a11233f1a78bb4790220cb62725674acb7c978cf9144f175c"
},
"downloads": -1,
"filename": "myst_sphinx_gallery-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "c201fe3cb0b5fbfd2049d99c3a3703f7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 45384,
"upload_time": "2024-09-06T08:29:38",
"upload_time_iso_8601": "2024-09-06T08:29:38.965235Z",
"url": "https://files.pythonhosted.org/packages/cc/3a/8136546c8265f998aaf8b6914249e0655c1232aa1d7f22b20b4bbd1ddebe/myst_sphinx_gallery-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-06 08:29:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Fanchengyan",
"github_project": "myst-sphinx-gallery",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "myst-sphinx-gallery"
}