Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23d9b03

Browse files
committed
DOC: Suppress IPython output in examples and tutorials where not needed
By default, sphinx-gallery captures the last output of each code block and shows it in the generated html in yellow boxes. Especially in tutorials with a frequently interleaving code and text blocks this may appear confusing and reduces readability. In some cases, however, the output is desired (although it could always be replaced by printing). The global configuration is now changed to "capture nothing", for one tutorial with multiple desired outputs this is overridden in the file to show the output and in other cases with just one desired output it's converted to a call to print().
1 parent f44e70e commit 23d9b03

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
199199
'subsection_order': gallery_order.sectionorder,
200200
'thumbnail_size': (320, 224),
201201
'within_subsection_order': gallery_order.subsectionorder,
202+
'capture_repr': (),
202203
}
203204

204205
if 'plot_gallery=0' in sys.argv:

tutorials/intermediate/artists.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class in the Matplotlib API, and the one you will be working with most
115115
116116
Try creating the figure below.
117117
"""
118+
# sphinx_gallery_capture_repr = ('__repr__',)
118119

119120
import numpy as np
120121
import matplotlib.pyplot as plt

tutorials/intermediate/autoscale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# -------
2727
# The default margin around the data limits is 5%:
2828

29-
ax.margins()
29+
print(ax.margins())
3030

3131
###############################################################################
3232
# The margins can be made larger using `~matplotlib.axes.Axes.margins`:

0 commit comments

Comments
 (0)