git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] CodingGuidelines: Add a section on writing documentation

From
Štěpán Němec <stepnem@gmail.com>
Date
Oct 24, 2010, 15:51 UTC
Message-ID
<20101024155121.GA9503@headley>
In-Reply-To
<20101021222129.GA13262@burratino>

Provide a few examples on argument and option notation in usage strings and command synopses.

Signed-off-by: Štěpán Němec <stepnem@gmail.com>
---
Jonathan Nieder <jrnieder@gmail.com> writes:
> Štěpán Němec wrote:
[...]
Show 11 quoted lines
>> I can try to compile an initial version of such a document, based on the
>> commit message of the original single-patch version
>> (<http://article.gmane.org/gmane.comp.version-control.git/158467>) and
>> including some more cases/examples.
>> 
>> Where do you think would be the most appropriate place for it?
>> Just add a section to CodingGuidelines, or a separate
>> Documentation/WritingGuidelines or something?
>
> Sorry for the slow response.  Documentation/CodingGuidelines makes sense
> to me, since it affects the usage strings in code.
Thanks, here's a patch.
 Documentation/CodingGuidelines |   53 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 09ffc46..0ac7aac 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -139,3 +139,56 @@ For C programs:
 
  - When we pass <string, length> pair to functions, we should try to
    pass them in that order.
+
+Writing Documentation:
+
+ Every user-visible change should be reflected in the documentation.
+ The same general rule as for code applies -- imitate the existing
+ conventions.  A few commented examples follow to provide reference
+ when writing or modifying command usage strings and synopsis sections
+ in the manual pages:
+
+ Placeholders are enclosed in angle brackets:
+   <file>
+   --sort=<key>
+   --abbrev[=<n>]
+
+ Possibility of multiple occurences is indicated by three dots:
+   <file>...
+   (One or more of <file>.)
+
+ Optional parts are enclosed in square brackets:
+   [<extra>]
+   (Zero or one <extra>.)
+
+   --exec-path[=<path>]
+   (Option with an optional argument.  Note that the "=" is inside the
+   brackets.)
+
+   [<patch>...]
+   (Zero or more of <patch>.  Note that the dots are inside, not
+   outside the brackets.)
+
+ Parentheses are used for grouping, often combined with vertical bar
+ to indicate alternatives:
+   [(<rev>|<range>)...]
+   (Any number of either <rev> or <range>.  Parens are needed to make
+   it clear that "..." pertains to both <rev> and <range>.)
+
+   [(-p <parent>)...]
+   (Any number of option -p, each with one <parent> argument.)
+
+   git remote set-head <name> (-a | -d | <branch>)
+   (One and only one of "-a", "-d" or "<branch>" _must_ (no square
+   brackets) be provided.)
+
+ Specific number of occurences is indicated as follows:
+   <commit>{0,2}
+   (Up to two <commit>s.)
+
+ And a somewhat more contrived example:
+   --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
+   Here "=" is outside the brackets, because "--diff-filter=" is a
+   valid usage.  "*" has its own pair of brackets, because it can
+   (optionally) be specified only when one or more of the letters is
+   also provided.
-- 
1.7.3.rc2.221.gbf93f.dirty
Previous: Jonathan NiederNext: Mark Lodato
Message 9 of 43 in “Unify argument and option notation in the docs”
  1. Unify argument and option notation in the docsŠtěpán Němec, Oct 8, 2010
  2. Jonathan NiederOct 8, 2010
  3. Štěpán NěmecOct 8, 2010
  4. 0/6 Unify argument and option notation in the docsŠtěpán Němec, Oct 8, 2010
  5. Jonathan NiederOct 8, 2010
  6. Junio C HamanoOct 8, 2010
  7. Štěpán NěmecOct 8, 2010
  8. Jonathan NiederOct 21, 2010
  9. CodingGuidelines: Add a section on writing documentationŠtěpán Němec, Oct 24, 2010
  10. Mark LodatoOct 29, 2010
  11. Štěpán NěmecOct 29, 2010
  12. Sverre RabbelierOct 29, 2010
  13. Štěpán NěmecNov 1, 2010
  14. CodingGuidelines: Add a section on writing documentationŠtěpán Němec, Nov 4, 2010
  15. diff,difftool: Don't use the {0,2} notation in usage stringsŠtěpán Němec, Nov 4, 2010
  16. Sverre RabbelierNov 4, 2010
  17. Jeff KingNov 4, 2010
  18. Jonathan NiederNov 4, 2010
  19. Jeff KingNov 4, 2010
  20. Jonathan NiederNov 4, 2010
  21. Jeff KingNov 4, 2010
  22. Štěpán NěmecNov 4, 2010
  23. Jeff KingNov 4, 2010
  24. docs: clarify git diff modes of operationJeff King, Nov 4, 2010
  25. Jonathan NiederNov 4, 2010
  26. Mark LodatoNov 5, 2010
  27. Štěpán NěmecNov 4, 2010
  28. Štěpán NěmecNov 4, 2010
  29. 1/6 Use angles for placeholders consistentlyŠtěpán Němec, Oct 8, 2010
  30. 2/6 Fix odd markup in --diff-filter documentationŠtěpán Němec, Oct 8, 2010
  31. Jonathan NiederOct 8, 2010
  32. Štěpán NěmecOct 8, 2010
  33. Jonathan NiederOct 8, 2010
  34. Štěpán NěmecOct 8, 2010
  35. Jonathan NiederOct 8, 2010
  36. 3/6 Use parentheses and `...' where appropriateŠtěpán Němec, Oct 8, 2010
  37. 4/6 Remove stray quotes in --pretty and --format documentationŠtěpán Němec, Oct 8, 2010
  38. 5/6 Put a space between `<' and argument in pack-objects usage stringŠtěpán Němec, Oct 8, 2010
  39. 6/6 Fix {update,checkout}-index usage stringsŠtěpán Němec, Oct 8, 2010
  40. 0/2 pack-objects: use ALLOC_GROW in place of manual growthJonathan Nieder, Oct 8, 2010
  41. 1/2 Documentation: No argument of ALLOC_GROW should have side-effectsJonathan Nieder, Oct 8, 2010
  42. 2/2 pack-objects: use ALLOC_GROWJonathan Nieder, Oct 8, 2010
  43. 3/2 Allow side-effects in second argument to ALLOC_GROWJonathan Nieder, Oct 8, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.