forked from psyplot/psyplot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconf.py
More file actions
305 lines (248 loc) · 10.5 KB
/
Copy pathconf.py
File metadata and controls
305 lines (248 loc) · 10.5 KB
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
# -*- coding: utf-8 -*-
#
# psyplot documentation build configuration file
#
# Disclaimer
# ----------
#
# Copyright (C) 2021 Helmholtz-Zentrum Hereon
# Copyright (C) 2020-2021 Helmholtz-Zentrum Geesthacht
# Copyright (C) 2016-2021 University of Lausanne
#
# This file is part of psyplot and is released under the GNU LGPL-3.O license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3.0 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LGPL-3.0 license for more details.
#
# You should have received a copy of the GNU LGPL-3.0 license
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sphinx
import os
import os.path as osp
import sys
import re
import six
import subprocess as spr
from itertools import product
import warnings
if six.PY2:
from urllib import urlopen
else:
from urllib.request import urlopen
# make sure, psyplot from parent directory is used
sys.path.insert(0, os.path.abspath('..'))
import psyplot
from psyplot.plotter import Formatoption, Plotter
# automatically import all plotter classes
psyplot.rcParams['project.auto_import'] = True
# include links to the formatoptions in the documentation of the
# :attr:`psyplot.project.ProjectPlotter` methods
Plotter.include_links(True)
warnings.filterwarnings('ignore', message="axes.color_cycle is deprecated")
warnings.filterwarnings(
'ignore', message=("This has been deprecated in mpl 1.5,"))
warnings.filterwarnings('ignore', message="invalid value encountered in ")
warnings.filterwarnings('ignore', message=r"\s*examples.directory")
warnings.filterwarnings('ignore', message='numpy.dtype size changed')
warnings.filterwarnings(
'ignore', message='Using an implicitly registered datetime converter')
warnings.filterwarnings(
'ignore', message=r"\s*The on_mappable_changed function")
warnings.filterwarnings(
'ignore', message=r".+multi-part geometries is deprecated")
warnings.filterwarnings(
'ignore', message=r"\s*The array interface is deprecated")
# -- 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.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.autosummary',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx.ext.extlinks',
'matplotlib.sphinxext.plot_directive',
'IPython.sphinxext.ipython_console_highlighting',
'IPython.sphinxext.ipython_directive',
'sphinxarg.ext',
'psyplot.sphinxext.extended_napoleon',
'autodocsumm',
'sphinx.ext.imgconverter',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
linkcheck_anchors_ignore = ["^install$"]
linkcheck_ignore = [
# HACK: SNF seems to have a temporary problem
r"https://p3.snf.ch/project-\d+",
]
# create the api documentation
if not osp.exists(osp.join(osp.dirname(__file__), 'api')):
spr.check_call(['bash', 'apigen.bash'])
napoleon_use_admonition_for_examples = True
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
autodoc_default_options = {
'show_inheritance': True,
'autosummary': True,
}
autoclass_content = 'both'
not_document_data = ['psyplot.config.rcsetup.defaultParams',
'psyplot.config.rcsetup.rcParams']
ipython_savefig_dir = os.path.join(os.path.dirname(__file__), '_static')
# General information about the project.
project = 'psyplot'
copyright = ", ".join(
psyplot.__copyright__.strip().replace("Copyright (C) ", "").splitlines()
)
author = psyplot.__author__
# 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 = re.match('\d+\.\d+\.\d+', psyplot.__version__).group()
# The full version, including alpha/beta/rc tags.
release = psyplot.__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 = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- 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_rtd_theme'
# 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']
# Output file base name for HTML help builder.
htmlhelp_basename = 'psyplotdoc'
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = '_static/psyplot.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/psyplot.ico'
# Custom sidebar templates, maps document names to template names.
html_sidebars = {
'index': ['sidebarlogo.html', 'sidebarusefullinks.html', 'searchbox.html'],
'**': ['sidebarlogo.html', 'relations.html', 'searchbox.html',
'localtoc.html', 'sidebarusefullinks.html']
}
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# Additional stuff for the LaTeX preamble.
'preamble': '\setcounter{tocdepth}{10}'
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'psyplot.tex', u'psyplot Documentation',
author, 'manual'),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'psyplot', u'psyplot Documentation',
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'psyplot', u'psyplot Documentation',
author, 'psyplot', 'Python framework for interactive data documentation',
'Miscellaneous'),
]
# -- Options for Epub output ----------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'matplotlib': ('https://matplotlib.org/stable/', None),
'seaborn': ('https://seaborn.pydata.org/', None),
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
'xarray': ('https://xarray.pydata.org/en/stable/', None),
'cartopy': ('https://scitools.org.uk/cartopy/docs/latest/', None),
'mpl_toolkits': ('https://matplotlib.org/basemap/', None),
'psy_maps': ('https://psyplot.github.io/psy-maps/', None),
'psy_simple': ('https://psyplot.github.io/psy-simple/', None),
'psy_reg': ('https://psyplot.github.io/psy-reg/', None),
'psyplot_gui': ('https://psyplot.github.io/psyplot-gui/', None),
'psy_view': ('https://psyplot.github.io/psy-view/', None),
"psyplot_examples": ('https://psyplot.github.io/examples/', None),
'python': ('https://docs.python.org/3/', None),
}
replacements = {
'`psyplot.rcParams`': '`~psyplot.config.rcsetup.rcParams`',
'`psyplot.InteractiveList`': '`~psyplot.data.InteractiveList`',
'`psyplot.InteractiveArray`': '`~psyplot.data.InteractiveArray`',
'`psyplot.open_dataset`': '`~psyplot.data.open_dataset`',
'`psyplot.open_mfdataset`': '`~psyplot.data.open_mfdataset`',
}
def link_aliases(app, what, name, obj, options, lines):
for (key, val), (i, line) in product(six.iteritems(replacements),
enumerate(lines)):
lines[i] = line.replace(key, val)
fmt_attrs_map = {
'Interface to other formatoptions': [
'children', 'dependencies', 'connections', 'parents',
'shared', 'shared_by'],
'Formatoption intrinsic': [
'value', 'value2share', 'value2pickle', 'default', 'validate'],
'Interface for the plotter': [
'lock', 'diff', 'set_value', 'check_and_set', 'initialize_plot',
'update', 'share', 'finish_update', 'remove', 'changed', 'plotter',
'priority', 'key', 'plot_fmt', 'update_after_plot',
'requires_clearing', 'requires_replot'],
'Interface to the data': ['data_dependent', 'index_in_list', 'project',
'ax', 'raw_data', 'decoder', 'any_decoder',
'data', 'iter_data', 'iter_raw_data',
'set_data', 'set_decoder'],
'Information attributes': ['group', 'name', 'groupname', 'default_key'],
'Miscellaneous': ['init_kwargs', 'logger'],
}
def group_fmt_attributes(app, what, name, obj, section, parent):
if parent is Formatoption:
return next(
(group for group, val in fmt_attrs_map.items() if name in val),
None)
def setup(app):
app.connect('autodoc-process-docstring', link_aliases)
app.connect('autodocsumm-grouper', group_fmt_attributes)
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}