[DISCUSS] Should we use terminal prompts in documentation?

38 views
Skip to first unread message

Mark Mikofski

unread,
Mar 2, 2020, 4:34:09 PM3/2/20
to pvlib-python
This topic recently came up in PR #922

The question is whether or not to use terminal prompts like $ in the documentation. As I said in the next comment:

I think one good reason to use a prompt, is to distinguish between the terminal (CMD: >, BaSH: $, etc) and a Python interpreter: >>> -- which might seem obvious to one of us, but I have found it is a frequent stumbling block for new users. We say, "type pytest pvlib," but not where, so they type this in Python, instead of a terminal.

But I was wondering what others thought about this, and whether it is really necessary. I hesitate to make an issue if it's a non-issue.

thanks! 

Kevin Anderson

unread,
Mar 5, 2020, 11:26:54 AM3/5/20
to pvlib-python
I have also seen new users assume all code snippets go into the python REPL, so I do think a prompt character and explanation would be an improvement in that context.  However I'm often frustrated when trying to copy/paste a code snippet into an editor and the prompt characters come along with it.  If we do add prompts, it would be nice to generate the HTML such that it's possible to copy the code by itself without the characters, perhaps the prompt characters don't get selected when highlighting a code block. 

Five seconds of googling found these:

Kevin

Mark Mikofski

unread,
Mar 5, 2020, 2:33:59 PM3/5/20
to pvlib-python
+1 for sphinx-copybutton
-1 for sphinx-prompt

FYI: copybutton has a skip-text option to remove Python prompts like >>>, although there's an open issue for multi-line input, which may use "..."

Also, there is a way to automatically hide prompts in sphinx, but I don't know how to activate it.

For example, the Python docs themselvs have this: https://docs.python.org/3/tutorial/inputoutput.html

prompt.png



scipy-prompt.png


So if we can enable this feature, then users can just highlight text without the prompt.

It looks like the ability to hide the prompt may not be available in RTD? Unclear?

apparently the feature is enable by this javascript: https://docs.python.org/3/_static/copybutton.js

Chris Holdgraf's sphinx extension is unfortunately similarly named, "sphinx-copybutton" but they are _not_ the same.

The copybutton.js scipt is part of the scipy-sphinx-theme extension:


which states that it is copied from the PSF cpython here (moved from cpython to python-doc-theme in 2017):

FYI: python-doc-theme is on PyPI here:


So, what to do? I see a few options:

1. use chris holdgraphs sphinx-copybutton extension
2. use the python-doc-theme or something similar
3. do nothing.

That doesn't answer the question about what to use for terminal prompts. I only looked through sphinx docs, and they use the $ terminal prompt at least a few places.

IMO, we might skip the terminal prompt and just say explicitly, enter this into a terminal, but for python repl maybe we use ">>>" and the python-doc-theme?
Reply all
Reply to author
Forward
0 new messages