-
Notifications
You must be signed in to change notification settings - Fork 228
Description
For gallery examples, it usually makes sense to split a long script into multiple blocks using block separators. The Sphinx-Gallery package supports three different "block separators/splitters"
- more than 20
#
characters, i.e.,###################################################
# %%
#%%
Reference: https://sphinx-gallery.github.io/stable/syntax.html#embed-rest-in-your-example-python-files
The separator #%%
will always be formatted to # %%
by black
, following PEP-8 convention, so this kind of separator can be ignored.
Currently, we use the #
separator in our gallery examples (e.g., https://github.com/GenericMappingTools/pygmt/blob/main/examples/gallery/maps/tilemaps.py). I propose to use # %%
instead.
The main reason is that # %%
is also supported by Visual Studio Code and other editors/IDEs (see https://code.visualstudio.com/docs/python/jupyter-support-py#_jupyter-code-cells), making Python scripts working like Jupyter Notebooks. The # %%
also can save us a lot of keystrokes.