本文介绍了将Sphinx autodoc-skip-member连接到我的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用,我怀疑它会进入我的conf.py,但是当我尝试在conf.py中对此代码进行变体时,我找不到应该connect()的应用程序对象:

But it isn't clear from the sphinx docs, and I can't find any examples that illustrate: where do I put the code to connect this? I see Sphinx.connect and I suspect it goes in my conf.py, but when I try variations on this code in conf.py I can't find the app object that I should connect():

def maybe_skip_member(app, what, name, obj, skip,
                                  options):
    print app, what, name, obj, skip, options
    return False

# This is not even close to correct:
#from sphinx.application import Sphinx
#Sphinx().connect('autodoc-skip-member', maybe_skip_member)

一个简单示例的指针将是理想的。

A pointer to a simple example would be ideal.

推荐答案

啊哈,最后一次在小范围搜索上的努力出现了,向下滚动到底部。显然,conf.py中的setup()函数将被该应用调用。我可以在conf.py的底部定义以下内容:

Aha, last ditch effort on a little googling turned up this example, scroll down to the bottom. Apparently a setup() function in conf.py will get called with the app. I was able to define the following at the bottom of my conf.py:

def maybe_skip_member(app, what, name, obj, skip, options):
    print app, what, name, obj, skip, options
    return True

def setup(app):
    app.connect('autodoc-skip-member', maybe_skip_member)

显然没有用(跳过所有内容),但是那是我一直在寻找但找不到的最小例子...

Which is obviously useless (it skips everything), but that's the minimal example I was looking for and couldn't find...

这篇关于将Sphinx autodoc-skip-member连接到我的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 05:27