如何使用Sphinx在特定部分记录成员? [英] How do I document members in specific sections using Sphinx?

查看:174
本文介绍了如何使用Sphinx在特定部分记录成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力找出如何在我的Sphinx文档的特定部分放置我的Python类的特定成员的文档,理想情况下,在其他部分自动记录其余部分。



我有一个Python类

  class MyClass(object):

def funky(self,arg):
一些文件。
...

my / module.py 中定义,可以按预期工作,我可以使用



pre> ***************************
MyModule - :mod:`my。 module`
************************* $

.. automodule :: my.module

.. autoclass :: MyClass
:member:
:undoc-members:
:show-inheritance:
/ pre>

但是,当我尝试更多地控制我的文档的组织,我无法使事情工作。具体来说,我想让一些成员记录在明确的部分(只有一个在这里显示,但会有几个),其余的自动记录为一个组。



但是,当我尝试这个例子

  ************** ************* 
MyModule - :mod:`my.module`
******************* ********

要记录
===========

尚未记录的内容。

.. automodule :: my.module

.. autoclass :: MyClass
:成员:
:undoc-members:
:show-inheritance:
:exclude-members:funky

时髦的东西
------------

一些时髦的东西

.. automethod :: funky

我得到


警告:不知道要导入哪个模块以自动记录u'funky(尝试在文档中放置module或currentmodule指令,或给出明确的模块名称)


但没有

  .. currentmodule :: my.module 
.. class :: MyClass

.. automethod :: funky

  .. currentmodule :: my。模块

.. automethod :: funky

等。让我在任何地方。



如何在我的Sphinx文档的特定位置自动记录我的类的某些成员?

解决方案

这样做:

  .. currentmodule :: my.module 

.. automethod :: MyClass.funky

您可以跳过 .. currentmodule :: ,这样做:

  .. automethod :: my .module.MyClass.funky 

第三个选项:

  .. currentmodule :: my.module 

.. autoclass :: MyClass

.. automethod :: funky


I'm struggling to figure out how to place the documentation for specific members of my Python class in specific sections of my Sphinx documentation, ideally while auto-documenting the rest in another section.

I have a Python class

class MyClass(object):

    def funky(self, arg):
        """Some docs."""
        ...

defined in my/module.py which works as expected and I can document without issues using

***************************
MyModule - :mod:`my.module`
***************************

.. automodule:: my.module

.. autoclass:: MyClass
   :members:
   :undoc-members:
   :show-inheritance:

But when I try to get more control over the organization of my documentation I can't get things working. Specifically, I'd like to have some members documented in explicit sections (just one is shown here, but there would be several), with the rest auto-documented as a group.

But when I try this with, for example

***************************
MyModule - :mod:`my.module`
***************************

To document
===========

Things that are not yet documented.

.. automodule:: my.module

.. autoclass:: MyClass
   :members:
   :undoc-members:
   :show-inheritance:
   :exclude-members: funky

Funky things
------------

Some funky things.

.. automethod:: funky

I get

WARNING: don't know which module to import for autodocumenting u'funky' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)

but no variations of

.. currentmodule:: my.module
.. class:: MyClass

.. automethod:: funky

or

.. currentmodule:: my.module

   .. automethod:: funky

etc. get me anywhere.

How do I auto-document some members of my class in specific places in my Sphinx documentation?

解决方案

This works:

.. currentmodule:: my.module

.. automethod:: MyClass.funky

You could skip .. currentmodule:: and do it like this:

.. automethod:: my.module.MyClass.funky

A third option:

.. currentmodule:: my.module

.. autoclass:: MyClass   

   .. automethod:: funky

这篇关于如何使用Sphinx在特定部分记录成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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