merge with bb://mbrochh/sphinx

This commit is contained in:
Georg Brandl 2011-01-04 22:22:23 +01:00
commit dd6984b7a9
2 changed files with 13 additions and 6 deletions

View File

@ -28,3 +28,5 @@ should check:
.. confval:: coverage_c_regexes .. confval:: coverage_c_regexes
.. confval:: coverage_ignore_c_items .. confval:: coverage_ignore_c_items
.. confval:: coverage_write_headline

View File

@ -166,7 +166,7 @@ class CoverageBuilder(Builder):
if exp.match(name): if exp.match(name):
break break
else: else:
if full_name not in objects: if full_name not in objects and not obj.__doc__:
# not documented at all # not documented at all
classes[name] = [] classes[name] = []
continue continue
@ -174,16 +174,20 @@ class CoverageBuilder(Builder):
attrs = [] attrs = []
for attr_name in dir(obj): for attr_name in dir(obj):
if attr_name not in obj.__dict__:
continue
attr = getattr(obj, attr_name) attr = getattr(obj, attr_name)
for attr_name, attr in inspect.getmembers( if (not inspect.ismethod(attr)
obj, lambda x: inspect.ismethod(x) or \ and not inspect.isfunction(attr)):
inspect.isfunction(x)): continue
if attr_name[0] == '_': if attr_name[0] == '_':
# starts with an underscore, ignore it # starts with an underscore, ignore it
continue continue
full_attr_name = '%s.%s' % (full_name, attr_name) full_attr_name = '%s.%s' % (full_name, attr_name)
if full_attr_name not in objects: if full_attr_name not in objects:
if len(obj.__doc__) > 0:
continue
attrs.append(attr_name) attrs.append(attr_name)
if attrs: if attrs:
@ -197,8 +201,8 @@ class CoverageBuilder(Builder):
op = open(output_file, 'w') op = open(output_file, 'w')
failed = [] failed = []
try: try:
write_header(op, 'Undocumented Python objects', '=') if self.config.coverage_write_headline:
write_header(op, 'Undocumented Python objects', '=')
keys = self.py_undoc.keys() keys = self.py_undoc.keys()
keys.sort() keys.sort()
for name in keys: for name in keys:
@ -248,3 +252,4 @@ def setup(app):
app.add_config_value('coverage_c_path', [], False) app.add_config_value('coverage_c_path', [], False)
app.add_config_value('coverage_c_regexes', {}, False) app.add_config_value('coverage_c_regexes', {}, False)
app.add_config_value('coverage_ignore_c_items', {}, False) app.add_config_value('coverage_ignore_c_items', {}, False)
app.add_config_value('coverage_write_headline', {}, False)