|
| 1 | +# Configuration file for the Sphinx documentation builder. |
| 2 | +# |
| 3 | +# This file only contains a selection of the most common options. For a full |
| 4 | +# list see the documentation: |
| 5 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 6 | + |
| 7 | +# -- Path setup -------------------------------------------------------------- |
| 8 | + |
| 9 | +import inspect |
| 10 | + |
| 11 | +# If extensions (or modules to document with autodoc) are in another directory, |
| 12 | +# add these directories to sys.path here. If the directory is relative to the |
| 13 | +# documentation root, use os.path.abspath to make it absolute, like shown here. |
| 14 | +# |
| 15 | +import os |
| 16 | +import sys |
| 17 | + |
| 18 | +try: |
| 19 | + from ipympl import __version__ as release |
| 20 | +except ImportError: |
| 21 | + release = "unknown" |
| 22 | + |
| 23 | + |
| 24 | +# -- Project information ----------------------------------------------------- |
| 25 | + |
| 26 | +project = "ipympl" |
| 27 | +copyright = "2022, Matplotlib Development Team" |
| 28 | +author = "Matplotlib Development Team" |
| 29 | + |
| 30 | + |
| 31 | +# -- General configuration --------------------------------------------------- |
| 32 | + |
| 33 | +# Add any Sphinx extension module names here, as strings. They can be |
| 34 | +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
| 35 | +# ones. |
| 36 | +extensions = [ |
| 37 | + "jupyter_sphinx", |
| 38 | + "myst_nb", |
| 39 | + "sphinx.ext.intersphinx", |
| 40 | + "sphinx.ext.linkcode", |
| 41 | + "sphinx.ext.mathjax", |
| 42 | + "sphinx_copybutton", |
| 43 | + "sphinx_panels", |
| 44 | + "sphinx_thebe", |
| 45 | + "sphinx_togglebutton", |
| 46 | +] |
| 47 | + |
| 48 | + |
| 49 | +# Cross-referencing configuration |
| 50 | +default_role = "py:obj" |
| 51 | +primary_domain = "py" |
| 52 | +nitpicky = True # warn if cross-references are missing |
| 53 | + |
| 54 | +# Intersphinx settings |
| 55 | +intersphinx_mapping = { |
| 56 | + "ipywidgets": ("https://ipywidgets.readthedocs.io/en/stable", None), |
| 57 | + "matplotlib": ("https://matplotlib.org/stable", None), |
| 58 | + "numpy": ("https://numpy.org/doc/stable", None), |
| 59 | + "python": ("https://docs.python.org/3", None), |
| 60 | +} |
| 61 | + |
| 62 | +# remove panels css to get wider main content |
| 63 | +panels_add_bootstrap_css = False |
| 64 | + |
| 65 | +# Settings for copybutton |
| 66 | +copybutton_prompt_is_regexp = True |
| 67 | +copybutton_prompt_text = r">>> |\.\.\. " # doctest |
| 68 | + |
| 69 | +# Settings for linkcheck |
| 70 | +linkcheck_anchors = False |
| 71 | +linkcheck_ignore = [] # type: ignore |
| 72 | + |
| 73 | +execution_timeout = -1 |
| 74 | +jupyter_execute_notebooks = "off" |
| 75 | +if "EXECUTE_NB" in os.environ: |
| 76 | + print("\033[93;1mWill run Jupyter notebooks!\033[0m") |
| 77 | + jupyter_execute_notebooks = "force" |
| 78 | + |
| 79 | +# Settings for myst-parser |
| 80 | +myst_enable_extensions = [ |
| 81 | + "amsmath", |
| 82 | + "colon_fence", |
| 83 | + "dollarmath", |
| 84 | + "smartquotes", |
| 85 | + "substitution", |
| 86 | +] |
| 87 | +suppress_warnings = [ |
| 88 | + "myst.header", |
| 89 | +] |
| 90 | + |
| 91 | +# Add any paths that contain templates here, relative to this directory. |
| 92 | +templates_path = ["_templates"] |
| 93 | + |
| 94 | +# List of patterns, relative to source directory, that match files and |
| 95 | +# directories to ignore when looking for source files. |
| 96 | +# This pattern also affects html_static_path and html_extra_path. |
| 97 | +exclude_patterns = [ |
| 98 | + "**ipynb_checkpoints", |
| 99 | + ".DS_Store", |
| 100 | + "Thumbs.db", |
| 101 | + "_build", |
| 102 | +] |
| 103 | + |
| 104 | + |
| 105 | +# -- Options for HTML output ------------------------------------------------- |
| 106 | + |
| 107 | +# The theme to use for HTML and HTML Help pages. See the documentation for |
| 108 | +# a list of builtin themes. |
| 109 | +# |
| 110 | +html_copy_source = True # needed for download notebook button |
| 111 | +html_css_files = [ |
| 112 | + "custom.css", |
| 113 | +] |
| 114 | +html_sourcelink_suffix = "" |
| 115 | +html_static_path = ["_static"] |
| 116 | +html_theme = "sphinx_book_theme" |
| 117 | +html_theme_options = { |
| 118 | + "launch_buttons": { |
| 119 | + "binderhub_url": "https://mybinder.org", |
| 120 | + "colab_url": "https://colab.research.google.com", |
| 121 | + "notebook_interface": "jupyterlab", |
| 122 | + "thebe": True, |
| 123 | + "thebelab": True, |
| 124 | + }, |
| 125 | + "path_to_docs": "docs", |
| 126 | + "repository_branch": "main", |
| 127 | + "repository_url": "https://github.com/matplotlib/ipympl", |
| 128 | + "use_download_button": True, |
| 129 | + "use_edit_page_button": True, |
| 130 | + "use_issues_button": True, |
| 131 | + "use_repository_button": True, |
| 132 | +} |
| 133 | +html_title = "ipympl" |
| 134 | + |
| 135 | +master_doc = "index" |
| 136 | +thebe_config = { |
| 137 | + "repository_url": html_theme_options["repository_url"], |
| 138 | + "repository_branch": html_theme_options["repository_branch"], |
| 139 | +} |
| 140 | + |
| 141 | + |
| 142 | +# based on pandas/doc/source/conf.py |
| 143 | +def linkcode_resolve(domain, info): |
| 144 | + """ |
| 145 | + Determine the URL corresponding to Python object |
| 146 | + """ |
| 147 | + if domain != "py": |
| 148 | + return None |
| 149 | + |
| 150 | + modname = info["module"] |
| 151 | + fullname = info["fullname"] |
| 152 | + |
| 153 | + submod = sys.modules.get(modname) |
| 154 | + if submod is None: |
| 155 | + return None |
| 156 | + |
| 157 | + obj = submod |
| 158 | + for part in fullname.split("."): |
| 159 | + try: |
| 160 | + obj = getattr(obj, part) |
| 161 | + except AttributeError: |
| 162 | + return None |
| 163 | + |
| 164 | + try: |
| 165 | + fn = inspect.getsourcefile(inspect.unwrap(obj)) |
| 166 | + except TypeError: |
| 167 | + fn = None |
| 168 | + if not fn: |
| 169 | + return None |
| 170 | + |
| 171 | + try: |
| 172 | + source, lineno = inspect.getsourcelines(obj) |
| 173 | + except OSError: |
| 174 | + lineno = None |
| 175 | + |
| 176 | + if lineno: |
| 177 | + linespec = f"#L{lineno}-L{lineno + len(source) - 1}" |
| 178 | + else: |
| 179 | + linespec = "" |
| 180 | + |
| 181 | + fn = os.path.relpath(fn, start=os.path.dirname("../ipympl")) |
| 182 | + |
| 183 | + return ( |
| 184 | + f"https://github.com/matplotlib/ipympl/blob/main/ipympl/{fn}{linespec}" # noqa |
| 185 | + ) |
0 commit comments