Skip to content

Commit 2469d42

Browse files
authored
docs: Improve command formatting (#517)
why: Standardize shell code blocks to follow documentation guidelines what: - Use `console` language tag with `$ ` prefix for shell commands - Split ruff check compound command with `\` line continuations - Add Shell Command Formatting rules to AGENTS.md
1 parent fb1d763 commit 2469d42

3 files changed

Lines changed: 50 additions & 11 deletions

File tree

AGENTS.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ EOF
404404

405405
When writing documentation (README, CHANGES, docs/), follow these rules for code blocks:
406406

407-
**One command per code block.** This makes commands individually copyable.
407+
**One command per code block.** This makes commands individually copyable. For sequential commands, either use separate code blocks or chain them with `&&` or `;` and `\` continuations (keeping it one logical command).
408408

409409
**Put explanations outside the code block**, not as comments inside.
410410

@@ -432,6 +432,42 @@ $ uv run pytest
432432
$ uv run pytest --cov
433433
```
434434

435+
### Shell Command Formatting
436+
437+
These rules apply to shell commands in documentation (README, CHANGES, docs/), **not** to Python doctests.
438+
439+
**Use `console` language tag with `$ ` prefix.** This distinguishes interactive commands from scripts and enables prompt-aware copy in many terminals.
440+
441+
Good:
442+
443+
```console
444+
$ uv run pytest
445+
```
446+
447+
Bad:
448+
449+
```bash
450+
uv run pytest
451+
```
452+
453+
**Split long commands with `\` for readability.** Each flag or flag+value pair gets its own continuation line, indented. Positional parameters go on the final line.
454+
455+
Good:
456+
457+
```console
458+
$ pipx install \
459+
--suffix=@next \
460+
--pip-args '\--pre' \
461+
--force \
462+
'libvcs'
463+
```
464+
465+
Bad:
466+
467+
```console
468+
$ pipx install --suffix=@next --pip-args '\--pre' --force 'libvcs'
469+
```
470+
435471
## Debugging Tips
436472

437473
When stuck in debugging loops:

CHANGES

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,17 @@ _Maintenance only, no bug fixes, or new features_
393393

394394
via ruff v0.3.4, all automated lint fixes, including unsafe and previews were applied:
395395

396-
```sh
397-
ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; ruff format .
396+
```console
397+
$ ruff check --select ALL . \
398+
--fix --unsafe-fixes \
399+
--preview --show-fixes; \
400+
ruff format .
398401
```
399402

400403
Branches were treated with:
401404

402-
```sh
403-
git rebase \
405+
```console
406+
$ git rebase \
404407
--strategy-option=theirs \
405408
--exec 'poetry run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; poetry run ruff format .; git add src tests; git commit --amend --no-edit' \
406409
origin/master

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ It powers [vcspull](https://github.com/vcs-python/vcspull) and simplifies VCS in
2626

2727
## Installation
2828

29-
```bash
30-
pip install libvcs
29+
```console
30+
$ pip install libvcs
3131
```
3232

3333
With [uv](https://docs.astral.sh/uv/):
3434

35-
```bash
36-
uv add libvcs
35+
```console
36+
$ uv add libvcs
3737
```
3838

3939
Try it interactively:
4040

41-
```bash
42-
uvx --with libvcs ipython
41+
```console
42+
$ uvx --with libvcs ipython
4343
```
4444

4545
Tip: libvcs is pre-1.0. Pin a version range in projects to avoid surprises:

0 commit comments

Comments
 (0)