Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to code-block:: text from code-block:: bash & update the version of pip #937

Merged
merged 8 commits into from
Jul 12, 2021
Merged

Change to code-block:: text from code-block:: bash & update the version of pip #937

merged 8 commits into from
Jul 12, 2021

Conversation

dukecat0
Copy link
Member

@dukecat0 dukecat0 commented Jul 9, 2021

@dukecat0 dukecat0 changed the title Change to code-block :: text from code-block:: bash & update the version of pip Change to code-block:: text from code-block:: bash & update the version of pip Jul 9, 2021
@pradyunsg
Copy link
Member

Hmm... This PR make me think that we should not checkin the .pot file, and instead generate that in a GitHub action instead.

@dukecat0
Copy link
Member Author

dukecat0 commented Jul 9, 2021

Hmm... This PR make me think that we should not checkin the .pot file, and instead generate that in a GitHub action instead.

Thanks for your suggestion and I will open another PR for this.

@bhrutledge bhrutledge self-requested a review July 9, 2021 10:58
Copy link
Contributor

@bhrutledge bhrutledge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comprehensive update! Beyond the question of text vs other lexers, just a couple some small tweaks to installing-using-pip-and-virtual-environments.rst for consistency.

source/guides/distributing-packages-using-setuptools.rst Outdated Show resolved Hide resolved
Comment on lines 41 to 43
.. code-block:: bash

pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a bash command, but rather its output, so I think it should be text:

Suggested change
.. code-block:: bash
pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)
.. code-block:: text
pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think these blocks under "Activating Virtual Environments" should similarly separate the command from its output:

.. tab:: Unix/macOS

    .. code-block:: bash

        which python
        .../env/bin/python

.. tab:: Windows

    .. code-block:: text

        where python
        ...\env\Scripts\python.exe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it's console rather than text.

Copy link
Contributor

@henryiii henryiii Jul 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Text" removes all semantic meaning from the highlighting, promising you will never do better than text, and making it programmatically indistinguishable from a text output. I'd think bat or powershell would be better, as that's actually the language this is in, even if there's no current visual difference. console is supposed to be somewhat agnostic, even if bash-like - was it rendering incorrectly? Also, if they are struggling with output vs. input, what about:

    .. code-block:: bat

        where python

    .. code-block:: text

        ...\env\Scripts\python.exe

? Does that break it up too much? I used to have a "input" and "output" type (gitbook plugin, IIRC) that would handle this nicely. As long as we are consistent, it's easy to refactor in the future - going to "text" makes it harder, because there may really be some "text" blocks that are not Windows shell inputs.

Copy link
Contributor

@bhrutledge bhrutledge Jul 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are good points re: semantics and refactoring, @henryiii. Since I was the one who originally suggested text, I just pushed the change to bat for Windows inputs (ee40d83), plus a couple remaining bash for Unix inputs (4e01f46).

I don't think console is correct for outputs, because according to the docs, it's a "lexer for Bash shell sessions, i.e. command lines, including a prompt, interspersed with output". text is widely-used throughout this project for outputs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhrutledge I think I've seen console perform well with windows-based prompts. My understanding that it only highlights the lines starting with some sort of a prompt differently from those that don't.
But yes, looking at https://github.com/pygments/pygments/blob/1ea5fc3/pygments/lexers/shell.py#L226 and https://github.com/pygments/pygments/blob/1ea5fc3/pygments/lexers/shell.py#L556, it seems like doscon is a windows counterpart of the console lexer.

@henryiii I do think that having clear input (with prompt) + output coupled would be beneficial

Copy link
Contributor

@bhrutledge bhrutledge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. I pushed a couple more tweaks to the installing-using-pip doc.

Since this would be my first merge as a maintainer, I'll leave this open for another day to allow for more comments.

source/guides/distributing-packages-using-setuptools.rst Outdated Show resolved Hide resolved
Comment on lines 165 to 178

It should be in the ``env`` directory:

.. tab:: Unix/macOS

.. code-block:: text

.../env/bin/python

.. tab:: Windows

.. code-block:: text

...\env\Scripts\python.exe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought having more distinction between the command and its output would read better.

Comment on lines +37 to +42
Afterwards, you should have the latest version of pip installed in your
user site:

python3 -m pip --version
pip 9.0.1 from $HOME/.local/lib/python3.6/site-packages (python 3.6)
.. code-block:: text

pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In retrospect, the changes to this section probably should be in a separate PR, but I took the opportunity to (hopefully) add some additional clarity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, also, the console session should be coupled with the output after the prompt input.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coupled with the output after the prompt input

If you mean there shouldn't be any explanatory text between the input and the output code-block, I disagree. That's how it was in earlier commits, and I thought it was a bit confusing. Also, there are already places in this doc (and I assume others) where they are separated, e.g.:

https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-packages

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing when the input line isn't marked with a prompt. If it is, that should be rendered better.

@dukecat0
Copy link
Member Author

dukecat0 commented Jul 11, 2021

Thanks for @henryiii's suggestion and @bhrutledge's commits! :)

@dukecat0
Copy link
Member Author

dukecat0 commented Jul 12, 2021

@bhrutledge Do you think we should add copy button for folks so they can copy the command directly? It's very easy to do this( just add a sphinx extension). Btw, this could be added in another PR.

Comment on lines +39 to 41
.. code-block:: bat

py -m pip install twine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For win console, it's probably just

Suggested change
.. code-block:: bat
py -m pip install twine
.. code-block:: doscon
> py -m pip install twine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe

Suggested change
.. code-block:: bat
py -m pip install twine
.. code-block:: ps1con
$ py -m pip install twine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @bhrutledge have you seen these?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh. I missed those. I agree those seem appropriate, if there's a parallel change of all of the bash inputs, i.e.:

.. code-block:: console

    $ twine upload dist/*

I think that's beyond the scope of this PR. Also, as noted in an earlier discussion, I'm not sure it's a better experience, because it adds a little more work to copying a command.

Copy link
Contributor

@bhrutledge bhrutledge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the additional comments. I'm going to merge this as-is, because I think it's a nice improvement. Folks can follow up with additional issues/PRs if they like.

Do you think we should add copy button for folks so they can copy the command directly?

@meowmeowmeowcat That sounds handy. I'd probably start with a PR that just adds the button, but not the prompt characters and the configuration to remove it.

Comment on lines +39 to 41
.. code-block:: bat

py -m pip install twine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh. I missed those. I agree those seem appropriate, if there's a parallel change of all of the bash inputs, i.e.:

.. code-block:: console

    $ twine upload dist/*

I think that's beyond the scope of this PR. Also, as noted in an earlier discussion, I'm not sure it's a better experience, because it adds a little more work to copying a command.

Comment on lines +37 to +42
Afterwards, you should have the latest version of pip installed in your
user site:

python3 -m pip --version
pip 9.0.1 from $HOME/.local/lib/python3.6/site-packages (python 3.6)
.. code-block:: text

pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coupled with the output after the prompt input

If you mean there shouldn't be any explanatory text between the input and the output code-block, I disagree. That's how it was in earlier commits, and I thought it was a bit confusing. Also, there are already places in this doc (and I assume others) where they are separated, e.g.:

https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-packages

@bhrutledge bhrutledge merged commit a95d0b1 into pypa:main Jul 12, 2021
@dukecat0 dukecat0 deleted the Fixes-#934 branch July 12, 2021 09:46
@webknjaz
Copy link
Member

re:copybutton — it'd be nice to integrate https://github.com/executablebooks/sphinx-copybutton + https://github.com/python/python-docs-theme/blob/master/python_docs_theme/static/copybutton.js

@dukecat0
Copy link
Member Author

@dukecat0
Copy link
Member Author

https://github.com/python/python-docs-theme/blob/master/python_docs_theme/static/copybutton.js

@webknjaz Is this necessary for the docs? I think most of the code blocks in the docs are shell commands.

@webknjaz
Copy link
Member

Dunno, I think it'd be nice to have the ability to easily copy those commands w/o the prompt.

@dukecat0
Copy link
Member Author

I agree. I will test sphinx-copybutton and see if it can integrate the function of the copybutton in python docs .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The windows examples use "bash" and backslashes installing-using-pip: Update command output
6 participants