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

Remove Excess $ From Shell Blocks #452

Closed
melodywang060 opened this issue Oct 8, 2024 · 3 comments · Fixed by #454
Closed

Remove Excess $ From Shell Blocks #452

melodywang060 opened this issue Oct 8, 2024 · 3 comments · Fixed by #454

Comments

@melodywang060
Copy link
Contributor

melodywang060 commented Oct 8, 2024

Problem

In a lot of code chunks in RAPIDs deployment documentation, only the first line of the multiline command is copied over when users hit the copy code block button - the rest are omitted

Example:

$ gcloud container clusters create rapids-gpu-kubeflow \
  --accelerator type=nvidia-tesla-a100,count=2 --machine-type a2-highgpu-2g \
  --zone us-central1-c --release-channel stable

In the example above, only the first line is interpret as the command, and the following lines are interpreted as the console output from the command in the first line

Quick Fix

Removing the $ in the beginning of the code chunk

This interprets the multiline command as a whole block of code to copy over instead of just the first line.

Pros

  • More convenient for users to copy and paste
@jacobtomlinson
Copy link
Member

jacobtomlinson commented Oct 8, 2024

If you are showing a command and it's output it can help to add the $ to the beginning of the command which lets the console syntax highlighter do it's thing.

```console
$ df -h
Filesystem                           Size    Used   Avail Capacity iused ifree %iused  Mounted on
/dev/disk3s1s1                      926Gi    19Gi   665Gi     3%    404k  4.3G    0%   /
devfs                               224Ki   224Ki     0Bi   100%     774     0  100%   /dev
```
$ df -h
Filesystem                           Size    Used   Avail Capacity iused ifree %iused  Mounted on
/dev/disk3s1s1                      926Gi    19Gi   665Gi     3%    404k  4.3G    0%   /
devfs                               224Ki   224Ki     0Bi   100%     774     0  100%   /dev

My understanding is that the copy/paste button ignores the additional lines because it thinks they are command output. You can see the highlighting clearly using the console highlighter.

$ gcloud container clusters create rapids-gpu-kubeflow \
  --accelerator type=nvidia-tesla-a100,count=2 --machine-type a2-highgpu-2g \
  --zone us-central1-c --release-channel stable

So removing the $ let's the copy/paste plugin know that it should copy the whole block.

gcloud container clusters create rapids-gpu-kubeflow \
  --accelerator type=nvidia-tesla-a100,count=2 --machine-type a2-highgpu-2g \
  --zone us-central1-c --release-channel stable

In any case in the docs where we have the leading $ but no example output then we are fine to just remove it. And for any single-line commands which have the $ things should work as expected. The only case I'm worried about it a multi-line command that does have output, in which case I don't think we can get the copy/paste to behave correctly. Hopefully there aren't any of those!

@jacobtomlinson
Copy link
Member

Interestingly the GitHub copy/paste button doesn't do anything clever at all and just copies the whole box, which probably isn't what you want for console examples with output.

@jameslamb
Copy link
Member

Interestingly the GitHub copy/paste button doesn't do anything clever at all and just copies the whole box, which probably isn't what you want for console examples with output.

I think it was this experience on GitHub specifically that probably led me to form this aversion to the leading $. To be fair, I didn't realize it was GitHub-specific.

Thanks for all the examples @jacobtomlinson ! Given that, I support what you said:

  • code blocks without output: remove $
  • code blocks with multi-line commands: remove $
  • all others: keep $

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 a pull request may close this issue.

3 participants