我已经安装了Sphinx,以便记录一些我正在处理的python模块和类。虽然标记语言看起来很不错,但我还没有成功地自动记录python代码。
基本上,我有以下python模块:
SegLib.py
其中还有一个名为Seg
的类。我想在生成的sphinx文档中显示类和模块的docstrings,并向其中添加进一步的格式化文本。
我的index.rst
看起来是这样的:
Contents:
.. toctree::
:maxdepth: 2
chapter1.rst
以及chapter1.rst
:
This is a header
================
Some text, *italic text*, **bold text**
* bulleted list. There needs to be a space right after the "*"
* item 2
.. note::
This is a note.
See :class:`Seg`
但是Seg
只是用粗体打印,没有链接到类的自动生成文档。
正在尝试:
参见:类:Seg
模块:mod:'SegLib'
模块:mod:'SegLib.py'
也帮不上忙。 有什么想法或好的指导链接吗?
编辑:将SegLib更改为segments(谢谢,iElectric!),并将第1.rst章更改为:
:mod:segments
模块
--------------------------
.. automodule:: segments.segments
.. autoclass:: segments.segments.Seg
但是,不能让sphinx直接在类中记录函数,或者更好的方法是自动将类中的所有函数添加到文档中。尝试过
.. autofunction:: segments.segments.Seg.sid
得到:
autodoc can't import/find function 'segments.segments.Seg.sid', it reported error: "No module named Seg"
你知道如何用一个简短的命令自动记录函数和类吗?
Udi公司
添加到文件开头:
尝试对类doc使用:autoclass:指令。
顺便说一下:模块名应该是小写。
编辑:I learned a lot from reading other source files。
相关问题 更多 >
编程相关推荐