-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
conf.py
387 lines (320 loc) · 12.7 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
#
# xarray documentation build configuration file, created by
# sphinx-quickstart on Thu Feb 6 18:57:54 2014.
#
# 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.
import datetime
import inspect
import os
import subprocess
import sys
from contextlib import suppress
import sphinx_autosummary_accessors
import xarray
allowed_failures = set()
print("python exec:", sys.executable)
print("sys.path:", sys.path)
if "conda" in sys.executable:
print("conda environment:")
subprocess.run(["conda", "list"])
else:
print("pip environment:")
subprocess.run([sys.executable, "-m", "pip", "list"])
print(f"xarray: {xarray.__version__}, {xarray.__file__}")
with suppress(ImportError):
import matplotlib
matplotlib.use("Agg")
try:
import rasterio # noqa: F401
except ImportError:
allowed_failures.update(
["gallery/plot_rasterio_rgb.py", "gallery/plot_rasterio.py"]
)
try:
import cartopy # noqa: F401
except ImportError:
allowed_failures.update(
[
"gallery/plot_cartopy_facetgrid.py",
"gallery/plot_rasterio_rgb.py",
"gallery/plot_rasterio.py",
]
)
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# 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",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"IPython.sphinxext.ipython_directive",
"IPython.sphinxext.ipython_console_highlighting",
"nbsphinx",
"sphinx_autosummary_accessors",
"sphinx.ext.linkcode",
"sphinx_panels",
"sphinxext.opengraph",
"sphinx_copybutton",
"sphinxext.rediraffe",
]
extlinks = {
"issue": ("https://github.com/pydata/xarray/issues/%s", "GH"),
"pull": ("https://github.com/pydata/xarray/pull/%s", "PR"),
}
# sphinx-copybutton configurations
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
copybutton_prompt_is_regexp = True
# nbsphinx configurations
nbsphinx_timeout = 600
nbsphinx_execute = "always"
nbsphinx_prolog = """
{% set docname = env.doc2path(env.docname, base=None) %}
You can run this notebook in a `live session <https://mybinder.org/v2/gh/pydata/xarray/doc/examples/main?urlpath=lab/tree/doc/{{ docname }}>`_ |Binder| or view it `on Github <https://github.com/pydata/xarray/blob/main/doc/{{ docname }}>`_.
.. |Binder| image:: https://mybinder.org/badge.svg
:target: https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/{{ docname }}
"""
autosummary_generate = True
autodoc_typehints = "none"
# Napoleon configurations
napoleon_google_docstring = False
napoleon_numpy_docstring = True
napoleon_use_param = False
napoleon_use_rtype = False
napoleon_preprocess_types = True
napoleon_type_aliases = {
# general terms
"sequence": ":term:`sequence`",
"iterable": ":term:`iterable`",
"callable": ":py:func:`callable`",
"dict_like": ":term:`dict-like <mapping>`",
"dict-like": ":term:`dict-like <mapping>`",
"path-like": ":term:`path-like <path-like object>`",
"mapping": ":term:`mapping`",
"file-like": ":term:`file-like <file-like object>`",
# special terms
# "same type as caller": "*same type as caller*", # does not work, yet
# "same type as values": "*same type as values*", # does not work, yet
# stdlib type aliases
"MutableMapping": "~collections.abc.MutableMapping",
"sys.stdout": ":obj:`sys.stdout`",
"timedelta": "~datetime.timedelta",
"string": ":class:`string <str>`",
# numpy terms
"array_like": ":term:`array_like`",
"array-like": ":term:`array-like <array_like>`",
"scalar": ":term:`scalar`",
"array": ":term:`array`",
"hashable": ":term:`hashable <name>`",
# matplotlib terms
"color-like": ":py:func:`color-like <matplotlib.colors.is_color_like>`",
"matplotlib colormap name": ":doc:`matplotlib colormap name <matplotlib:gallery/color/colormap_reference>`",
"matplotlib axes object": ":py:class:`matplotlib axes object <matplotlib.axes.Axes>`",
"colormap": ":py:class:`colormap <matplotlib.colors.Colormap>`",
# objects without namespace: xarray
"DataArray": "~xarray.DataArray",
"Dataset": "~xarray.Dataset",
"Variable": "~xarray.Variable",
"DatasetGroupBy": "~xarray.core.groupby.DatasetGroupBy",
"DataArrayGroupBy": "~xarray.core.groupby.DataArrayGroupBy",
# objects without namespace: numpy
"ndarray": "~numpy.ndarray",
"MaskedArray": "~numpy.ma.MaskedArray",
"dtype": "~numpy.dtype",
"ComplexWarning": "~numpy.ComplexWarning",
# objects without namespace: pandas
"Index": "~pandas.Index",
"MultiIndex": "~pandas.MultiIndex",
"CategoricalIndex": "~pandas.CategoricalIndex",
"TimedeltaIndex": "~pandas.TimedeltaIndex",
"DatetimeIndex": "~pandas.DatetimeIndex",
"Series": "~pandas.Series",
"DataFrame": "~pandas.DataFrame",
"Categorical": "~pandas.Categorical",
"Path": "~~pathlib.Path",
# objects with abbreviated namespace (from pandas)
"pd.Index": "~pandas.Index",
"pd.NaT": "~pandas.NaT",
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates", sphinx_autosummary_accessors.templates_path]
# The suffix of source filenames.
# source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "xarray"
copyright = "2014-%s, xarray Developers" % datetime.datetime.now().year
# The short X.Y version.
version = xarray.__version__.split("+")[0]
# The full version, including alpha/beta/rc tags.
release = xarray.__version__
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
today_fmt = "%Y-%m-%d"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
# The name of the Pygments (syntax highlighting) style to use.
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.
html_theme = "sphinx_book_theme"
html_title = ""
html_context = {
"github_user": "pydata",
"github_repo": "xarray",
"github_version": "main",
"doc_path": "doc",
}
# 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 = dict(
# analytics_id='' this is configured in rtfd.io
# canonical_url="",
repository_url="https://github.com/pydata/xarray",
repository_branch="main",
path_to_docs="doc",
use_edit_page_button=True,
use_repository_button=True,
use_issues_button=True,
home_page_in_toc=False,
extra_navbar="",
navbar_footer_text="",
extra_footer="""<p>Xarray is a fiscally sponsored project of <a href="https://numfocus.org">NumFOCUS</a>,
a nonprofit dedicated to supporting the open-source scientific computing community.<br>
Theme by the <a href="https://ebp.jupyterbook.org">Executable Book Project</a></p>""",
twitter_url="https://twitter.com/xarray_devs",
)
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "_static/dataset-diagram-logo.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "_static/favicon.ico"
# 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_css_files = ["style.css"]
# configuration for sphinxext.opengraph
ogp_site_url = "https://xarray.pydata.org/en/latest/"
ogp_image = "https://xarray.pydata.org/en/stable/_static/dataset-diagram-logo.png"
ogp_custom_meta_tags = [
'<meta name="twitter:card" content="summary_large_image" />',
'<meta property="twitter:site" content="@xarray_dev" />',
'<meta name="image" property="og:image" content="https://xarray.pydata.org/en/stable/_static/dataset-diagram-logo.png" />',
]
# Redirects for pages that were moved to new locations
rediraffe_redirects = {
"terminology.rst": "user-guide/terminology.rst",
"data-structures.rst": "user-guide/data-structures.rst",
"indexing.rst": "user-guide/indexing.rst",
"interpolation.rst": "user-guide/interpolation.rst",
"computation.rst": "user-guide/computation.rst",
"groupby.rst": "user-guide/groupby.rst",
"reshaping.rst": "user-guide/reshaping.rst",
"combining.rst": "user-guide/combining.rst",
"time-series.rst": "user-guide/time-series.rst",
"weather-climate.rst": "user-guide/weather-climate.rst",
"pandas.rst": "user-guide/pandas.rst",
"io.rst": "user-guide/io.rst",
"dask.rst": "user-guide/dask.rst",
"plotting.rst": "user-guide/plotting.rst",
"duckarrays.rst": "user-guide/duckarrays.rst",
"related-projects.rst": "ecosystem.rst",
"faq.rst": "getting-started-guide/faq.rst",
"why-xarray.rst": "getting-started-guide/why-xarray.rst",
"installing.rst": "getting-started-guide/installing.rst",
"quick-overview.rst": "getting-started-guide/quick-overview.rst",
}
# Sometimes the savefig directory doesn't exist and needs to be created
# https://github.com/ipython/ipython/issues/8733
# becomes obsolete when we can pin ipython>=5.2; see ci/requirements/doc.yml
ipython_savefig_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "_build", "html", "_static"
)
if not os.path.exists(ipython_savefig_dir):
os.makedirs(ipython_savefig_dir)
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = today_fmt
# Output file base name for HTML help builder.
htmlhelp_basename = "xarraydoc"
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
"iris": ("https://scitools-iris.readthedocs.io/en/latest", None),
"numpy": ("https://numpy.org/doc/stable", None),
"scipy": ("https://docs.scipy.org/doc/scipy", None),
"numba": ("https://numba.pydata.org/numba-doc/latest", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"dask": ("https://docs.dask.org/en/latest", None),
"cftime": ("https://unidata.github.io/cftime", None),
"rasterio": ("https://rasterio.readthedocs.io/en/latest", None),
"sparse": ("https://sparse.pydata.org/en/latest/", None),
}
# based on numpy doc/source/conf.py
def linkcode_resolve(domain, info):
"""
Determine the URL corresponding to Python object
"""
if domain != "py":
return None
modname = info["module"]
fullname = info["fullname"]
submod = sys.modules.get(modname)
if submod is None:
return None
obj = submod
for part in fullname.split("."):
try:
obj = getattr(obj, part)
except AttributeError:
return None
try:
fn = inspect.getsourcefile(inspect.unwrap(obj))
except TypeError:
fn = None
if not fn:
return None
try:
source, lineno = inspect.getsourcelines(obj)
except OSError:
lineno = None
if lineno:
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
else:
linespec = ""
fn = os.path.relpath(fn, start=os.path.dirname(xarray.__file__))
if "+" in xarray.__version__:
return f"https://github.com/pydata/xarray/blob/main/xarray/{fn}{linespec}"
else:
return (
f"https://github.com/pydata/xarray/blob/"
f"v{xarray.__version__}/xarray/{fn}{linespec}"
)
def html_page_context(app, pagename, templatename, context, doctree):
# Disable edit button for docstring generated pages
if "generated" in pagename:
context["theme_use_edit_page_button"] = False
def setup(app):
app.connect("html-page-context", html_page_context)