相关疑难解决方法(0)

使用sphinx自动记录python类,模块

我已经安装了Sphinx,以便记录一些我正在研究的python模块和类.虽然标记语言看起来非常好,但我还是没有设法自动记录python代码.

基本上,我有以下python模块:

SegLib.py
Run Code Online (Sandbox Code Playgroud)

还有一个叫它的班级Seg.我想在生成的sphinx文档中显示类和模块的文档字符串,并为其添加更多格式化文本.

index.rst看起来像这样:

Contents:

.. toctree::
:maxdepth: 2

chapter1.rst
Run Code Online (Sandbox Code Playgroud)

并且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`
Run Code Online (Sandbox Code Playgroud)

但是Seg只是以粗体打印,而不是与类的自动生成的文档相关联.

尝试:参见:class:Seg Module:mod:'SegLib'模块:mod:'SegLib.py'

也没有帮助.任何想法或良好的教程链接?

编辑:将SegLib更改为段(感谢,iElectric!),并将chapter1.rst更改为 ::mod:segmentsModule ------------------------- -

.. automodule:: segments.segments

.. autoclass:: segments.segments.Seg
Run Code Online (Sandbox Code Playgroud)

但是,无法让sphinx直接记录类中的函数,或者更好 - 将类中的所有函数自动添加到文档中.试着

.. autofunction:: segments.segments.Seg.sid …
Run Code Online (Sandbox Code Playgroud)

python documentation-generation python-sphinx

21
推荐指数
1
解决办法
2万
查看次数