summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-06-27 17:40:32 +0000
committerPauli Virtanen <pav@iki.fi>2009-06-27 17:40:32 +0000
commitaa292318e92eee5f99fa5701e4a84ae7bd0bdc4c (patch)
tree2dc0269396268404ffbbfc9dc8c75a68ba930c0f
parent7a661682c1d8209fe17daba26ed0cddc2cb5edf3 (diff)
downloadnumpy-aa292318e92eee5f99fa5701e4a84ae7bd0bdc4c.tar.gz
docs: fill in stub Methods/Attributes sections if they are omitted
-rw-r--r--doc/sphinxext/docscrape.py24
-rw-r--r--doc/sphinxext/docscrape_sphinx.py4
2 files changed, 12 insertions, 16 deletions
diff --git a/doc/sphinxext/docscrape.py b/doc/sphinxext/docscrape.py
index 3e190b6f2..0e073da93 100644
--- a/doc/sphinxext/docscrape.py
+++ b/doc/sphinxext/docscrape.py
@@ -479,21 +479,19 @@ class ClassDoc(NumpyDocString):
NumpyDocString.__init__(self, doc)
+ if not self['Methods']:
+ self['Methods'] = [(name, '', '') for name in sorted(self.methods)]
+
+ if not self['Attributes']:
+ self['Attributes'] = [(name, '', '')
+ for name in sorted(self.properties)]
+
@property
def methods(self):
return [name for name,func in inspect.getmembers(self._cls)
if not name.startswith('_') and callable(func)]
- def __str__(self):
- out = ''
- out += super(ClassDoc, self).__str__()
- out += "\n\n"
-
- #for m in self.methods:
- # print "Parsing `%s`" % m
- # out += str(self._func_doc(getattr(self._cls,m), 'meth')) + '\n\n'
- # out += '.. index::\n single: %s; %s\n\n' % (self._name, m)
-
- return out
-
-
+ @property
+ def properties(self):
+ return [name for name,func in inspect.getmembers(self._cls)
+ if not name.startswith('_') and func is None]
diff --git a/doc/sphinxext/docscrape_sphinx.py b/doc/sphinxext/docscrape_sphinx.py
index 8b93459d5..12907731e 100644
--- a/doc/sphinxext/docscrape_sphinx.py
+++ b/doc/sphinxext/docscrape_sphinx.py
@@ -70,9 +70,7 @@ class SphinxDocString(NumpyDocString):
others = []
for param, param_type, desc in self[name]:
param = param.strip()
- if not self._obj or \
- (hasattr(self._obj, param) and
- getattr(getattr(self._obj, param), '__doc__', None)):
+ if not self._obj or hasattr(self._obj, param):
autosum += [" %s%s" % (prefix, param)]
else:
others.append((param, param_type, desc))