Skip to content

Commit

Permalink
Merge pull request #2377 from cta-observatory/sphinx-gallery-notebooks
Browse files Browse the repository at this point in the history
Convert all notebooks to sphinx gallery format
  • Loading branch information
maxnoe authored Sep 11, 2023
2 parents 789a41f + 16b5445 commit 3c5b4f3
Show file tree
Hide file tree
Showing 51 changed files with 4,119 additions and 7,220 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ __pycache__
ctapipe/_version_cache.py
ctapipe/_version.py


# Ignore .c files by default to avoid including generated code. If you want to
# add a non-generated .c extension, use `git add -f filename.c`.
*.c
Expand All @@ -25,6 +26,7 @@ MANIFEST
# Sphinx
docs/api
docs/_build
docs/auto_examples

# Editors and IDEs

Expand Down Expand Up @@ -86,7 +88,4 @@ distribute-*.tar.gz
target
.mypy_cache

examples/notebooks/*.html
examples/notebooks/*.png

provenance.log
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ help:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

clean:
rm -rf api
rm -rf api auto_examples
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)


Expand Down
39 changes: 37 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ctapipe documentation build configuration file, created by
# sphinx-quickstart on Fri Jan 6 10:22:58 2017.
#
# This file is execfile()d with the current directory set to its
# Thi file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
Expand All @@ -29,6 +29,9 @@
# Get configuration information from setup.cfg
from configparser import ConfigParser

# Sphinx gallery
from sphinx_gallery.sorting import ExplicitOrder, FileNameSortKey

import ctapipe

setup_cfg = ConfigParser()
Expand All @@ -55,6 +58,7 @@
"numpydoc",
"sphinx_design",
"IPython.sphinxext.ipython_console_highlighting",
"sphinx_gallery.gen_gallery",
]


Expand Down Expand Up @@ -142,6 +146,31 @@ def setup(app):
("py:class", "ctapipe.compat.StrEnum"),
]

# Sphinx gallery config

sphinx_gallery_conf = {
"examples_dirs": [
"../examples",
], # path to your example scripts
"subsection_order": ExplicitOrder(
[
"../examples/tutorials",
"../examples/algorithms",
"../examples/core",
"../examples/visualization",
]
),
"within_subsection_order": FileNameSortKey,
"nested_sections": False,
"filename_pattern": r".*\.py",
"copyfile_regex": r".*\.png",
"promote_jupyter_magic": True,
"line_numbers": True,
"default_thumb_file": "_static/ctapipe_logo.png",
"pypandoc": True,
"matplotlib_animations": True,
}


# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand Down Expand Up @@ -195,6 +224,12 @@ def setup(app):
".DS_Store",
"**.ipynb_checkpoints",
"changes",
"user-guide/examples/*/README.rst",
"user-guide/examples/README.rst",
"auto_examples/index.rst",
"auto_examples/*/*.py.md5",
"auto_examples/*/*.py",
"auto_examples/*/*.ipynb",
]

# The name of the Pygments (syntax highlighting) style to use.
Expand All @@ -209,7 +244,7 @@ def setup(app):
# Define the json_url for our version switcher.
json_url = "https://ctapipe.readthedocs.io/en/latest/_static/switcher.json"

# Define the version we use for matching in the version switcher.
# Define the version we use for matching in the version switcher.,
version_match = os.getenv("READTHEDOCS_VERSION")
# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
# If it is an integer, we're in a PR build and the version isn't correct.
Expand Down
5 changes: 5 additions & 0 deletions docs/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
collect_ignore = [
"conf.py",
"_build",
"auto_examples",
]
Loading

0 comments on commit 3c5b4f3

Please sign in to comment.