@@ -1240,6 +1240,17 @@ def indent(self, text, prefix=' '):
12401240 lines = [(prefix + line ).rstrip () for line in text .split ('\n ' )]
12411241 return '\n ' .join (lines )
12421242
1243+ def _format_doc (self , text , width = 68 ):
1244+ """Wraps the single-line summary if it is too long."""
1245+ if not text : return ''
1246+ lines = text .split ('\n ' , 2 )
1247+ if len (lines ) > 1 and lines [1 ]:
1248+ return text
1249+ lines [:1 ] = textwrap .wrap (lines [0 ], width ,
1250+ break_long_words = False ,
1251+ break_on_hyphens = False )
1252+ return '\n ' .join (lines )
1253+
12431254 def section (self , title , contents ):
12441255 """Format a section with a given heading."""
12451256 clean_contents = self .indent (contents ).rstrip ()
@@ -1390,6 +1401,7 @@ def makename(c, m=object.__module__):
13901401
13911402 doc = getdoc (object )
13921403 if doc :
1404+ doc = self ._format_doc (doc )
13931405 push (doc + '\n ' )
13941406
13951407 # List the mro, if non-trivial.
@@ -1590,6 +1602,7 @@ def docroutine(self, object, name=None, mod=None, cl=None, homecls=None):
15901602 return decl + '\n '
15911603 else :
15921604 doc = getdoc (object ) or ''
1605+ doc = self ._format_doc (doc )
15931606 return decl + '\n ' + (doc and self .indent (doc ).rstrip () + '\n ' )
15941607
15951608 def docdata (self , object , name = None , mod = None , cl = None , * ignored ):
@@ -1602,6 +1615,7 @@ def docdata(self, object, name=None, mod=None, cl=None, *ignored):
16021615 push ('\n ' )
16031616 doc = getdoc (object ) or ''
16041617 if doc :
1618+ doc = self ._format_doc (doc )
16051619 push (self .indent (doc ))
16061620 push ('\n ' )
16071621 return '' .join (results )
@@ -1620,7 +1634,8 @@ def docother(self, object, name=None, mod=None, parent=None, *ignored,
16201634 if not doc :
16211635 doc = getdoc (object )
16221636 if doc :
1623- line += '\n ' + self .indent (str (doc )) + '\n '
1637+ doc = self ._format_doc (str (doc ))
1638+ line += '\n ' + self .indent (doc ) + '\n '
16241639 return line
16251640
16261641class _PlainTextDoc (TextDoc ):
0 commit comments