Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
chemiscope 0.8.5 documentation
Logo
chemiscope 0.8.5 documentation
  • Chemiscope
  • Examples
    • Simple chemiscope input
    • Structure-property maps
    • Trajectory plotting
    • Atom property coloring
    • Shape visualization
    • Exploring dataset with chemiscope
    • Advanced dataset exploration
    • Using metatomic models for dataset exploration
    • Showing custom bonds using stk
  • User manual
    • Introduction to structural properties
    • Different panels and settings
    • Chemiscope input files
    • Sharing datasets with collaborators
  • Python module
    • Installation
    • Command line interface
    • chemiscope functions reference
    • Jupyter notebooks
    • Chemiscope in sphinx
    • Use with sphinx-gallery
  • Chemiscope as a library
Back to top
View this page

Use with sphinx-gallery¶

The chemiscope widgets double up in the documentation of python packages using sphinx_gallery - a sphinx extension that executes python scripts and formats their output as static pages inside the documentation. You can look at the examples to see how the widgets get displayed inside a documentation, and read the documentation of sphinx_gallery if you never used it.

Here we just provide a short explanation of how to modify an existing sphinx-gallery setup to include chemiscope widgets in the examples.

Using widgets in the examples¶

Showing a widget in an example file is as simple as using chemiscope.show() in the example file. The widgets will be shown in a similar style as that shown in the jupyter interface, including the possibility of showing only the structure or map viewers. In practice, this relies on the same custom RST directive used for the sphinx extension.

Setting up sphinx-gallery¶

In order to enable the display of chemiscope widgets in the documentation, assuming you already have a sphinx_gallery setup, you need to activate the custom scraper from the chemiscope module.

The conf.py file in the documentation should include the appropriate extension (usually you’ll be adding this to a list of other extensions)

extensions = [ "chemiscope.sphinx" ]

Furthermore, you need to specify that sphinx_gallery should use the custom chemiscope scraper (again, you’ll typically add this to a tuple of other scrapers)

sphinx_gallery_conf = {
    "image_scrapers": ( ChemiscopeScraper(), ),
}
Next
Chemiscope as a library
Previous
Chemiscope in sphinx
Copyright © 2021, Guillaume Fraux
Made with Sphinx and @pradyunsg's Furo
On this page
  • Use with sphinx-gallery
    • Using widgets in the examples
    • Setting up sphinx-gallery