Skip to content

Document when to use white space in code blocks #691

Description

@daobrien

Perhaps best illustrated with an example.
Original:

[user@host basic-repo]$ *git log --graph --oneline --all*
* 122b62a (`HEAD -> my-feature`, main) add text files with output and reversed output
* 9606c21 update printed message
_...output omitted..._
[user@host basic-repo]$ *git commit -m 'fix broken test'*
[my-feature 0aaf18b] fix broken test
 1 file changed, 1 insertion(+), 1 deletion(-)
[user@host basic-repo]$ *git log --graph --oneline --all*
* 0aaf18b (`HEAD -> my-feature`) fix broken test
* 122b62a (main) add text files with output and reversed output
* 9606c21 update printed message
_...output omitted..._

This block contains 3 commands, and it's pretty easy to "lose" them among all the output.
If we introduce white space:

[user@host basic-repo]$ *git log --graph --oneline --all*
* 122b62a (`HEAD -> my-feature`, main) add text files with output and reversed output
* 9606c21 update printed message
_...output omitted..._

[user@host basic-repo]$ *git commit -m 'fix broken test'*
[my-feature 0aaf18b] fix broken test
 1 file changed, 1 insertion(+), 1 deletion(-)

[user@host basic-repo]$ *git log --graph --oneline --all*
* 0aaf18b (`HEAD -> my-feature`) fix broken test
* 122b62a (main) add text files with output and reversed output
* 9606c21 update printed message
_...output omitted..._

The plan is not to use white space after every command, but rather in those cases where the code block becomes busy and clarity suffers. This is somewhat subjective, and one comment I've received is that "this is not exactly what it looks like in the output". But, we take liberties with the output already by using ...output omitted... and omitting secondary prompts.

I don't think we need strict guidelines, but I do think we need to provide options with some firm boundaries. E.g., how many commands and how much output is too much in a single code block? IMO this example doesn't contain too many commands; 3 commands, 2 of which are the same, and all aimed at illustrating a single point. There's enough output, however, to make those commands start to blend into one confusing code block. A bit of white space separates them into their independent parts. If instead the commands were quite distinct (e.g., git clone followed by editing a file and then committing), then I'd look at two code blocks.

@rclee33 We talked about this a little while back. WDYT?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementWill improve the guide but is not a bug or blocker.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions