From be5f12ca5624130e6a61297d4c944cc65f757f52 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 7 Jan 2011 15:59:37 -0500 Subject: preserve method signatures of @action_method-decorated methods in sphinx docs --- docs/conf.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs') diff --git a/docs/conf.py b/docs/conf.py index d69936cf8..2f4c5227a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,6 +13,7 @@ import sys, os import datetime +import inspect import warnings warnings.simplefilter('ignore', DeprecationWarning) @@ -407,6 +408,18 @@ def setup(app): app.add_directive('frontmatter', frontmatter, 1, (0, 0, 0)) app.add_directive('mainmatter', mainmatter, 1, (0, 0, 0)) app.add_directive('backmatter', backmatter, 1, (0, 0, 0)) + app.connect('autodoc-process-signature', resig) + +def resig(app, what, name, obj, options, signature, return_annotation): + """ Allow for preservation of ``@action_method`` decorated methods + in configurator """ + docobj = getattr(obj, '__docobj__', None) + if docobj is not None: + argspec = inspect.getargspec(docobj) + if argspec[0] and argspec[0][0] in ('cls', 'self'): + del argspec[0][0] + signature = inspect.formatargspec(*argspec) + return signature, return_annotation # turn off all line numbers in latex formatting -- cgit v1.2.3