Skip to content

Commit 6584fcc

Browse files
avargitster
authored andcommitted
CodingGuidelines: update and clarify command-line conventions
Edit the section which explains how to create a good SYNOPSIS section for clarity and accuracy, it was mostly introduced in c455bd8 (CodingGuidelines: Add a section on writing documentation, 2010-11-04): * Change "extra" example to "file", which now naturally follows from previous "<file>..." example (one or more) to "[<file>...]" (zero or more). * Explain how we prefer spacing around "[]()" tokens and "|" alternatives, this is not a new policy, but just codifies what's already the pattern in the most wide use in the documentation. Having a space around " | " for flags, but not for flag values is inconsistent, but this style guide codifies existing patterns. Grepping shows that we don't have any instance matching the second "Don't" example: git grep -E -h -o '=\([^)]+\)' -- builtin Documentation/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5e6667 commit 6584fcc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Documentation/CodingGuidelines

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,8 @@ Writing Documentation:
650650
(One or more of <file>.)
651651

652652
Optional parts are enclosed in square brackets:
653-
[<extra>]
654-
(Zero or one <extra>.)
653+
[<file>...]
654+
(Zero or more of <file>.)
655655

656656
--exec-path[=<path>]
657657
(Option with an optional argument. Note that the "=" is inside the
@@ -665,6 +665,16 @@ Writing Documentation:
665665
[-q | --quiet]
666666
[--utf8 | --no-utf8]
667667

668+
Use spacing around "|" token(s), but not immediately after opening or
669+
before closing a [] or () pair:
670+
Do: [-q | --quiet]
671+
Don't: [-q|--quiet]
672+
673+
Don't use spacing around "|" tokens when they're used to seperate the
674+
alternate arguments of an option:
675+
Do: --track[=(direct|inherit)]
676+
Don't: --track[=(direct | inherit)]
677+
668678
Parentheses are used for grouping:
669679
[(<rev> | <range>)...]
670680
(Any number of either <rev> or <range>. Parens are needed to make

0 commit comments

Comments
 (0)