jupyter-sphinx icon indicating copy to clipboard operation
jupyter-sphinx copied to clipboard

Allow to hide script output but not plots?

Open SeanDS opened this issue 5 years ago • 4 comments

The :hideoutput: flag hides both plots and script outputs. It would be nice to be able to hide only script outputs but not plots, or vice-versa. Some typical plot commands implemented in libraries return something from their plot methods, so you get the situation where calling something.plot() inside your jupyter-execute directive gives you both the plot (great) but also some ugly return text under the plot like <Figure size 432x288 with 2 Axes>.

Here is an example from my own project:

Screenshot_20200410_160148

I'd like the ({finesse.detectors.powerdetector.PowerDetector: ...) stuff to be hidden.

Perhaps the :hideoutput: flag could support some options like "all" (default), "plots", "stdout", "stderr" (and support any combination of those)?

SeanDS avatar Apr 10 '20 14:04 SeanDS

Thanks for the suggestion.

In the meantime you can suppress the output by ending the last line with a semicolon—that's the standard jupyter behavior.

akhmerov avatar Apr 10 '20 14:04 akhmerov

For now this is blocked by #107

akhmerov avatar Apr 10 '20 14:04 akhmerov

Thanks for the semicolon hint.

What is blocking about #107? Seems like this could be as simple as a few if/else statements?

SeanDS avatar Apr 10 '20 14:04 SeanDS

Overall it makes sense to treat output differently in different formats (html/pdf specifically). Right now this is impossible, and #107 is a step in that direction. Because it overhauls the logic of how the outputs are treated, it would likely make more sense to review your proposal after #107 is merged.

As an extra remark: one danger for this package is feature creep—jupyter-execute directive already has a lot of options, and I think caution in adding more is a good idea.

akhmerov avatar Apr 10 '20 14:04 akhmerov