@@ -1733,47 +1733,33 @@ def draw_bbox(bbox, renderer, color='k', trans=None):
1733
1733
r .draw (renderer )
1734
1734
1735
1735
1736
- def _pprint_table ( table , leadingspace = 2 ):
1736
+ def _pprint_styles ( _styles ):
1737
1737
"""
1738
- Given the list of list of strings, return a string of REST table format.
1738
+ A helper function for the _Style class. Given the dictionary of
1739
+ {stylename: styleclass}, return a formatted string listing all the
1740
+ styles. Used to update the documentation.
1739
1741
"""
1742
+ table = [('Class' , 'Name' , 'Attrs' ),
1743
+ * [(cls .__name__ ,
1744
+ # adding backquotes since - and | have special meaning in reST
1745
+ f'``{ name } ``' ,
1746
+ # [1:-1] drops the surrounding parentheses.
1747
+ str (inspect .signature (cls ))[1 :- 1 ] or 'None' )
1748
+ for name , cls in sorted (_styles .items ())]]
1749
+ # Convert to rst table.
1740
1750
col_len = [max (len (cell ) for cell in column ) for column in zip (* table )]
1741
- table_formatstr = ' ' .join ('=' * cl for cl in col_len )
1742
- lines = [
1751
+ table_formatstr = ' ' .join ('=' * cl for cl in col_len )
1752
+ rst_table = ' \n ' . join ( [
1743
1753
'' ,
1744
1754
table_formatstr ,
1745
- ' ' .join (cell .ljust (cl ) for cell , cl in zip (table [0 ], col_len )),
1755
+ ' ' .join (cell .ljust (cl ) for cell , cl in zip (table [0 ], col_len )),
1746
1756
table_formatstr ,
1747
- * [' ' .join (cell .ljust (cl ) for cell , cl in zip (row , col_len ))
1757
+ * [' ' .join (cell .ljust (cl ) for cell , cl in zip (row , col_len ))
1748
1758
for row in table [1 :]],
1749
1759
table_formatstr ,
1750
1760
'' ,
1751
- ]
1752
- return textwrap .indent ('\n ' .join (lines ), ' ' * leadingspace )
1753
-
1754
-
1755
- def _pprint_styles (_styles ):
1756
- """
1757
- A helper function for the _Style class. Given the dictionary of
1758
- {stylename: styleclass}, return a formatted string listing all the
1759
- styles. Used to update the documentation.
1760
- """
1761
- import inspect
1762
-
1763
- _table = [["Class" , "Name" , "Attrs" ]]
1764
-
1765
- for name , cls in sorted (_styles .items ()):
1766
- spec = inspect .getfullargspec (cls .__init__ )
1767
- if spec .defaults :
1768
- argstr = ", " .join (map (
1769
- "{}={}" .format , spec .args [- len (spec .defaults ):], spec .defaults
1770
- ))
1771
- else :
1772
- argstr = 'None'
1773
- # adding ``quotes`` since - and | have special meaning in reST
1774
- _table .append ([cls .__name__ , "``%s``" % name , argstr ])
1775
-
1776
- return _pprint_table (_table )
1761
+ ])
1762
+ return textwrap .indent (rst_table , prefix = ' ' * 2 )
1777
1763
1778
1764
1779
1765
def _simpleprint_styles (_styles ):
0 commit comments