• 9
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Connect Sphinx autodoc-skip-member to my function

I want to use sphinx's autodoc-skip-member event to select a portion of the members on a certain python class for documentation.

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.

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...

  • 43
Reply Report

This answer expands upon the answer by bstpierre. Below is the relevant portion from my conf.py:

autodoc_default_flags = ['members', 'private-members', 'special-members',
                         #'undoc-members',
                         'show-inheritance']

def autodoc_skip_member(app, what, name, obj, skip, options):
    exclusions = ('__weakref__',  # special-members
                  '__doc__', '__module__', '__dict__',  # undoc-members
                  )
    exclude = name in exclusions
    return skip or exclude

def setup(app):
    app.connect('autodoc-skip-member', autodoc_skip_member)
  • 13
Reply Report

Trending Tags