From d46fa57c68b1f6ff4e9f2da6bf9c1e60045c89cf Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Fri, 6 Feb 2009 00:27:08 +0000 Subject: doc/numpydoc: work better together with Sphinx's config option --- doc/sphinxext/docscrape.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'doc/sphinxext/docscrape.py') diff --git a/doc/sphinxext/docscrape.py b/doc/sphinxext/docscrape.py index 904270a52..f374b3ddc 100644 --- a/doc/sphinxext/docscrape.py +++ b/doc/sphinxext/docscrape.py @@ -406,11 +406,13 @@ def header(text, style='-'): class FunctionDoc(NumpyDocString): - def __init__(self, func, role='func'): + def __init__(self, func, role='func', doc=None): self._f = func self._role = role # e.g. "func" or "meth" + if doc is None: + doc = inspect.getdoc(func) or '' try: - NumpyDocString.__init__(self,inspect.getdoc(func) or '') + NumpyDocString.__init__(self, doc) except ValueError, e: print '*'*78 print "ERROR: '%s' while parsing `%s`" % (e, self._f) @@ -459,7 +461,7 @@ class FunctionDoc(NumpyDocString): class ClassDoc(NumpyDocString): - def __init__(self,cls,modulename='',func_doc=FunctionDoc): + def __init__(self,cls,modulename='',func_doc=FunctionDoc,doc=None): if not inspect.isclass(cls): raise ValueError("Initialise using a class. Got %r" % cls) self._cls = cls @@ -470,7 +472,10 @@ class ClassDoc(NumpyDocString): self._name = cls.__name__ self._func_doc = func_doc - NumpyDocString.__init__(self, pydoc.getdoc(cls)) + if doc is None: + doc = pydoc.getdoc(cls) + + NumpyDocString.__init__(self, doc) @property def methods(self): -- cgit v1.2.1