Skip to content

Commit 58dd7e4

Browse files
committed
Merge branch 'ja/doc-markup-updates'
Documentation rules has been explicitly described how to mark-up literal parts and a few manual pages have been updated as examples. * ja/doc-markup-updates: doc: git-clone: do not autoreference the manpage in itself doc: git-clone: apply new documentation formatting guidelines doc: git-init: apply new documentation formatting guidelines doc: allow literal and emphasis format in doc vs help tests doc: rework CodingGuidelines with new formatting rules
2 parents 4697c8a + ebb5504 commit 58dd7e4

File tree

7 files changed

+216
-185
lines changed

7 files changed

+216
-185
lines changed

Documentation/CodingGuidelines

Lines changed: 85 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -641,15 +641,15 @@ Writing Documentation:
641641
- Prefer succinctness and matter-of-factly describing functionality
642642
in the abstract. E.g.
643643

644-
--short:: Emit output in the short-format.
644+
`--short`:: Emit output in the short-format.
645645

646646
and avoid something like these overly verbose alternatives:
647647

648-
--short:: Use this to emit output in the short-format.
649-
--short:: You can use this to get output in the short-format.
650-
--short:: A user who prefers shorter output could....
651-
--short:: Should a person and/or program want shorter output, he
652-
she/they/it can...
648+
`--short`:: Use this to emit output in the short-format.
649+
`--short`:: You can use this to get output in the short-format.
650+
`--short`:: A user who prefers shorter output could....
651+
`--short`:: Should a person and/or program want shorter output, he
652+
she/they/it can...
653653

654654
This practice often eliminates the need to involve human actors in
655655
your description, but it is a good practice regardless of the
@@ -659,12 +659,12 @@ Writing Documentation:
659659
addressing the hypothetical user, and possibly "we" when
660660
discussing how the program might react to the user. E.g.
661661

662-
You can use this option instead of --xyz, but we might remove
662+
You can use this option instead of `--xyz`, but we might remove
663663
support for it in future versions.
664664

665665
while keeping in mind that you can probably be less verbose, e.g.
666666

667-
Use this instead of --xyz. This option might be removed in future
667+
Use this instead of `--xyz`. This option might be removed in future
668668
versions.
669669

670670
- If you still need to refer to an example person that is
@@ -682,68 +682,118 @@ Writing Documentation:
682682
The same general rule as for code applies -- imitate the existing
683683
conventions.
684684

685-
A few commented examples follow to provide reference when writing or
686-
modifying command usage strings and synopsis sections in the manual
687-
pages:
688685

689-
Placeholders are spelled in lowercase and enclosed in angle brackets:
690-
<file>
691-
--sort=<key>
692-
--abbrev[=<n>]
686+
Markup:
687+
688+
Literal parts (e.g. use of command-line options, command names,
689+
branch names, URLs, pathnames (files and directories), configuration and
690+
environment variables) must be typeset as verbatim (i.e. wrapped with
691+
backticks):
692+
`--pretty=oneline`
693+
`git rev-list`
694+
`remote.pushDefault`
695+
`http://git.example.com`
696+
`.git/config`
697+
`GIT_DIR`
698+
`HEAD`
699+
`umask`(2)
700+
701+
An environment variable must be prefixed with "$" only when referring to its
702+
value and not when referring to the variable itself, in this case there is
703+
nothing to add except the backticks:
704+
`GIT_DIR` is specified
705+
`$GIT_DIR/hooks/pre-receive`
706+
707+
Word phrases enclosed in `backtick characters` are rendered literally
708+
and will not be further expanded. The use of `backticks` to achieve the
709+
previous rule means that literal examples should not use AsciiDoc
710+
escapes.
711+
Correct:
712+
`--pretty=oneline`
713+
Incorrect:
714+
`\--pretty=oneline`
715+
716+
Placeholders are spelled in lowercase and enclosed in
717+
angle brackets surrounded by underscores:
718+
_<file>_
719+
_<commit>_
693720

694721
If a placeholder has multiple words, they are separated by dashes:
695-
<new-branch-name>
696-
--template=<template-directory>
722+
_<new-branch-name>_
723+
_<template-directory>_
724+
725+
A placeholder is not enclosed in backticks, as it is not a literal.
726+
727+
When needed, use a distinctive identifier for placeholders, usually
728+
made of a qualification and a type:
729+
_<git-dir>_
730+
_<key-id>_
731+
732+
When literal and placeholders are mixed, each markup is applied for
733+
each sub-entity. If they are stuck, a special markup, called
734+
unconstrained formatting is required.
735+
Unconstrained formating for placeholders is __<like-this>__
736+
Unconstrained formatting for literal formatting is ++like this++
737+
`--jobs` _<n>_
738+
++--sort=++__<key>__
739+
__<directory>__++/.git++
740+
++remote.++__<name>__++.mirror++
741+
742+
caveat: ++ unconstrained format is not verbatim and may expand
743+
content. Use Asciidoc escapes inside them.
697744

698-
When a placeholder is cited in text paragraph, it is enclosed in angle
699-
brackets to remind the reader the reference in the synopsis section.
700-
For better visibility, the placeholder is typeset in italics:
701-
The _<file>_ to be added.
745+
Synopsis Syntax
746+
747+
Syntax grammar is formatted neither as literal nor as placeholder.
748+
749+
A few commented examples follow to provide reference when writing or
750+
modifying command usage strings and synopsis sections in the manual
751+
pages:
702752

703753
Possibility of multiple occurrences is indicated by three dots:
704-
<file>...
754+
_<file>_...
705755
(One or more of <file>.)
706756

707757
Optional parts are enclosed in square brackets:
708-
[<file>...]
758+
[_<file>_...]
709759
(Zero or more of <file>.)
710760

711-
--exec-path[=<path>]
761+
++--exec-path++[++=++__<path>__]
712762
(Option with an optional argument. Note that the "=" is inside the
713763
brackets.)
714764

715-
[<patch>...]
765+
[_<patch>_...]
716766
(Zero or more of <patch>. Note that the dots are inside, not
717767
outside the brackets.)
718768

719769
Multiple alternatives are indicated with vertical bars:
720-
[-q | --quiet]
721-
[--utf8 | --no-utf8]
770+
[`-q` | `--quiet`]
771+
[`--utf8` | `--no-utf8`]
722772

723773
Use spacing around "|" token(s), but not immediately after opening or
724774
before closing a [] or () pair:
725-
Do: [-q | --quiet]
726-
Don't: [-q|--quiet]
775+
Do: [`-q` | `--quiet`]
776+
Don't: [`-q`|`--quiet`]
727777

728778
Don't use spacing around "|" tokens when they're used to separate the
729779
alternate arguments of an option:
730-
Do: --track[=(direct|inherit)]
731-
Don't: --track[=(direct | inherit)]
780+
Do: ++--track++[++=++(`direct`|`inherit`)]`
781+
Don't: ++--track++[++=++(`direct` | `inherit`)]
732782

733783
Parentheses are used for grouping:
734-
[(<rev> | <range>)...]
784+
[(_<rev>_ | _<range>_)...]
735785
(Any number of either <rev> or <range>. Parens are needed to make
736786
it clear that "..." pertains to both <rev> and <range>.)
737787

738-
[(-p <parent>)...]
788+
[(`-p` _<parent>_)...]
739789
(Any number of option -p, each with one <parent> argument.)
740790

741-
git remote set-head <name> (-a | -d | <branch>)
791+
`git remote set-head` _<name>_ (`-a` | `-d` | _<branch>_)
742792
(One and only one of "-a", "-d" or "<branch>" _must_ (no square
743793
brackets) be provided.)
744794

745795
And a somewhat more contrived example:
746-
--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
796+
`--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]`
747797
Here "=" is outside the brackets, because "--diff-filter=" is a
748798
valid usage. "*" has its own pair of brackets, because it can
749799
(optionally) be specified only when one or more of the letters is
@@ -754,39 +804,6 @@ Writing Documentation:
754804
the user would type into a shell and use 'Git' (uppercase first letter)
755805
when talking about the version control system and its properties.
756806

757-
A few commented examples follow to provide reference when writing or
758-
modifying paragraphs or option/command explanations that contain options
759-
or commands:
760-
761-
Literal examples (e.g. use of command-line options, command names,
762-
branch names, URLs, pathnames (files and directories), configuration and
763-
environment variables) must be typeset in monospace (i.e. wrapped with
764-
backticks):
765-
`--pretty=oneline`
766-
`git rev-list`
767-
`remote.pushDefault`
768-
`http://git.example.com`
769-
`.git/config`
770-
`GIT_DIR`
771-
`HEAD`
772-
773-
An environment variable must be prefixed with "$" only when referring to its
774-
value and not when referring to the variable itself, in this case there is
775-
nothing to add except the backticks:
776-
`GIT_DIR` is specified
777-
`$GIT_DIR/hooks/pre-receive`
778-
779-
Word phrases enclosed in `backtick characters` are rendered literally
780-
and will not be further expanded. The use of `backticks` to achieve the
781-
previous rule means that literal examples should not use AsciiDoc
782-
escapes.
783-
Correct:
784-
`--pretty=oneline`
785-
Incorrect:
786-
`\--pretty=oneline`
787-
788-
A placeholder is not enclosed in backticks, as it is not a literal.
789-
790807
If some place in the documentation needs to typeset a command usage
791808
example with inline substitutions, it is fine to use +monospaced and
792809
inline substituted text+ instead of `monospaced literal text`, and with

Documentation/config/clone.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
clone.defaultRemoteName::
1+
`clone.defaultRemoteName`::
22
The name of the remote to create when cloning a repository. Defaults to
3-
`origin`, and can be overridden by passing the `--origin` command-line
3+
`origin`.
4+
ifdef::git-clone[]
5+
It can be overridden by passing the `--origin` command-line
6+
option.
7+
endif::[]
8+
ifndef::git-clone[]
9+
It can be overridden by passing the `--origin` command-line
410
option to linkgit:git-clone[1].
11+
endif::[]
512

6-
clone.rejectShallow::
13+
`clone.rejectShallow`::
714
Reject cloning a repository if it is a shallow one; this can be overridden by
8-
passing the `--reject-shallow` option on the command line. See linkgit:git-clone[1]
15+
passing the `--reject-shallow` option on the command line.
16+
ifndef::git-clone[]
17+
See linkgit:git-clone[1].
18+
endif::[]
919

10-
clone.filterSubmodules::
20+
`clone.filterSubmodules`::
1121
If a partial clone filter is provided (see `--filter` in
1222
linkgit:git-rev-list[1]) and `--recurse-submodules` is used, also apply
1323
the filter to submodules.

Documentation/config/init.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ ifndef::git-init[]
33
:see-git-init: (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].)
44
endif::[]
55

6-
init.templateDir::
6+
`init.templateDir`::
77
Specify the directory from which templates will be copied. {see-git-init}
8-
init.defaultBranch::
8+
`init.defaultBranch`::
99
Allows overriding the default branch name e.g. when initializing
1010
a new repository.

0 commit comments

Comments
 (0)