##// END OF EJS Templates
detect builtin docstrings in oinspect...
MinRK -
Show More
@@ -42,6 +42,12 b' from IPython.utils.wildcard import list_namespace'
42 42 from IPython.utils.coloransi import *
43 43 from IPython.utils.py3compat import cast_unicode, string_types
44 44
45 # builtin docstrings to ignore
46 _func_call_docstring = types.FunctionType.__call__.__doc__
47 _object_init_docstring = object.__init__.__doc__
48 _builtin_type_docstrings = {
49 t.__doc__ for t in (types.ModuleType, types.MethodType, types.FunctionType)
50 }
45 51 #****************************************************************************
46 52 # Builtin color schemes
47 53
@@ -732,8 +738,8 b' class Inspector:'
732 738 init_def = self._getdef(obj_init,oname)
733 739 init_ds = getdoc(obj_init)
734 740 # Skip Python's auto-generated docstrings
735 if init_ds and \
736 init_ds.startswith('x.__init__(...) initializes'):
741 print(init_ds)
742 if init_ds == _object_init_docstring:
737 743 init_ds = None
738 744
739 745 if init_def or init_ds:
@@ -756,10 +762,7 b' class Inspector:'
756 762 else:
757 763 class_ds = getdoc(cls)
758 764 # Skip Python's auto-generated docstrings
759 if class_ds and \
760 (class_ds.startswith('function(code, globals[,') or \
761 class_ds.startswith('instancemethod(function, instance,') or \
762 class_ds.startswith('module(name[,') ):
765 if class_ds in _builtin_type_docstrings:
763 766 class_ds = None
764 767 if class_ds and ds != class_ds:
765 768 out['class_docstring'] = class_ds
@@ -768,8 +771,7 b' class Inspector:'
768 771 try:
769 772 init_ds = getdoc(obj.__init__)
770 773 # Skip Python's auto-generated docstrings
771 if init_ds and \
772 init_ds.startswith('x.__init__(...) initializes'):
774 if init_ds == _object_init_docstring:
773 775 init_ds = None
774 776 except AttributeError:
775 777 init_ds = None
@@ -783,7 +785,7 b' class Inspector:'
783 785 out['call_def'] = self.format(call_def)
784 786 call_ds = getdoc(obj.__call__)
785 787 # Skip Python's auto-generated docstrings
786 if call_ds and call_ds.startswith('x.__call__(...) <==> x(...)'):
788 if call_ds == _func_call_docstring:
787 789 call_ds = None
788 790 if call_ds:
789 791 out['call_docstring'] = call_ds
General Comments 0
You need to be logged in to leave comments. Login now