Generating python CLI man page

前端 未结 3 1184
我寻月下人不归
我寻月下人不归 2020-12-30 07:46

I am developing a python CLI tool (using optparse in python2.6, but hope to switch soon to python2.7) and I am about to write the man page. I have some experience on generat

3条回答
  •  温柔的废话
    2020-12-30 08:14

    While sphinx is a really great documentation system, it's awfully complex and hard to master. If you need a bang solution, I suggest you look in my project build_manpage.py.

    It is not a replacement for properly documenting you projects (with sphinx or what ever way you choose). But it has some immediate benefits for a Python programmer:

    • You don't have to learn the man syntax.
    • You don't have to learn rst syntax (never the less, you should one day learn it ...)
    • You don't need to maintain your optparser\argparser and a man page formated in external file (in man, rst, or any other conversion system).

    • You simply add one file to you build configuration, and a man page is created for you!

    If you do want to use a more complicated system, with a lot of bells and whistles, sphinx allows you convert an rst formated page to man page. And a recently young project, takes a similar approach to my parser and scans your ArgumentParser to produce an rst formatted page,with sphinx directives (such that you don't need to write it yourself. (In contrast my scanner produces a man page directly).

    Note that this is now part of a pull request to add a manpage formatter in the standard library.

提交回复
热议问题