-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from JulioAPeraza/plot-surface
Add surface plots to the examples gallery
- Loading branch information
Showing
9 changed files
with
124 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,253 +1,140 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# NiMARE documentation build configuration file, created by | ||
# sphinx-quickstart | ||
# | ||
# This file is execfile()d with the current directory set to its | ||
# containing dir. | ||
# | ||
# Note that not all possible configuration values are present in this | ||
# autogenerated file. | ||
# | ||
# All configuration values have a default; values that are commented out | ||
# serve to show the default. | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
# from datetime import datetime | ||
import os | ||
import sys | ||
from datetime import datetime | ||
from distutils.version import LooseVersion | ||
|
||
import sphinx | ||
from m2r import MdInclude | ||
import brainspace | ||
from sphinx_gallery.sorting import FileNameSortKey | ||
|
||
sys.path.insert(0, os.path.abspath(os.path.pardir)) | ||
sys.path.insert(0, os.path.abspath("sphinxext")) | ||
from github_link import make_linkcode_resolve | ||
brainspace.OFF_SCREEN = True # off screen rendering for examples | ||
|
||
# import gradec | ||
# -- Project information ----------------------------------------------------- | ||
|
||
# -- General configuration ------------------------------------------------ | ||
project = "Gradec" | ||
copyright = "2023-" + datetime.now().strftime("%Y") + ", Gradec developers" | ||
author = "Gradec developers" | ||
|
||
# If your documentation needs a minimal Sphinx version, state it here. | ||
# needs_sphinx = "3.5" | ||
# The full version, including alpha/beta/rc tags | ||
release = "0.1.0" | ||
|
||
# generate autosummary even if no references | ||
autosummary_generate = True | ||
add_module_names = False | ||
# Import project to get version info | ||
sys.path.insert(0, os.path.abspath(os.path.pardir)) | ||
import gradec # noqa | ||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
"sphinx.ext.autodoc", # standard | ||
"sphinx.ext.autosummary", # standard | ||
"sphinx.ext.doctest", # runs doctests | ||
"sphinx.ext.intersphinx", # links code to other packages | ||
"sphinx.ext.linkcode", # links to code from api | ||
"sphinx.ext.napoleon", # alternative to numpydoc | ||
"sphinx_copybutton", # for copying code snippets | ||
"sphinx_gallery.gen_gallery", # example gallery | ||
"sphinxarg.ext", # argparse | ||
"sphinxcontrib.bibtex", # for foot-citations | ||
"recommonmark", # markdown parser | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.autosummary", | ||
"sphinx.ext.doctest", | ||
"sphinx.ext.intersphinx", | ||
"sphinx.ext.mathjax", | ||
"sphinx.ext.napoleon", | ||
"sphinx.ext.viewcode", | ||
"sphinxarg.ext", | ||
"sphinx_gallery.gen_gallery", | ||
"matplotlib.sphinxext.plot_directive", | ||
] | ||
|
||
if LooseVersion(sphinx.__version__) < LooseVersion("1.4"): | ||
extensions.append("sphinx.ext.pngmath") | ||
else: | ||
extensions.append("sphinx.ext.imgmath") | ||
# Generate the API documentation when building | ||
autosummary_generate = True | ||
autodoc_default_options = {"members": True, "inherited-members": True} | ||
numpydoc_show_class_members = False | ||
autoclass_content = "class" | ||
|
||
napoleon_google_docstring = False | ||
napoleon_numpy_docstring = True | ||
napoleon_include_init_with_doc = False | ||
napoleon_include_special_with_doc = False | ||
napoleon_use_param = True | ||
napoleon_use_ivar = True | ||
napoleon_use_rtype = False | ||
|
||
napoleon_include_private_with_doc = False | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ["_templates"] | ||
|
||
# source_suffix = ['.rst', '.md'] | ||
# The suffix(es) of source filenames. | ||
source_suffix = ".rst" | ||
|
||
# The master toctree document. | ||
master_doc = "index" | ||
|
||
# General information about the project. | ||
project = "Gradec" | ||
copyright = "2023-" + datetime.now().strftime("%Y") + ", Gradec developers" | ||
author = "Gradec developers" | ||
|
||
# The version info for the project you're documenting, acts as replacement for | ||
# |version| and |release|, also used in various other places throughout the | ||
# built documents. | ||
# | ||
# The short X.Y version. | ||
# version = gradec.__version__ | ||
# The full version, including alpha/beta/rc tags. | ||
# release = gradec.__version__ | ||
|
||
# The language for content autogenerated by Sphinx. Refer to documentation | ||
# for a list of supported languages. | ||
# | ||
# This is also used if you do content translation via gettext catalogs. | ||
# Usually you set "language" from the command line for these cases. | ||
language = "en" | ||
language = None | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This patterns also effect to html_static_path and html_extra_path | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "utils/*"] | ||
|
||
# The reST default role (used for this markup: `text`) to use for all documents. | ||
default_role = "autolink" | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
||
# The name of the Pygments (syntax highlighting) style to use. | ||
pygments_style = "default" | ||
pygments_style = "sphinx" | ||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
import sphinx_rtd_theme # noqa | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Napoleon settings | ||
# ----------------------------------------------------------------------------- | ||
napoleon_google_docstring = False | ||
napoleon_numpy_docstring = True | ||
napoleon_custom_sections = ["License"] | ||
napoleon_include_init_with_doc = True | ||
napoleon_include_private_with_doc = False | ||
napoleon_include_special_with_doc = False | ||
napoleon_use_admonition_for_examples = True | ||
napoleon_use_admonition_for_notes = True | ||
napoleon_use_admonition_for_references = True | ||
napoleon_use_ivar = True | ||
napoleon_use_param = True | ||
napoleon_use_keyword = True | ||
napoleon_use_rtype = True | ||
napoleon_preprocess_types = False | ||
napoleon_type_aliases = None | ||
napoleon_attr_annotations = True | ||
|
||
# ----------------------------------------------------------------------------- | ||
# HTML output | ||
# ----------------------------------------------------------------------------- | ||
# The theme to use for HTML and HTML Help pages. | ||
# See the documentation for a list of builtin themes. | ||
html_theme = "sphinx_rtd_theme" | ||
html_show_sourcelink = False | ||
|
||
# Theme options are theme-specific and customize the look and feel of a theme further. | ||
# For a list of options available for each theme, see the documentation. | ||
html_theme_options = { | ||
"includehidden": False, # don't show hidden TOCs in sidebar | ||
} | ||
html_sidebars = {"**": ["globaltoc.html", "relations.html", "searchbox.html", "indexsidebar.html"]} | ||
# Theme options are theme-specific and customize the look and feel of a theme | ||
# further. For a list of options available for each theme, see the | ||
# documentation. | ||
html_theme_options = {} | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ["_static"] | ||
|
||
# html_favicon = "_static/nimare_favicon.png" | ||
# html_logo = "_static/nimare_banner.png" | ||
# CSS files to include | ||
html_css_files = ["theme_overrides.css"] | ||
|
||
# -- Options for HTMLHelp output --------------------------------------------- | ||
|
||
# ----------------------------------------------------------------------------- | ||
# HTMLHelp output | ||
# ----------------------------------------------------------------------------- | ||
# Output file base name for HTML help builder. | ||
htmlhelp_basename = "nimaredoc" | ||
|
||
# The following is used by sphinx.ext.linkcode to provide links to github | ||
linkcode_resolve = make_linkcode_resolve( | ||
"gradec", | ||
"https://github.com/JulioAPeraza/gradec/blob/{revision}/{package}/{path}#L{lineno}", | ||
) | ||
|
||
# ----------------------------------------------------------------------------- | ||
# intersphinx | ||
# ----------------------------------------------------------------------------- | ||
_python_version_str = "{0.major}.{0.minor}".format(sys.version_info) | ||
_python_doc_base = f"https://docs.python.org/{_python_version_str}" | ||
htmlhelp_basename = "gradecdoc" | ||
|
||
# -- Extension configuration ------------------------------------------------- | ||
intersphinx_mapping = { | ||
"python": (_python_doc_base, None), | ||
"numpy": ("https://numpy.org/doc/stable/", (None, "./_intersphinx/numpy-objects.inv")), | ||
"scipy": ( | ||
"https://docs.scipy.org/doc/scipy/reference", | ||
(None, "./_intersphinx/scipy-objects.inv"), | ||
), | ||
"sklearn": ("https://scikit-learn.org/stable", (None, "./_intersphinx/sklearn-objects.inv")), | ||
"matplotlib": ("https://matplotlib.org/", (None, "https://matplotlib.org/objects.inv")), | ||
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None), | ||
"nibabel": ("https://nipy.org/nibabel/", None), | ||
"nilearn": ("http://nilearn.github.io/stable/", None), | ||
"pymare": ("https://pymare.readthedocs.io/en/latest/", None), | ||
"skimage": ("https://scikit-image.org/docs/stable/", None), | ||
"brainspace": ("https://brainspace.readthedocs.io/en/latest/", None), | ||
"neuromaps": ("https://netneurolab.github.io/neuromaps/", None), | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Sphinx gallery | ||
# ----------------------------------------------------------------------------- | ||
sphinx_gallery_conf = { | ||
# path to your examples scripts | ||
"examples_dirs": "../examples", | ||
# run examples with a number, then "plot" | ||
"filename_pattern": "/[0-9]+_plot_", | ||
# path where to save gallery generated examples | ||
"gallery_dirs": "auto_examples", | ||
"backreferences_dir": "generated", | ||
# Modules for which function level galleries are created. | ||
# In this case sphinx_gallery and numpy in a tuple of strings. | ||
"doc_module": ("gradec"), | ||
"ignore_pattern": r"misc-notebooks/.", | ||
"reference_url": { | ||
# The module you locally document uses None | ||
"gradec": None | ||
}, | ||
"within_subsection_order": FileNameSortKey, | ||
"thumbnail_size": (250, 250), | ||
"remove_config_comments": True, | ||
"image_scrapers": ("matplotlib"), | ||
"within_subsection_order": FileNameSortKey, | ||
"download_all_examples": False, | ||
} | ||
|
||
# Generate the plots for the gallery | ||
plot_gallery = "True" | ||
|
||
# ----------------------------------------------------------------------------- | ||
# sphinxcontrib-bibtex | ||
# ----------------------------------------------------------------------------- | ||
bibtex_bibfiles = ["./references.bib"] | ||
bibtex_style = "unsrt" | ||
bibtex_reference_style = "author_year" | ||
bibtex_footbibliography_header = "" | ||
|
||
|
||
def touch_example_backreferences(app, what, name, obj, options, lines): | ||
# generate empty examples files, so that we don't get | ||
# inclusion errors if there are no examples for a class / module | ||
examples_path = os.path.join(app.srcdir, "generated", f"{name}.examples") | ||
if not os.path.exists(examples_path): | ||
# touch file | ||
open(examples_path, "w").close() | ||
|
||
|
||
def setup(app): | ||
"""From https://github.com/rtfd/sphinx_rtd_theme/issues/117""" | ||
app.connect("autodoc-process-docstring", touch_example_backreferences) | ||
# Fix to https://github.com/sphinx-doc/sphinx/issues/7420 | ||
# from https://github.com/life4/deal/commit/7f33cbc595ed31519cefdfaaf6f415dada5acd94 | ||
# from m2r to make `mdinclude` work | ||
app.add_config_value("no_underscore_emphasis", False, "env") | ||
app.add_config_value("m2r_parse_relative_links", False, "env") | ||
app.add_config_value("m2r_anonymous_references", False, "env") | ||
app.add_config_value("m2r_disable_inline_math", False, "env") | ||
app.add_directive("mdinclude", MdInclude) | ||
|
||
|
||
def generate_example_rst(app, what, name, obj, options, lines): | ||
# generate empty examples files, so that we don't get | ||
# inclusion errors if there are no examples for a class / module | ||
folder = os.path.join(app.srcdir, "generated") | ||
if not os.path.isdir(folder): | ||
os.makedirs(folder) | ||
|
||
examples_path = os.path.join(app.srcdir, "generated", f"{name}.examples") | ||
if not os.path.exists(examples_path): | ||
# touch file | ||
open(examples_path, "w").close() | ||
doctest_global_setup = """\ | ||
import numpy as np | ||
np.random.seed(1234)\ | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: gradec_env | ||
|
||
channels: | ||
- conda-forge | ||
|
||
dependencies: | ||
- python=3.9 | ||
- sphinx>=2.0 | ||
- sphinx_rtd_theme | ||
- sphinx-gallery | ||
- sphinx-gallery | ||
- pip | ||
- pip: | ||
- .. | ||
- sphinx_argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sphinx>=2.0 | ||
sphinx_rtd_theme | ||
sphinx-gallery | ||
sphinx-gallery | ||
sphinx_argparse |
Oops, something went wrong.