mgeier / insipid-sphinx-theme

:yawning_face: An insipid theme for the Sphinx documentation generator.
https://insipid-sphinx-theme.readthedocs.io/
BSD 2-Clause "Simplified" License
39 stars 4 forks source link

Add functionality to hide Python prompts #48

Open f-brinkmann opened 3 years ago

f-brinkmann commented 3 years ago

It would be great to have the possibility to hide the python prompts >>> from code blocks for easier copy-pasting.

Here's an example in scipy. The >>> button on the top right corner of the code examples removes them: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html

Copy-pasting code with the >>> visible will add an empty line between each line you see in the example. Doing the same without the >>> visible removes the empty lines.

I found a discussion of this in another theme and might find some time to give it a go. Would you include it in your code? https://github.com/readthedocs/sphinx_rtd_theme/issues/167

mgeier commented 3 years ago

Sure, I like this feature, but wouldn't it be possible to implement this as a theme-independent separate extension?

The CSS probably wouldn't be perfect for every possible theme, but I guess it could be made to work with at least a few selected themes.

f-brinkmann commented 3 years ago

To be honest I'd prefer the road of least resistance for now. Since I'm not firm witch CSS and don't want to generate additional work for me in case someone tries the extension and opens issues when it doesn't work for other themes. Would that be ok for you?

mgeier commented 3 years ago

To be honest I'd prefer the road of least resistance for now.

Me too, that's why I'd prefer a separate Sphinx extension.

When I first saw that feature, I was actually surprised that it wasn't a re-usable Sphinx extension.

But if there are technical reasons that speak against that, I'm open to discussions about including it here.

Since I'm not firm witch CSS and don't want to generate additional work for me in case someone tries the extension and opens issues when it doesn't work for other themes.

You don't have any obligations, you can support as many or as few themes as you like, for how long you like. Even if you only support the insipid theme, I think it's still worth making a separate extension, because then somebody else can take it and apply it to different themes. But I don't see why it shouldn't automatically work fine for a reasonably large number of existing themes.

Either way, this feature would have to be able to be switched off, in order to not conflict with other extensions like https://github.com/executablebooks/sphinx-copybutton (which BTW has the same problem of not working for all themes).

f-brinkmann commented 3 years ago

Ok, I'll try to find time to look into it and update this thread if I make progress :)

hagenw commented 2 years ago

I have used https://github.com/executablebooks/sphinx-copybutton since a longer time and it works great, see https://audeering.github.io/audeer/api-audeer.html for an example.