내 전동 공구에 대한 매뉴얼 페이지 항목을 추가하려면 어떻게해야합니까?


42

집에서 만든 전문 스크립트 (주로 Bash와 Perl로 작성)를 man페이지를 통해 사용할 수있게하는 방법에 대해서는 전혀 모른다 .

어떤 절차를 따라야합니까?이 작업을 수행하려면 문서를 작성해야하는 특정 형식이 있습니까?


4
이 작업을 수행하기 만하면 +1됩니다. asciidoc, Restructured Text, POD, docbook은 모두 사람 형식으로 변환됩니다.
chiggsy

답변:


19

필자는 Perl의 POD 를 사용하는 것이 매뉴얼 페이지를 직접 작성하는 것보다 훨씬 쉽다는 것을 알았으며 pod2man유틸리티 (기본 Perl 패키지의 일부)를 사용 하여 POD 파일에서 매뉴얼 페이지를 만들 수 있습니다 . 일부 실행 파일은 이미 Perl로 작성되었으므로 POD 형식을 스크립트에 직접 추가하고 POD 파일로 직접 변환 할 수 있습니다. 또한 POD의 단순성으로 인해 코드가 다른 언어로 작성된 경우에도 여러 프로젝트가 POD 형식을 사용하는 것을 보았습니다.

매뉴얼 페이지의 추가 디렉토리를 추가하기 위해 $MANPATH환경 변수를 설정할 수 있습니다 . 이미 구성된 man 경로 목록에 추가 할 접두사 $MANPATHa :. manpath현재 정의 된 man 경로를 보려면 명령을 사용하십시오 .


8

간단히 말해서 man groff_man파일 형식 ( web version )을 참조하십시오 .

저장 /usr/local/man/man1하거나 /usr/share/man/man1작동하지 않는 경우 저장하십시오 .

자세한 내용 은 Man Page HOWTO 를 참조하십시오.


"man groff"를 읽어야한다고 생각합니다.
chris

groff가 지원하는 각 파일 형식에 대한 별도의 매뉴얼 페이지가 있습니다. 매뉴얼 페이지 용 문서는 groff_an또는에 있어야 groff_man하지만 기본 패키지가 아닌 패키지를 설치해야 할 수도 있습니다.
Mikel

그러나 그렇습니다, 나는 간단히 말했고 groff_an, 대부분의 사람들에게는 그것이 groff_man당신이 말하는 것이 될 것 입니다. :-)
Mikel

6

시도해보십시오 pandocStackOverflow 에서 알고있는 확장 된 마크 다운 구문을 사용합니다 .

다음매뉴얼 페이지 의 예입니다 .

% PANDOC(1) Pandoc User Manuals
% John MacFarlane
% January 8, 2008

# NAME

pandoc - general markup converter

# SYNOPSIS

pandoc [*options*] [*input-file*]...

# DESCRIPTION

Pandoc converts files from one markup format to another. It can
read markdown and (subsets of) reStructuredText, HTML, and LaTeX, and
it can write plain text, markdown, reStructuredText, HTML, LaTeX,
ConTeXt, Texinfo, groff man, MediaWiki markup, RTF, OpenDocument XML,
ODT, DocBook XML, EPUB, and Slidy or S5 HTML slide shows.

If no *input-file* is specified, input is read from *stdin*.
Otherwise, the *input-files* are concatenated (with a blank
line between each) and used as input.  Output goes to *stdout* by
default (though output to *stdout* is disabled for the `odt` and
`epub` output formats).  For output to a file, use the `-o` option:

    pandoc -o output.html input.txt

Instead of a file, an absolute URI may be given.  In this case
pandoc will fetch the content using HTTP:

    pandoc -f html -t markdown http://www.fsf.org

The input and output formats may be specified using command-line options
(see **OPTIONS**, below, for details).  If these formats are not
specified explicitly, Pandoc will attempt to determine them
from the extensions of the input and output filenames.  If input comes
from *stdin* or from a file with an unknown extension, the input is assumed
to be markdown.  If no output filename is specified using the `-o`
option, or if a filename is specified but its extension is unknown,
the output will default to HTML.  Thus, for example,

    pandoc -o chap1.tex chap1.txt

converts *chap1.txt* from markdown to LaTeX.  And

    pandoc README

converts *README* from markdown to HTML.

Pandoc's version of markdown is an extended variant of standard
markdown: the differences are described in the *README* file in
the user documentation.  If standard markdown syntax is desired, the
`--strict` option may be used.

Pandoc uses the UTF-8 character encoding for both input and output.
If your local character encoding is not UTF-8, you
should pipe input and output through `iconv`:

    iconv -t utf-8 input.txt | pandoc | iconv -f utf-8

# OPTIONS

-f *FORMAT*, -r *FORMAT*, \--from=*FORMAT*, \--read=*FORMAT*
:   Specify input format.  *FORMAT* can be
    `native` (native Haskell), `markdown` (markdown or plain text),
    `rst` (reStructuredText), `html` (HTML), or `latex` (LaTeX).
    If `+lhs` is appended to `markdown`, `rst`, or `latex`, the input
    will be treated as literate Haskell source.

-t *FORMAT*, -w *FORMAT*, \--to=*FORMAT*, \--write=*FORMAT*
:   Specify output format.  *FORMAT* can be `native` (native Haskell),
    `plain` (plain text), `markdown` (markdown), `rst` (reStructuredText),
    `html` (HTML), `latex` (LaTeX), `context` (ConTeXt), `man` (groff man), 
    `mediawiki` (MediaWiki markup), `texinfo` (GNU Texinfo),
    `docbook` (DocBook XML), `opendocument` (OpenDocument XML),
    `odt` (OpenOffice text document), `epub` (EPUB book),
    `slidy` (Slidy HTML and javascript slide show),
    `s5` (S5 HTML and javascript slide show), or `rtf` (rich text
    format). Note that `odt` and `epub` output will not be directed to
    *stdout*; an output filename must be specified using the `-o/--output`
    option.  If `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`,
    the output will be rendered as literate Haskell source.

-s, \--standalone
:   Produce output with an appropriate header and footer (e.g. a
    standalone HTML, LaTeX, or RTF file, not a fragment).

-o *FILE*, \--output=*FILE*
:   Write output to *FILE* instead of *stdout*.  If *FILE* is
    \``-`', output will go to *stdout*.

-p, \--preserve-tabs
:   Preserve tabs instead of converting them to spaces.

\--tab-stop=*TABSTOP*
:   Specify tab stop (default is 4).

\--strict
:   Use strict markdown syntax, with no extensions or variants.

\--reference-links
:   Use reference-style links, rather than inline links, in writing markdown
    or reStructuredText.

-R, \--parse-raw
:   Parse untranslatable HTML codes and LaTeX environments as raw HTML
    or LaTeX, instead of ignoring them.

-S, \--smart
:   Use smart quotes, dashes, and ellipses.  (This option is significant
    only when the input format is `markdown`.  It is selected automatically
    when the output format is `latex` or `context`.)

-m*URL*, \--latexmathml=*URL*
:   Use LaTeXMathML to display embedded TeX math in HTML output.
    To insert a link to a local copy of the `LaTeXMathML.js` script,
    provide a *URL*. If no *URL* is provided, the contents of the
    script will be inserted directly into the HTML header.

\--mathml
:   Convert TeX math to MathML.  In standalone mode, a small javascript
    will be inserted that allows the MathML to be viewed on some browsers.

\--jsmath=*URL*
:   Use jsMath to display embedded TeX math in HTML output.
    The *URL* should point to the jsMath load script; if provided,
    it will be linked to in the header of standalone HTML documents.

\--gladtex
:   Enclose TeX math in `<eq>` tags in HTML output.  These can then
    be processed by gladTeX to produce links to images of the typeset
    formulas. 

\--mimetex=*URL*
:   Render TeX math using the mimeTeX CGI script.  If *URL* is not specified,
    it is assumed that the script is at `/cgi-bin/mimetex.cgi`.

\--webtex=*URL*
:   Render TeX math using an external script. The formula will be
    concatenated with the URL provided. If *URL* is not specified, the
    Google Chart API will be used.

-i, \--incremental
:   Make list items in Slidy or S5 display incrementally (one by one).

\--offline
:   Include all the CSS and javascript needed for a Slidy or S5 slide
    show in the output, so that the slide show will work even when no
    internet connection is available.

\--xetex
:   Create LaTeX outut suitable for processing by XeTeX.

-N, \--number-sections
:   Number section headings in LaTeX, ConTeXt, or HTML output.
    (Default is not to number them.)

\--section-divs
:   Wrap sections in `<div>` tags, and attach identifiers to the
    enclosing `<div>` rather than the header itself.

\--no-wrap
:   Disable text wrapping in output. (Default is to wrap text.)

\--sanitize-html
:   Sanitizes HTML (in markdown or HTML input) using a whitelist.
    Unsafe tags are replaced by HTML comments; unsafe attributes
    are omitted.  URIs in links and images are also checked against a
    whitelist of URI schemes.

\--email-obfuscation=*none|javascript|references*
:   Specify a method for obfuscating `mailto:` links in HTML documents.
    *none* leaves `mailto:` links as they are.  *javascript* obfuscates
    them using javascript. *references* obfuscates them by printing their
    letters as decimal or hexadecimal character references.
    If `--strict` is specified, *references* is used regardless of the
    presence of this option.

\--id-prefix*=string*
:   Specify a prefix to be added to all automatically generated identifiers
    in HTML output.  This is useful for preventing duplicate identifiers
    when generating fragments to be included in other pages.

\--indented-code-classes*=classes*
:   Specify classes to use for indented code blocks--for example,
    `perl,numberLines` or `haskell`. Multiple classes may be separated
    by spaces or commas.

\--toc, \--table-of-contents
:   Include an automatically generated table of contents (HTML, markdown,
    RTF) or an instruction to create one (LaTeX, reStructuredText).
    This option has no effect on man, DocBook, Slidy, or S5 output.

\--base-header-level=*LEVEL*
:   Specify the base level for headers (defaults to 1).

\--template=*FILE*
:   Use *FILE* as a custom template for the generated document. Implies
    `-s`. See TEMPLATES below for a description of template syntax. If
    this option is not used, a default template appropriate for the
    output format will be used. See also `-D/--print-default-template`.

-V KEY=VAL, \--variable=*KEY:VAL*
:   Set the template variable KEY to the value VAL when rendering the
    document in standalone mode. This is only useful when the
    `--template` option is used to specify a custom template, since
    pandoc automatically sets the variables used in the default
    templates.

-c *CSS*, \--css=*CSS*
:   Link to a CSS style sheet.  *CSS* is the pathname of the style sheet.

-H *FILE*, \--include-in-header=*FILE*
:   Include contents of *FILE* at the end of the header.  Implies `-s`.

-B *FILE*, \--include-before-body=*FILE*
:   Include contents of *FILE* at the beginning of the document body.
    Implies `-s`.

-A *FILE*, \--include-after-body=*FILE*
:   Include contents of *FILE* at the end of the document body.
    Implies `-s`.

-C *FILE*, \--custom-header=*FILE*
:   Use contents of *FILE* as the document header. *Note: This option is
    deprecated. Users should transition to using `--template` instead.*

\--reference-odt=*filename*
:   Use the specified file as a style reference in producing an ODT.
    For best results, the reference ODT should be a modified version
    of an ODT produced using pandoc.  The contents of the reference ODT
    are ignored, but its stylesheets are used in the new ODT. If no
    reference ODT is specified on the command line, pandoc will look
    for a file `reference.odt` in the user data directory (see
    `--data-dir`). If this is not found either, sensible defaults will be
    used.

\--epub-stylesheet=*filename*
:   Use the specified CSS file to style the EPUB.  If no stylesheet
    is specified, pandoc will look for a file `epub.css` in the
    user data directory (see `--data-dir`, below).  If it is not
    found there, sensible defaults will be used.

\--epub-metadata=*filename*
:   Look in the specified XML file for metadata for the EPUB.
    The file should contain a series of Dublin Core elements
    (http://dublincore.org/documents/dces/), for example:

         <dc:rights>Creative Commons</dc:rights>
         <dc:language>es-AR</dc:language>

    By default, pandoc will include the following metadata elements:
    `<dc:title>` (from the document title), `<dc:creator>` (from the
    document authors), `<dc:language>` (from the locale), and
    `<dc:identifier id="BookId">` (a randomly generated UUID). Any of
    these may be overridden by elements in the metadata file.

-D *FORMAT*, \--print-default-template=*FORMAT*
:   Print the default template for an output *FORMAT*. (See `-t`
    for a list of possible *FORMAT*s.)

-T *STRING*, \--title-prefix=*STRING*
:   Specify *STRING* as a prefix to the HTML window title.

\--data-dir*=DIRECTORY*
:   Specify the user data directory to search for pandoc data files.
    If this option is not specified, the default user data directory
    will be used:

        $HOME/.pandoc

    in unix and

        C:\Documents And Settings\USERNAME\Application Data\pandoc

    in Windows. A `reference.odt`, `epub.css`, `templates` directory,
    or `s5` directory placed in this directory will override pandoc's
    normal defaults.

\--dump-args
:   Print information about command-line arguments to *stdout*, then exit.
    The first line of output contains the name of the output file specified
    with the `-o` option, or \``-`' (for *stdout*) if no output file was
    specified.  The remaining lines contain the command-line arguments,
    one per line, in the order they appear.  These do not include regular
    Pandoc options and their arguments, but do include any options appearing
    after a \``--`' separator at the end of the line.
    This option is intended primarily for use in wrapper scripts.

\--ignore-args
:   Ignore command-line arguments (for use in wrapper scripts).
    Regular Pandoc options are not ignored.  Thus, for example,

        pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1

    is equivalent to

        pandoc -o foo.html -s

-v, \--version
:   Print version.

-h, \--help
:   Show usage message.

# TEMPLATES

When the `-s/--standalone` option is used, pandoc uses a template to
add header and footer material that is needed for a self-standing
document.  To see the default template that is used, just type

    pandoc --print-default-template=FORMAT

where `FORMAT` is the name of the output format. A custom template
can be specified using the `--template` option.  You can also override
the system default templates for a given output format `FORMAT`
by putting a file `templates/FORMAT.template` in the user data
directory (see `--data-dir`, below).

Templates may contain *variables*.  Variable names are sequences of
alphanumerics, `-`, and `_`, starting with a letter.  A variable name
surrounded by `$` signs will be replaced by its value.  For example,
the string `$title$` in

    <title>$title$</title>

will be replaced by the document title.

To write a literal `$` in a template, use `$$`.

Some variables are set automatically by pandoc.  These vary somewhat
depending on the output format, but include:

`legacy-header`
:   contents specified by `-C/--custom-header`
`header-includes`
:   contents specified by `-H/--include-in-header` (may have multiple
    values)
`toc`
:   non-null value if `--toc/--table-of-contents` was specified
`include-before`
:   contents specified by `-B/--include-before-body` (may have
    multiple values)
`include-after`
:   contents specified by `-A/--include-after-body` (may have
    multiple values)
`body`
:   body of document
`title`
:   title of document, as specified in title block
`author`
:   author of document, as specified in title block (may have
    multiple values)
`date`
:   date of document, as specified in title block

Variables may be set at the command line using the `-V/--variable`
option. This allows users to include custom variables in their
templates.

Templates may contain conditionals.  The syntax is as follows:

    $if(variable)$
    X 
    $else$
    Y
    $endif$

This will include `X` in the template if `variable` has a non-null
value; otherwise it will include `Y`. `X` and `Y` are placeholders for
any valid template text, and may include interpolated variables or other
conditionals. The `$else$` section may be omitted.

When variables can have multiple values (for example, `author` in
a multi-author document), you can use the `$for$` keyword:

    $for(author)$
    <meta name="author" content="$author$" />
    $endfor$

You can optionally specify a separator to be used between
consecutive items:

    $for(author)$$author$$sep$, $endfor$

# SEE ALSO

`markdown2pdf` (1).
The *README* file distributed with Pandoc contains full documentation.

The Pandoc source code and all documentation may be downloaded from
<http://johnmacfarlane.net/pandoc/>.

맨 페이지 실행으로 변환하려면 :

pandoc -s -t man pandoc.1.md -o example10.1

시각화 된 변환 결과 (생성 된 매뉴얼 페이지의 조각) :

판독 예제

가장 많이 사용 되는 Linux 배포판의 저장소에서 Pandoc설치할 수 있습니다 .

더 많은 링크 :


4

나는 사용자 정의 매뉴얼 페이지만드는 데 빠르고 쉬운이 튜토리얼을 사용하고 있습니다 .

일반적인 과정은 다음과 같습니다.

  1. 마크 업이있는 텍스트 파일 만들기
  2. sed스크립트를 통해 형식을 지정하십시오.nroff
  3. 통과시켜 nroff

그런 다음 선택적으로 (b | g) zip으로 압축하여 적절한 man 디렉토리에 넣을 수 있습니다.


3

이 페이지 에 따르면 쉽습니다.

nano nuseradd

그런 다음 이와 같은 예제를 붙여넣고 수정하십시오. 이 페이지 (또는 man 7 mdoc)는 형식 지정 옵션을 설명합니다.

.\" Manpage for nuseradd.
.\" Contact vivek@nixcraft.net.in to correct errors or typos.
.TH man 8 "06 May 2010" "1.0" "nuseradd man page"
.SH NAME
nuseradd \- create a new LDAP user
.SH SYNOPSIS
nuseradd [USERNAME]
.SH DESCRIPTION
nuseradd is high level shell program for adding users to LDAP server.  On Debian, administrators should usually use nuseradd.debian(8) instead.
.SH OPTIONS
The nuseradd does not take any options. However, you can supply username.
.SH SEE ALSO
useradd(8), passwd(5), nuseradd.debian(8)
.SH BUGS
No known bugs.
.SH AUTHOR
Vivek Gite (vivek@nixcraft.net.in)

그런 다음 gzip을 사용하여 새 매뉴얼 페이지를 적절한 매뉴얼 섹션에 복사하십시오.

1   Executable shell commands
2   System calls (functions provided by the kernel)
3   Library calls (functions within program libraries)
4   Special files (usually found in /dev)
5   File formats and conventions eg /etc/passwd
6   Games
7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8   System administration commands (usually only for root)
9   Kernel routines [Non standard]

예는 관리 도구이므로 8 절로 이동합니다.

cat nuseradd |gzip > /usr/local/man/man8/nuseradd.1

또는 사람들 이 다른 위치 (예 : 로컬) 에서 읽도록하십시오 .man ./nuseradd


cat 명령을 실행하려면 먼저 다음을 입력하여 수퍼 유저 sudo su
여야합니다.

0

"md2man.sh"라는 파일 또는 원하는 이름으로 선택하십시오.

#!/bin/bash

pandoc -s -t man $1 | groff -Kutf8 -Tutf8 -man > $1".1"

용법: md2man.sh myManPage.md

참고 사항 : 모든 groff -T, 출력 장치 지원 utf8은 아닙니다 . Utf8은 groff에서 작동하지만 모든 드라이버에서 지원되는 것은 아닙니다. 예를 들어 pdfpsUTF8 입력 작동하지 않습니다. -Kutf8groff 를 사용 하면 utf8 입력이 필요합니다. htmluft8과 같은 텍스트 출력과 같은 다른 드라이버 -Tutf8는 utf8 문자로 출력합니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.