Code Monkey home page Code Monkey logo

sphinx-gallery.github.io's Introduction

Sphinx-Gallery

PyPI

Conda-forge

Zenodo DOI

CircleCI status

Code coverage

A Sphinx extension that builds an HTML gallery of examples from any set of Python scripts. Check out the documentation for introductions on how to use it and more...

A demo of a gallery generated by Sphinx-Gallery

Quickstart

Sphinx-Gallery can be used to generate an example gallery from .py files, for a library, as well as a stand-alone web page showcasing examples of a particular Python package, module, or class.

Let's get started with a simple example or check out the

documentation for introductions on how to use it and more...

Install via pip

You can do a direct install via pip by using:

$ pip install sphinx-gallery "sphinx>=4.0" pillow

Important

Sphinx-Gallery will not manage its dependencies when installing, thus you are required to install them manually. Our minimal dependencies are Sphinx >= 4 and Pillow, which we use for scaling images.

Tip

Sphinx-Gallery also has support for scraping images from Matplotlib and Matplotlib-based packages such as Seaborn. We recommend installing system optipng binaries to reduce the file sizes of the generated PNG files.

Add examples to your docs

Let's assume simple scenario, you have a Python package with a directory structure like this:

├── doc
│   ├── conf.py
│   ├── index.rst
|   ├── make.bat
│   └── Makefile
├── my_python_module
│   ├── __init__.py
│   └── mod.py
└── examples
    ├── plot_example.py
    └── README.txt (or .rst)

Enable Sphinx-Gallery by adding the following to your doc/conf.py:

extensions = [
    ...
    'sphinx_gallery.gen_gallery',
]

# path to the examples scripts
sphinx_gallery_conf = {
    'examples_dirs': '../examples',   # path to your example scripts
    'gallery_dirs': 'auto_examples',  # path to where to save gallery generated output
}

Finally just compile your docs as usual. Sphinx-Gallery will generate reST files, adding execution outputs, and save them in auto_examples/. Add a link to auto_examples/index.rst to include the gallery in your documentation.

An incomplete list:

Contributing

You can get the latest development source from our Github repository. You need setuptools installed in your system to install Sphinx-Gallery. For example, you can do:

$ git clone https://github.com/sphinx-gallery/sphinx-gallery
$ cd sphinx-gallery
$ pip install -r requirements.txt -r dev-requirements.txt
$ conda install graphviz  # if using conda, you can get graphviz this way
$ pip install -e .

Check that you are all set by running:

$ pytest sphinx_gallery

How to cite

If you would like to cite Sphinx-Gallery you can do so using our Zenodo deposit.

sphinx-gallery.github.io's People

Contributors

larsoner avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.