MAN-PAGES(7) | Linux Programmer's Manual | MAN-PAGES(7) |
man-pages - Linux の man ページを書く際の決まり事
man [section] title
This page describes the conventions that should be employed when writing man pages for the Linux man-pages project, which documents the user-space API provided by the Linux kernel and the GNU C library. The project thus provides most of the pages in Section 2, many of the pages that appear in Sections 3, 4, and 7, and a few of the pages that appear in Sections 1, 5, and 8 of the man pages on a Linux system. The conventions described on this page may also be useful for authors writing man pages for other projects.
マニュアルのセクションは、習慣的に以下のような定義が用いられている:
新しいマニュアルページは man(7) で説明されている groff an.tmac パッケージを使って記述すべきである。 この方針は一貫性の確保が主な理由である。既存の Linux のマニュアルページ の圧倒的多数がこれらのマクロを使って記述されている。
マニュアルページのソースコードの 1行の長さは 可能な限り 75文字を越えないようにしてほしい。 こうすることで、パッチをメール本文に載せて送る場合に、 メールクライアントによる行折り返しを回避することができる。
man ページの最初の行は TH コマンドにすべきである。
The arguments of the command are as follows:
昔から使われてきたセクション名を以下のリストに示す。 これらを使うと良いだろう。 一般的に、マニュアルページは、少なくとも 色つき のセクションを持つのが望ましい。 新しくマニュアルページを作成する際には、だいたい以下のリストに示した 順序でセクションを配置するようにしてもらいたい。
名前 (NAME) | |
書式 (SYNOPSIS) | |
CONFIGURATION | [Normally only in Section 4] |
説明 (DESCRIPTION) | |
OPTIONS | [Normally only in Sections 1, 8] |
EXIT STATUS | [Normally only in Sections 1, 8] |
返り値 | [Normally only in Sections 2, 3] |
ERRORS | [Typically only in Sections 2, 3] |
ENVIRONMENT | |
ファイル | |
VERSIONS | [Normally only in Sections 2, 3] |
ATTRIBUTES | [Normally only in Sections 2, 3] |
準拠 | |
注意 | |
バグ | |
例 | |
AUTHORS | [Discouraged] |
REPORTING BUGS | [Not used in man-pages] |
COPYRIGHT | [Not used in man-pages] |
関連項目 (SEE ALSO) |
「伝統的に使われてきた見出しが使える場合には、それを使ってほしい。」 この種の一貫性を保つことで、情報を理解しやすくなるからである。 どうしても必要な場合には、理解しやすくなるように独自の見出しを 作ってもよい (特にセクション 4 や 5 のページではこうした方が わかりやすくなる)。ただし、そうする前に、伝統的な見出しを使い、 そのセクション内にサブセクション (.SS) を設けることで 対応できないか考えてほしい。
以下のリストでは、上記のセクションのそれぞれの内容について 詳しく説明する。
以下の節ではman-pagesプロジェクトで推奨のスタイルについて説明している。 ここで触れられていない点については、"the Chicago Manual of Style" がたいていはよい情報源になるだろう。 また、すでに使用されているスタイルについてはプロジェクトのソースツリーを検索してみてほしい。 (訳注:この章では英語の原文でのスタイルについて説明しており、日本語マニュアルにはあわない点もあるため、具体例などは英語のままとしている箇所もあります。)
可能な限り、マニュアルページの文章では性別の区別のない表現を使用すること。 性別に区別のない単数形の代名詞として "they" ("them", "themself", "their") を使用してもよい。
For manual pages that describe a command (typically in Sections 1 and 8), the arguments are always specified using italics, even in the SYNOPSIS section.
The name of the command, and its options, should always be formatted in bold.
For manual pages that describe functions (typically in Sections 2 and 3), the arguments are always specified using italics, even in the SYNOPSIS section, where the rest of the function is specified in bold:
int myfunction(int argc, char **argv);
引数名といった変数名はイタリック体を指定すべきである。
Any reference to the subject of the current manual page should be written with the name in bold followed by a pair of parentheses in Roman (normal) font. For example, in the fcntl(2) man page, references to the subject of the page would be written as: fcntl(). The preferred way to write this in the source file is:
.BR fcntl ()
("\fB...\fP()" よりも、この形式を使うこと。 これにより、マニュアルページのソースファイルを解釈するツールを 書くのが簡単になる。)
In the source of a manual page, new sentences should be started on new lines, and long sentences should split into lines at clause breaks (commas, semicolons, colons, and so on). This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences or sentence clauses.
Paragraphs should be separated by suitable markers (usually either .PP or .IP). Do not separate paragraphs using blank lines, as this results in poor rendering in some output formats (such as PostScript and PDF).
ファイル名 (パス名、またはヘッダーファイルへの参照) は常にイタリック体にする (例: <stdio.h>)。 ただし、書式 (SYNOPSIS) セクションは例外で、 インクルードファイルはボールドにする (例: #include <stdio.h>)。 標準のインクルードヘッダーファイルを参照する際は、 通常の C 言語と同様に山括弧でヘッダーファイルを囲ぬで指定する (例: <stdio.h>)。
通常、大文字で表現する特殊マクロはボールドで表す (例えば MAXINT)。 例外として NULL はボールドにしない。
エラーコードのリストを列挙する時には、コードはボールドで表す (このリストには通常 .TP マクロを用いる)。
完全なコマンドは、長い場合には、例に示すように 字下げした行にコマンドだけを記載し、コマンドの前後には空行を置くべきである。
man 7 man-pages
コマンドが短い場合は、 man 7 man-pages のようにイタリック体で文中に埋め込んで記載してもよい。 この場合、コマンド内の適切な位置に、改行できないスペース ("\ ") を使うとよいかもしれない。 コマンドオプションも (-l のように) イタリック体で記載すべきである。
式は、専用の字下げした行に記載しない場合、イタリック体を指定すること。 繰り返しになるが、式を通常の文中に埋め込む場合にも、 改行できないスペースを使うとよいだろう。
When showing example shell sessions, user input should be formatted in bold, for example
$ date Thu Jul 7 13:01:27 CEST 2016
別のマニュアルページへの参照は、ボールドで名前を記載し、 それに続けてセクション番号を「必ず」書く。セクション番号は ローマンフォント (通常のフォント) で書き、スペースは入れない (例: intro(2))。 マニュアルページのソースファイルには次のように記載するのが望ましい:
.BR intro (2)
(相互参照にセクション番号を含めておくと、 man2html といったツールがページ間のハイパーリンクを適切に生成できる。)
Control characters should be written in bold face, with no quotes; for example, ^X.
リリース 2.59 からだが、 man-pages はアメリカ英語の綴りの慣習に従っている (以前はイギリス英語とアメリカ英語が基準もなく混在して使われていた)。 新しいページやパッチは全てこの慣習に従って下さい。
よく知られた綴りの違い以外に、微妙な違いもいくつか見られる。
BSD バージョン番号の伝統的な表記方法は x.yBSD である (x.y はバージョン番号; 例: 4.2BSD)。 BSD 4.3 といった表記は避けること。
サブセクション ("SS") 見出しでは、最初の単語だけ先頭文字を大文字にし、残りの単語は小文字にすること。但し、英語の用法 (例えば、固有名詞) やプログラミング言語の要件 (例えば、識別子の名前) などで別の表記をする場合はこの限りではない。
.SS Unicode under Linux
When structure definitions, shell session logs, and so on are included in running text, indent them by 4 spaces (i.e., a block enclosed by .in +4n and .in), format them using the .EX and EE macros, and surround them with suitable paragraph markers (either .PP or .IP). For example:
.PP .in +4n .EX int main(int argc, char *argv[]) { return 0; } .EE .in .PP
以下の表にマニュアルページでの使用が推奨される用語を示す。これらは主にマニュアルページ間での一貫性を保つためである。
用語 | 使用を避ける単語 | 備考 |
bit mask | bitmask | |
built-in | builtin | |
Epoch | epoch | For the UNIX Epoch (00:00:00, 1 Jan 1970 UTC) |
filename | file name | |
filesystem | file system | |
hostname | host name | |
inode | i-node | |
lowercase | lower case, lower-case | |
nonzero | non-zero | |
pathname | path name | |
pseudoterminal | pseudo-terminal | |
privileged port | reserved port, system port | |
real-time | realtime, real time | |
run time | runtime | |
saved set-group-ID | saved group ID, saved set-GID | |
saved set-user-ID | saved user ID, saved set-UID | |
set-group-ID | set-GID, setgid | |
set-user-ID | set-UID, setuid | |
superuser | super user, super-user | |
superblock | super block, super-block | |
timestamp | time stamp | |
timezone | time zone | |
uppercase | upper case, upper-case | |
usable | useable | |
user space | userspace | |
username | user name | |
x86-64 | x86_64 | Except if referring to result of "uname -m" or similar |
zeros | zeroes |
以下の修飾子としての複合語におけるハイフンの議論も参照。
以下の表にマニュアルページでの使用を避けるべき用語を示す。 推奨される表現も合わせて記載している。 これらは主にマニュアルページ間での一貫性を保つためである。
使用を避ける | 使用を推奨 | 備考 |
32bit | 32-bit | 8-bit, 16-bit なども同様 |
current process | calling process | カーネルプログラマーがマニュアルページを書く際によくする間違い |
manpage | man page, manual page | |
minus infinity | negative infinity | |
non-root | unprivileged user | |
non-superuser | unprivileged user | |
nonprivileged | unprivileged | |
OS | operating system | |
plus infinity | positive infinity | |
pty | pseudoterminal | |
tty | terminal | |
Unices | UNIX systems | |
Unixes | UNIX systems |
商標については正しい綴りと大文字小文字を使うこと。以下は時々綴りの間違いがある商標の正しい綴りのリストである。
DG/UX
HP-UX
UNIX
UnixWare
null pointer (ヌルポインター) は何もないものを指すポインターで、通常は定数 NULL で示される。 一方、 NUL は null byte (ヌルバイト、値 0 のバイト) で、 C では文字定数 '\0' と表現される。
ポインターとして推奨される用語は "null pointer" (ヌルポインター) もしくは単に "NULL" である。 "NULL pointer" と記載するのは避けること。
バイトとして推奨される用語は "null byte" (ヌルバイト) である。 "NUL" と記載するのは避けること。 "NUL" は "NULL" と間違われることが非常に多いからである。 また、 "zero byte" (ゼロバイト) と "null character" (ヌル文字) も避けること。 C の文字列を終端するバイトは "the terminating null byte" (終端ヌルバイト)、 文字列の説明として使う場合には "null-terminated" (ヌル終端された) と記載すべきである。 "NUL-terminated" の使用は避けること。
ハイパーリンクについては、 .UR/.UE マクロの組を使うこと (groff_man(7) 参照)。ページを以下のようにレンダリングする場合に、このマクロはウェブブラウザーで使用できる正しいハイパーリンクを生成してくれる。
BROWSER=firefox man -H pagename
In general, the use of abbreviations such as "e.g.", "i.e.", "etc.", "cf.", and "a.k.a." should be avoided, in favor of suitable full wordings ("for example", "that is", "and so on", "compare to", "also known as").
これらの省略形の使用が認められる唯一の場所は、 短い括弧で囲まれた余談 ("(e.g., like this one)") の場合である。
ここで記載しているように、これらの省略形では必ずピリオドを入れること。 また、"e.g." と "i.e." では常に後にカンマも付けること。
*roff で em によるダッシュ—この部分の両端にある記号—を書くには "\(em" を使う。 (ASCII 端末では em によるダッシュは通常ハイフン 2 つとして表示されるが、別の活版印刷の場合などでは長いダッシュとして表示されることもある。) em によるダッシュの両側にはスペースを置かないこと。
何かを修飾する際 (すなわち後続の名詞を限定する場合) 複合語にはハイフンを入れること。いくつか例を挙げる。
32-bit value (32 ビット値)
command-line argument
(コマンドライン引数)
floating-point number (浮動小数点数)
run-time check (実行時チェック)
user-space function
(ユーザー空間関数)
wide-character string
(ワイド文字の文字列)
一般的に最近の英語の傾向では、"multi", "non", "pre", "re", "sub" などの接尾辞の後ろにはハイフンを付けない。 これらの接尾辞が単純な接尾語との普通の英語の組み合わせの場合には、 マニュアルページでは基本的にこのルールに従う。 以下のリストに推奨される形式での例をいくつか挙げる。
interprocess
multithreaded
multiprocess
nonblocking
nondefault
nonempty
noninteractive
nonnegative
nonportable
nonzero
preallocated
precreate
prerecorded
reestablished
reinitialize
rearm
reread
subcomponent
subdirectory
subsystem
接尾語が通常の英単語以外 (商標、固有名詞、頭字語、複合語) と組み合わされる場合は、ハイフンを使うこと。以下に例を挙げる。
non-ASCII
non-English
non-NULL
non-real-time
最後に、"re-create" と "recreate" は異なる別の動詞である点に注意すること。たいていの場合、使おうと思っているのは前者であろう。
Where a real minus character is required (e.g., for numbers such as -1, for man page cross references such as utf-8(7), or when writing options that have a leading dash, such as in ls -l), use the following form in the man page source:
\-
このガイドラインはサンプルコードの場合にも適用される。
To produce unslanted single quotes that render well in ASCII, UTF-8, and PDF, use "\(aq" ("apostrophe quote"); for example
\(aqC\(aq
ここで C が括弧で囲まれる文字である。このガイドラインはサンプルコードの場合にも適用される。
Where a proper caret (^) that renders well in both a terminal and PDF is required, use "\(ha". This is especially necessary in code samples, to get a nicely rendered caret when rendering to PDF.
Using a naked "~" character results in a poor rendering in PDF. Instead use "\(ti". This is especially necessary in code samples, to get a nicely rendered tilde when rendering to PDF.
マニュアルページには、システムコールやライブラリ関数の使い方を示す サンプルプログラムを含めることができる。 その際には、以下の点に留意すべきである。
プログラムの使い方や他のシステムの特徴を示すためにシェルのセッションログを含める場合、
サンプルプログラムがどんな風になっていればよいかの例については、 wait(2) と pipe(2) を参照すること。
man-pages パッケージに含まれるマニュアルページの体裁の標準的な例については、 pipe(2) と fcntl(2) を参照すること。
man(1), man2html(1), attributes(7), groff(7), groff_man(7), man(7), mdoc(7)
この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。
2020-08-13 | Linux |