Skip to content

Commit 9a0ad55

Browse files
authored
[MAINT] Fix some gallery files not being executed (#2792)
* Exclude gallery files that start with NX_ * Rename oedi_9068.py example to NX_... to exclude from sphinx-gallery execution * Fix exclusion regex * ¿? Add warning into oedi example just in case * Comment editorial * Flake8 doing its thing. Once again. * Flake8 x2 * Flake8 x3 * Pin sphinx-gallery to 0.21 * Add whatsnew entry * One last ammend to regex * This is the last ammend to the regex 100% real don't doubt it * Guess what. I'm updating the regex once again * Minor edit to whatsnew * regex escape separator - Win build was broken * Document regex on different OSes * Revive import distutils - IDK why it's there, thou * Remove distutil leftover * Change prefix NX_ -> noplot_ * Forgot to save conf.py * flake8 needed love
1 parent 35c9e61 commit 9a0ad55

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

docs/examples/system-models/oedi_9068.py renamed to docs/examples/system-models/noplot_oedi_9068.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@
1313
#
1414
# The system has public monitoring data available at the Open Energy Data
1515
# Initiative (OEDI) under `System ID
16-
# 9068 <https://data.openei.org/s3_viewer?bucket=oedi-data-lake&prefix=pvdaq%2F2023-solar-data-prize%2F9068_OEDI%2F>`__.
16+
# 9068 <https://data.openei.org/s3_viewer?bucket=oedi-data-lake&prefix=pvdaq%2F2023-solar-data-prize%2F9068_OEDI%2F>`__. # noqa: E501
1717
# For more information about the system, see its `OEDI
1818
# page <https://openei.org/wiki/PVDAQ/Sites/SR_CO>`__.
19+
#
20+
# .. warning::
21+
# This example requires user-provided credentials to be run at step
22+
# :ref:`Fetch weather data <fetch_weather_data>`. Therefore, it is not
23+
# executed as part of documentation build process and it's more
24+
# susceptible to API changes. Please, report any issues you may find.
1925

2026
# sphinx_gallery_thumbnail_path = "_images/OEDI_9068_daily_timeseries.png"
2127
import pvlib
@@ -132,6 +138,7 @@
132138
# %%
133139
# Fetch weather data
134140
# ------------------
141+
# .. _fetch_weather_data:
135142
#
136143
# The system does have measured plane-of-array irradiance data, but the
137144
# measurements suffer from row-to-row shading and tracker stalls. In this

docs/sphinx/source/conf.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
# for generating GH links with linenumbers
2121
import inspect
2222

23-
# import distutils before calling pd.show_versions()
24-
# https://github.com/pypa/setuptools/issues/3044
25-
import distutils # noqa: F401
23+
# to escape special characters in sphinx-gallery OS-dependant regex
24+
import re
25+
2626
import pandas as pd
2727

2828
pd.show_versions()
@@ -384,12 +384,19 @@ def setup(app):
384384
# https://github.com/pvlib/pvlib-python/issues/837
385385
suppress_warnings = ['ref.footnote']
386386

387+
os_re_sep = re.escape(os.path.sep)
387388
# settings for sphinx-gallery
388389
sphinx_gallery_conf = {
389390
'examples_dirs': ['../../examples'], # location of gallery scripts
390391
'gallery_dirs': ['gallery'], # location of generated output
391-
# execute only files starting with plot_
392-
'filename_pattern': 'plot_',
392+
393+
# do not execute gallery examples filenames that begin with noplot_
394+
# first group + sep := match folders up to filename
395+
# negative lookahead + match anything but sep := match filename (if valid)
396+
# https://sphinx-gallery.github.io/stable/configuration.html#parsing-and-executing-examples-via-matching-patterns # noqa: E501
397+
# unix: filename_pattern = '^(.*)/(?!noplot_)([^/]*)$'
398+
# win: filename_pattern = '^(.*)\\\\(?!noplot_)([^\\\\]*)$'
399+
'filename_pattern': rf"^(.*){os_re_sep}(?!noplot_)([^{os_re_sep}]*)$",
393400

394401
# directory where function/class granular galleries are stored
395402
'backreferences_dir': 'reference/generated/gallery_backreferences',

docs/sphinx/source/whatsnew/v0.15.3.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Requirements
4242

4343
Maintenance
4444
~~~~~~~~~~~
45+
* Fix some gallery examples not being run. Only gallery examples whose filename begins with ``noplot_`` will be excluded. (:issue:`2790`, :pull:`2792`)
4546
* Removed unused internal function ``clearsky._is_leap_year`` (:issue:`2768`, :pull:`2813`)
4647
* Fix documentation builds on runner images lacking link-type timezones. (:issue:`2795`, :pull:`2809`)
4748

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ doc = [
6060
'matplotlib',
6161
'sphinx == 7.3.7',
6262
'pydata-sphinx-theme == 0.15.4',
63-
'sphinx-gallery',
63+
'sphinx-gallery == 0.21',
6464
'docutils == 0.21',
6565
'pillow',
6666
'sphinx-toggleprompt == 0.5.2',

0 commit comments

Comments
 (0)