Hi Éric,

On 31/10/2011 19.19, Éric Araujo wrote:
Hi Ezio,

http://hg.python.org/cpython/rev/18bbfed9aafa
user:        Ezio Melotti<ezio.melo...@gmail.com>
summary:
   Add a button to the code examples in the doc to show/hide the prompts and 
output.
Looks cool!  I hope this will stop our use of two or three different
styles for Python code in the docs (doctest-compatible vs.
source-file-style vs. copy-paste-ready) and ultimately help make them
doctest-compatible.

My main concern about this is that it works only with the HTML doc and now with the pdf/chm, so converting the examples would make the situation a bit worse for the pdf/chm users (and also for js-less users). I think in the examples we should just use what make more sense -- either copy/paste from an interpreter session when the output is relevant, copy only the source when it's not, and avoid the "hybrid style" (i.e. include the '>>>' and the output but omit the '...'). Nonetheless I think most of the users use the HTML doc, so it should be an improvement for them :)


+$(document).ready(function() {
+    /* Add a [>>>] button on the top-right corner of code samples to hide
+     * the>>>  and ... prompts and the output and thus make the code
+     * copyable. */
I think it would be more user-friendly if the button/trigger would use
real English text like “Hide prompts”/“Show prompts” rather than symbols.

I thought about that and ended up adding a title="" with a more accurate description, while leaving the button short and unobtrusive. A bigger button might interfer/overlap with the code if the code contains long lines and/or if the window is too narrow. I expect that people will anyway try it out as soon as they notice it and learn quickly what it does.

In a couple of years this whole script could be replaced with a couple of lines of CSS using the CSS3 "user-select" property (so that only the code and not the rest is actually copied), but at the moment the support for it is still a bit lacking and inconsistent.

Best Regards,
Ezio Melotti

Cheers


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to