可以用troff格式制作man页吗?

问题描述 投票:0回答:1

我有一个troff格式的文件,想重新制作成man page。

文件.txt。

.. c:function:: bool is_module_percpu_address (unsigned long addr)

   test whether address is from module static percpu

**Parameters**

``unsigned long addr``
  address to test

**Description**

Test whether **addr** belongs to module static percpu area.

**Return**

``true`` if **addr** is from module static percpu area


.. c:function:: int module_refcount (struct module * mod)

   return the refcount or -1 if unloading

**Parameters**

``struct module * mod``
  the module we're checking

**Return**

     -1 if the module is in the process of unloading
     otherwise the number of references in the kernel to the module

我不太明白groff的输出,当我做的时候 groff file.txt | man -l -.

如你所见,我从来没有做过man page,只是想用troff格式,把它做成一个可读的man page。

如何做到这一点?

PS:输出来自perl脚本 kernel-doc 从提供的源代码树中。我知道它是否是troff格式,但脚本说是这样的(Output troff manual page format)

shell document manpage troff
1个回答
0
投票

如果要求使用troff格式并创建一个可读的man page,不一定要使用groff--我建议使用pandoc。下面的命令比使用groff的输出更可读。

pandoc file.txt -s -t man | man -l -

enter image description here

如果你的文件有像 @meuh 建议的那样,有任何 markdown 或 reStructuredText 的内容,那对 pandoc 来说应该不是问题。


0
投票

我偶然发现了一个叫做 rst2man 在python中编写的,它的转换工作。它是不完美的,但更好的选择,然后 pandoc. 如果有人试图例如阅读内核文档. 你可以用

 kernel-doc path/to/kernel/source.{c,h} | rst2man -q - | man -l -

kernel-doc 是源码树中的Perl脚本

rst2man 是python脚本

© www.soinside.com 2019 - 2024. All rights reserved.