Python命令行程序:从现有文档生成手册页并包含在发行版中 [英] Python command line program: generate man page from existing documentation and include in the distribution

查看:77
本文介绍了Python命令行程序:从现有文档生成手册页并包含在发行版中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循(希望)的一种常见做法,我有一个Python软件包,该软件包在单独的 scripts 目录中包含多个模块和一个可执行脚本,如此处

Following an (hopefully) common practice, I have a Python package that includes several modules and an executable script in a separate scripts directory, as can be seen here.

该脚本的文档(除optparse提供的自动生成的帮助中的内容,以及Sphinx子目录中的软件包文档。我正在尝试:

The documentation for the script, apart from the auto-generated help given by optparse, is together with the package documentation in a Sphinx subdirectory. I am trying to:


  1. 从现有文档中生成脚本的手册页

  2. 包括发行版中的手册页

我可以轻松地使用Sphinx( man_pages 设置和 sphinx-build -b man 。因此,我可以调用 python setup.py build_sphinx -b man 并在 build / sphinx / man 目录。

I can easily do #1 with Sphinx, the man_pages setting and sphinx-build -b man. So I can call python setup.py build_sphinx -b man and have the man page generated in the build/sphinx/man directory.

现在,我希望能够将生成的手册页包含在发行版tarball中,以便GNU / Linux打包程序可以找到它并将其安装到正确的位置。像 package_data 之类的各种选项在这里似乎不起作用,因为手册页在Sphinx生成之前不存在。这也可能适用于i18n文件( .mo .po 文件)。

Now I would like to be able to have the generated man page included in the distribution tarball, so GNU/Linux packagers can find it and install it to the proper location. Various options like package_data do not seem to work here because the man page is not there until it is generated by Sphinx. This could also apply to i18n files (.mo vs .po files).

MANIFEST.in 中包含不属于源文件的文件似乎不正确。将生成的文件提交到源存储库的可能性看起来很糟糕,我想避免这种情况。

Including files that are not part of the source in MANIFEST.in doesn't seem right. The possibility of commiting the generated files to the source repository looks like an awful thing to do and I would like to avoid it.


成为一种并且最好仅是一种显而易见的方式。

There should be one-- and preferably only one --obvious way to do it.


推荐答案

到在您的发行版中添加静态手册页,则可以将其添加到 MANIFEST 文件中。

To add static man pages in you distribution, you can add them in the MANIFEST file.

recursive-include docs *.txt
recursive-include po *.po
recursive-include sample_data *
recursive-include data *.desktop *.svg *.png
include COPYING.txt
include README.txt
recursive-include man_pages

其中 man_pages 是包含生成的手册页副本的目录。

Where man_pages is the directory containing the copies of generated man pages.

另请参见: http://linuxmanpages.com/man1/man.1.php

这篇关于Python命令行程序:从现有文档生成手册页并包含在发行版中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆