Re: [PATCH] Documentation/git-stash.txt: Adjust SYNOPSIS command syntaxes

Previous thread: git-svn segmetation fault by Wink Saville on Friday, February 1, 2008 - 6:32 pm. (12 messages)

Next thread: [PATCH] --format=pretty: new modifiers cID, cIM, CIS by Jari Aalto on Friday, February 1, 2008 - 6:43 pm. (1 message)
To: <git@...>
Date: Friday, February 1, 2008 - 6:37 pm

* Fri 2008-02-01 Jakub Narebski <jnareb@gmail.com>

In regexp language yes, but in describing the command syntaxes, I do not

The angles primarily denote "required", and secondarily that you put

Tat is highly uncommon. In angle bracket notation this is unabiguous:

command <parameter1|parameter2> <file ...>
A B

In angles, it's clear that both A and B are required; in A, you must

The bracket's primary meaning is to say "optional" in command
definitions. They do not "group"; they nest -- saying that there are

Angle brackets do not mean "substitute your own input", but they deonote
a requirement; how the requirement is filled is done according to the
description in the documentation.

command <"save"|"load">

In unabiguous way to say that the choices for words are "save" and
"load" of which one of them must be supplied.

The reason why angle angles are used is that they are shell redirection
metacharacters --- which never appear in that quality in standard manual
page SYNOPSIS. The angles cannot be understood in any other way than as
a "requirement" in the command definition.

Jari

--
Welcome to FOSS revolution: we fix and modify until it shines

-

To: Jari Aalto <jari.aalto@...>
Cc: Jakub Narebski <jnareb@...>, Junio C Hamano <gitster@...>, <git@...>
Date: Friday, February 1, 2008 - 8:38 pm

It seems that I was mistaken about that. Junio suggestion of following
others example and using "{}" curly brackets for grouping alternate
choices is IMHO a good solution.

The "<>" angle brackets does not denote required. Not in git manpages,

They do group. "command [A|B]" means "command" or "command A" or

In our (git) manual pages "<text>" denotes placeholders.

The traditional manpages use /italics/ (usually rendered as
_underlined_ text on terminals) to denote placeholders (user supplied
input).

I think we better decide on syntax used in SYNOPSIS section, and
perhaps even document it CodingGuidelines

-- >8 --

From http://www.linux.com/articles/34212

The SYNOPSIS section describes the usage of the command. In general,
it should look very much like a traditional usage message. [...]
By convention, optional arguments are surrounded by square brackets.

From man(7)

SYNOPSIS briefly describes the command or function's interface. For
commands, this shows the syntax of the command and its argu-
ments (including options); boldface is used for as-is text
and italics are used to indicate replaceable arguments.
Brackets ([]) surround optional arguments, vertical bars (|)
separate choices, and ellipses (...) can be repeated.

From manpages(5), Darwin documentation

MANUAL PAGE SYNTAX
In manual page syntax, anything in a normal text font is required
text. Anything in a boldface font is a flag or a subcommand.
Anything underlined is a user-specified argument such as a
filename.

Any argument surrounded by brackets is considered to be optional.
For example, [ filename ] would indicate an optional filename
argument.

Flags, arguments, or subcommands separated by a vertical
separator (|) are mutually exclusive. For example, if -a turns
on an option and -b turns off the option, the syntax for this
...

To: Jari Aalto <jari.aalto@...>
Cc: <git@...>
Date: Friday, February 1, 2008 - 7:26 pm

Actually, I've never seen any less-than-greater-than used to
group alternates command description of traditional manual
pages. So I'd say both may be unusual, but yours is a lot more
unusual.

For example, GNU 'tar' uses | for alternates, but it does not
mark grouping:

SYNOPSIS
tar [ - ] A --catenate --concatenate | c --create | d --diff --compare
| --delete | r --append | t --list | u --update | x --extract --get [
options ] pathname [ pathname ... ]

which is horribly confusing to read.

GNU 'cpio' makes it somewhat easier to read by listing
subcommands separately:

SYNOPSIS
cpio {-o|--create} [-0acvABLV] [-C bytes] [-H format] [-M message] [-O
[[user@]host:]archive] [-F [[user@]host:]archive]
[--file=[[user@]host:]archive] [--format=format] [--message=message]
[--null] [--reset-access-time] [--verbose] [--dot] [--append] [--block-
size=blocks] [--dereference] [--io-size=bytes] [--quiet]
[--force-local] [--rsh-command=command] [--help] [--version] < name-
list [> archive]

cpio {-i|--extract} [-bcdfmnrtsuvBSV] [-C bytes] [-E file] [-H format]
...

But when they have alternates, they use braces {} to group them.

Solaris 'tar' lists subcommand separately, and seems to use
braces {} for grouping alternates:

SYNOPSIS
tar c [ bBeEfFhiklnopPqvwX [ 0-7 ] ] [ block ] [
tarfile ] [ exclude-file ] { -I include-file | -C direc-
tory | file | file } ...

In our manual pages, less-than-greater-than around names are
very often used to mark placeholders. If you want to say zero
or more files, you would typically say:

command <file>...

Using something other than less-than-greater-than to group
alternates would make things easier to differentiate. If we
used braces {} it _might_ have been more similar to what other
people have traditionally done.

-

Previous thread: git-svn segmetation fault by Wink Saville on Friday, February 1, 2008 - 6:32 pm. (12 messages)

Next thread: [PATCH] --format=pretty: new modifiers cID, cIM, CIS by Jari Aalto on Friday, February 1, 2008 - 6:43 pm. (1 message)