summaryrefslogtreecommitdiff
path: root/doc/sphinxext/docscrape.py
diff options
context:
space:
mode:
Diffstat (limited to 'doc/sphinxext/docscrape.py')
-rw-r--r--doc/sphinxext/docscrape.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/doc/sphinxext/docscrape.py b/doc/sphinxext/docscrape.py
index f36f7ceb7..ad5998cc6 100644
--- a/doc/sphinxext/docscrape.py
+++ b/doc/sphinxext/docscrape.py
@@ -411,19 +411,14 @@ class FunctionDoc(NumpyDocString):
def __init__(self, func, role='func', doc=None, config={}):
self._f = func
self._role = role # e.g. "func" or "meth"
+
if doc is None:
+ if func is None:
+ raise ValueError("No function or docstring given")
doc = inspect.getdoc(func) or ''
- try:
- NumpyDocString.__init__(self, doc)
- except ValueError, e:
- print '*'*78
- print "ERROR: '%s' while parsing `%s`" % (e, self._f)
- print '*'*78
- #print "Docstring follows:"
- #print doclines
- #print '='*78
-
- if not self['Signature']:
+ NumpyDocString.__init__(self, doc)
+
+ if not self['Signature'] and func is not None:
func, func_name = self.get_func()
try:
# try to read signature
@@ -465,17 +460,17 @@ class FunctionDoc(NumpyDocString):
class ClassDoc(NumpyDocString):
def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc,
config={}):
- if not inspect.isclass(cls):
- raise ValueError("Initialise using a class. Got %r" % cls)
+ if not inspect.isclass(cls) and cls is not None:
+ raise ValueError("Expected a class or None, but got %r" % cls)
self._cls = cls
if modulename and not modulename.endswith('.'):
modulename += '.'
self._mod = modulename
- self._name = cls.__name__
- self._func_doc = func_doc
if doc is None:
+ if cls is None:
+ raise ValueError("No class or documentation string given")
doc = pydoc.getdoc(cls)
NumpyDocString.__init__(self, doc)
@@ -490,10 +485,14 @@ class ClassDoc(NumpyDocString):
@property
def methods(self):
+ if self._cls is None:
+ return []
return [name for name,func in inspect.getmembers(self._cls)
if not name.startswith('_') and callable(func)]
@property
def properties(self):
+ if self._cls is None:
+ return []
return [name for name,func in inspect.getmembers(self._cls)
if not name.startswith('_') and func is None]