开发者

Best way to document a Python module which is generated by the C API?

I have embedded and extended python inside my C application and I now want to document this. I have defined a module using the C API, therefore pydoc tool will not see it (right?).

Thus far the b开发者_如何学JAVAest way I can think is to use the 'pydoc' module on my module at runtime (therefore the extension module I defined will be present). This should allow me to spit out HTML and text versions of docs for my API.

Something like (off the top of my head):

import pydoc
import sys

d = pydoc.HTMLDoc()
print(d.page("my api", d.docmodule(sys.modules["mymodule"])))

Is there a better way?


I'm not sure exactly how you've use the C-API (since you've just said that you've embedded and extended Python in your C application).

However, pydoc imports a module and uses introspection to generate documentation for the module so if you run it on your compiled module, it will still work. The point is that it doesn't look at the source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜