Skip to content

Commit 56195c9

Browse files
authored
Update code blocks and add guidelines on usage to style guide (#74)
I've attempted to fix up some code blocks. Whatever was obviously a terminal (ehm, console) session I've updated to use `console`. Turns out `terminal` isn't a valid lexer, and just does no highlighting. I've changed some types to `bash` or `console` a bit depending on the contents of the code block, but I have not tried to fix everything. I've added a section about code blocks to the style guide, which we can try to follow when updating existing or adding new docs.
1 parent af88538 commit 56195c9

File tree

14 files changed

+163
-110
lines changed

14 files changed

+163
-110
lines changed

docs/access/mfa.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ Before starting, ensure that the following pre-requisites are satisfied
5050

5151
!!! warning
5252
If you try to SSH to CSCS systems without setting up MFA, you will be prompted with permission denied error, for example:
53-
```
54-
> ssh ela.cscs.ch
53+
```console
54+
$ ssh ela.cscs.ch
5555
[email protected]: Permission denied (publickey).
5656
Connection closed by UNKNOWN port 65535
5757
```

docs/clusters/clariden.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ See the SLURM documentation for instructions on how to run jobs on the [Grace-Ho
8484

8585
??? example "how to check the number of nodes on the system"
8686
You can check the size of the system by running the following command in the terminal:
87-
```terminal
88-
> sinfo --format "| %20R | %10D | %10s | %10l | %10A |"
87+
```console
88+
$ sinfo --format "| %20R | %10D | %10s | %10l | %10A |"
8989
| PARTITION | NODES | JOB_SIZE | TIMELIMIT | NODES(A/I) |
9090
| debug | 32 | 1-2 | 30:00 | 3/29 |
9191
| normal | 1266 | 1-infinite | 1-00:00:00 | 812/371 |

docs/clusters/santis.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ See the SLURM documentation for instructions on how to run jobs on the [Grace-Ho
9898

9999
??? example "how to check the number of nodes on the system"
100100
You can check the size of the system by running the following command in the terminal:
101-
```terminal
102-
> sinfo --format "| %20R | %10D | %10s | %10l | %10A |"
101+
```console
102+
$ sinfo --format "| %20R | %10D | %10s | %10l | %10A |"
103103
| PARTITION | NODES | JOB_SIZE | TIMELIMIT | NODES(A/I) |
104104
| debug | 32 | 1-2 | 30:00 | 3/29 |
105105
| normal | 1266 | 1-infinite | 1-00:00:00 | 812/371 |

docs/contributing/index.md

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ We use the GitHub fork and pull request model for development:
1313
Clone your fork repository on your PC/laptop:
1414
```bash
1515
# clone your fork of the repository
16-
> git clone [email protected]:${githubusername}/cscs-docs.git
17-
> cd cscs-docs
18-
> git switch -c 'fix/ssh-alias'
16+
git clone [email protected]:${githubusername}/cscs-docs.git
17+
cd cscs-docs
18+
git switch -c 'fix/ssh-alias'
1919
# ... make your edits ...
2020
# add and commit your changes
21-
> git add <files>
22-
> git commit -m 'update the ssh docs with aliases for all user lab vclusters'
23-
> git push origin 'fix/ssh-alias'
21+
git add <files>
22+
git commit -m 'update the ssh docs with aliases for all user lab vclusters'
23+
git push origin 'fix/ssh-alias'
2424
```
2525
Then navigate to GitHub, and create a pull request.
2626

2727
The `serve` script in the root path of the repository can be used to view the docs locally:`
28-
```
29-
> ./serve
28+
```bash
29+
./serve
3030
...
3131
INFO - [08:33:34] Serving on http://127.0.0.1:8000/
3232
```
@@ -228,3 +228,56 @@ They stand out better from the main text, and can be collapsed by default if nee
228228
This note is collapsed, because it uses `???`.
229229

230230
If an admonition is collapsed by default, it should have a title.
231+
232+
### Code blocks
233+
234+
Use [code blocks](https://squidfunk.github.io/mkdocs-material/reference/code-blocks/) when you want to display monospace text in a programming language, terminal output, configuration files etc.
235+
The documentation uses [pygments](https://pygments.org) for highlighting.
236+
See [list of available lexers](https://pygments.org/docs/lexers/#) for the languages that you can use for code blocks.
237+
238+
Use [`console`](https://pygments.org/docs/lexers/#pygments.lexers.shell.BashSessionLexer) for interactive sessions with prompt-output pairs:
239+
240+
=== "Markdown"
241+
242+
````markdown
243+
```console title="Hello, world!"
244+
$ echo "Hello, world!"
245+
Hello, world!
246+
```
247+
````
248+
249+
=== "Rendered"
250+
251+
```console title="Hello, world!"
252+
$ echo "Hello, world!"
253+
Hello, world!
254+
```
255+
256+
!!! warning
257+
`terminal` is not a valid lexer, but MkDocs or pygments will not warn about using it as a language.
258+
The text will be rendered without highlighting.
259+
260+
!!! warning
261+
Use `$` as the prompt character, optionally preceded by text.
262+
`>` as the prompt character will not be highlighted correctly.
263+
264+
Note the use of `title=...`, which will give the code block a heading.
265+
266+
!!! tip
267+
Include a title whenever possible to describe what the code block does or is.
268+
269+
If you want to display commands without output that can easily be copied, use `bash` as the language:
270+
271+
=== "Markdown"
272+
273+
````markdown
274+
```bash title="Hello, world!"
275+
echo "Hello, world!"
276+
```
277+
````
278+
279+
=== "Rendered"
280+
281+
```bash title="Hello, world!"
282+
echo "Hello, world!"
283+
```

docs/guides/gb2025.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ This confines system processes and operations to the first core of each of the f
4242

4343
The consequence of this setting is that only 71 cores per socket can be requested by an application (for a total of 284 cores instead of 288 cores per node).
4444

45-
!!! warning "Unable to allocate resources: Requested node configuration is not availabl"
45+
!!! warning "Unable to allocate resources: Requested node configuration is not available"
4646
If you try to use all 72 cores on each socket, SLURM will give a hard error, because only 71 are available:
4747

48-
```
48+
```console
4949
# try to run 4 ranks per node, with 72 cores each
50-
> srun -n4 -N1 -c72 --reservation=reshuffling ./build/affinity.mpi
50+
$ srun -n4 -N1 -c72 --reservation=reshuffling ./build/affinity.mpi
5151
srun: error: Unable to allocate resources: Requested node configuration is not available
5252
```
5353

docs/guides/terminal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ At CSCS the vast majority of users stick with the default `bash`: at the time of
1414

1515
Run the following command after logging in:
1616

17-
```terminal
17+
```console
1818
$ getent passwd | grep $USER
1919
bcumming:*:22008:1000:Benjamin Cumming, CSCS:/users/bcumming:/usr/local/bin/bash
2020
```

docs/software/container-engine.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ Since the `ubuntu.toml` file is located in the [EDF search path][ref-ce-edf-sear
5050
The above terminal snippet demonstrates how to launch a containerized environment using Slurm with the `--environment` option.
5151
Click on the :fontawesome-solid-circle-plus: icon for information on each command.
5252

53-
```bash
54-
daint-ln002 > srun --environment=ubuntu --pty bash # (1)
53+
```console
54+
[daint-ln002]$ srun --environment=ubuntu --pty bash # (1)
5555

56-
nid005333 > pwd # (2)
56+
[nid005333]$ pwd # (2)
5757
/capstor/scratch/cscs/<username>
5858

59-
nid005333 > cat /etc/os-release # (3)
59+
[nid005333]$ cat /etc/os-release # (3)
6060
PRETTY_NAME="Ubuntu 24.04 LTS"
6161
NAME="Ubuntu"
6262
VERSION_ID="24.04"
@@ -71,8 +71,8 @@ Since the `ubuntu.toml` file is located in the [EDF search path][ref-ce-edf-sear
7171
UBUNTU_CODENAME=noble
7272
LOGO=ubuntu-logo
7373

74-
nid005333 > exit # (4)
75-
daint-ln002 >
74+
[nid005333]$ exit # (4)
75+
[daint-ln002]$
7676
```
7777

7878
1. Starting an interactive shell session within the Ubuntu 24.04 container deployed on a compute node using `srun --environment=ubuntu --pty bash`.

docs/software/devtools/linaro-ddt.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The following guide will walk through the steps required to build and debug an a
1818
Once the uenv is loaded and activated, the program to debug must be compiled with the `-g` (for CPU) and `-G` (for GPU) debugging flags.
1919
For example, we can build a CUDA test with a user environment:
2020

21-
```terminal
21+
```bash
2222
uenv start prgenv-gnu:24.11:v1 --view=default
2323
nvcc -c -arch=sm_90 -g -G test_gpu.cu
2424
mpicxx -g test_cpu.cpp test_gpu.o -o myexe
@@ -41,13 +41,13 @@ To use the DDT client with uenv, it must be launched in `Manual Launch` mode
4141

4242
Log into the system and launch with the `srun` command:
4343

44-
```terminal
44+
```console
4545
# start a session with both the PE used to build your application
4646
# and the linaro-forge uenv mounted
47-
> uenv start prgenv-gnu/24.11:v1,linaro-forge/24.1.1:v1 --view=prgenv-gnu:default
48-
> source /user-tools/activate
47+
$ uenv start prgenv-gnu/24.11:v1,linaro-forge/24.1.1:v1 --view=prgenv-gnu:default
48+
$ source /user-tools/activate
4949

50-
> srun -N1 -n4 -t15 -pdebug ./cuda_visible_devices.sh ddt-client ./myexe
50+
$ srun -N1 -n4 -t15 -pdebug ./cuda_visible_devices.sh ddt-client ./myexe
5151
```
5252

5353
### Start debugging

docs/software/devtools/linaro-forge.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ The Linaro uenv is named `linaro-forge`, and the available versions can be deter
1818

1919
!!! example "finding available linaro-forge versions"
2020

21-
```
22-
> uenv image find linaro-forge
21+
```console
22+
$ uenv image find linaro-forge
2323
uenv arch system id size(MB) date
2424
linaro-forge/24.1.1:v1 gh200 daint e0e79f5c3e6a8ee0 365 2025-02-12
2525

26-
> uenv image pull linaro-forge/24.1.1:v1
26+
$ uenv image pull linaro-forge/24.1.1:v1
2727
pulling e0e79f5c3e6a8ee0 100.00% --- 365/365 (0.00 MB/s)
2828
```
2929

@@ -50,10 +50,10 @@ Version: 24.1.1
5050
!!! note
5151
The `linaro-forge` uenv is always mounted at the `/user-tools` mount point, and a script `/user-tools/activate` is provided to load both ddt and map into your environment, without needing to use a view.
5252

53-
```bash
54-
> uenv start linaro-forge/14.1.1
55-
> source /user-tools/activate
56-
> ddt --version
53+
```console
54+
$ uenv start linaro-forge/14.1.1
55+
$ source /user-tools/activate
56+
$ ddt --version
5757
Linaro DDT Part of Linaro Forge.
5858
Copyright (c) 2023-2024 Linaro Limited. All rights reserved.
5959
Version: 24.1.1

docs/software/prgenv/prgenv-gnu.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ There are three ways to access the software provided by prgenv-gnu, once it has
8181
The simplest way to get started is to use the `default` file system view, which automatically loads all of the packages when the uenv is started.
8282

8383
!!! example "test mpi compilers and python provided by prgenv-gnu/24.11"
84-
```bash
84+
```console
8585
# start using the default view
86-
> uenv start --view=default prgenv-gnu/24.11:v1
86+
$ uenv start --view=default prgenv-gnu/24.11:v1
8787

8888
# the python executable provided by the uenv is the default, and is a recent version
89-
> which python
89+
$ which python
9090
/user-environment/env/default/bin/python
91-
> python --version
91+
$ python --version
9292
Python 3.12.5
9393

9494
# the mpi compiler wrappers are also available
95-
> which mpicc
95+
$ which mpicc
9696
/user-environment/env/default/bin/mpicc
97-
> mpicc --version
97+
$ mpicc --version
9898
gcc (Spack GCC) 13.3.0
99-
> gcc --version # the compiler wrapper uses the gcc provided by the uenv
99+
$ gcc --version # the compiler wrapper uses the gcc provided by the uenv
100100
gcc (Spack GCC) 13.3.0
101101
```
102102

@@ -106,9 +106,9 @@ There are three ways to access the software provided by prgenv-gnu, once it has
106106
No modules are loaded when a uenv starts, and have to be loaded individually using `module load`.
107107

108108
!!! example "starting prgenv-gnu and listing the provided modules"
109-
```bash
110-
> uenv start prgenv-gnu/24.11:v1 --view=modules
111-
> module avail
109+
```console
110+
$ uenv start prgenv-gnu/24.11:v1 --view=modules
111+
$ module avail
112112
---------------------------- /user-environment/modules ----------------------------
113113
aws-ofi-nccl/git.v1.9.2-aws_1.9.2 lua/5.4.6
114114
boost/1.86.0 lz4/1.10.0

0 commit comments

Comments
 (0)