@@ -307,13 +307,15 @@ def create_documenter(self, app: Sphinx, obj: Any,
307307 doccls = get_documenter (app , obj , parent )
308308 return doccls (self .bridge , full_name )
309309
310- def get_items (self , names : list [str ]) -> list [tuple [str , str , str , str ]]:
310+ def get_items (self , names : list [str ]) -> list [tuple [str , str | None , str , str ]]:
311311 """Try to import the given names, and return a list of
312312 ``[(name, signature, summary_string, real_name), ...]``.
313+
314+ signature is already formatted and is None if :nosignatures: option was given.
313315 """
314316 prefixes = get_import_prefixes_from_env (self .env )
315317
316- items : list [tuple [str , str , str , str ]] = []
318+ items : list [tuple [str , str | None , str , str ]] = []
317319
318320 max_item_chars = 50
319321
@@ -365,17 +367,20 @@ def get_items(self, names: list[str]) -> list[tuple[str, str, str, str]]:
365367
366368 # -- Grab the signature
367369
368- try :
369- sig = documenter .format_signature (show_annotation = False )
370- except TypeError :
371- # the documenter does not support ``show_annotation`` option
372- sig = documenter .format_signature ()
373-
374- if not sig :
375- sig = ''
370+ if 'nosignatures' in self .options :
371+ sig = None
376372 else :
377- max_chars = max (10 , max_item_chars - len (display_name ))
378- sig = mangle_signature (sig , max_chars = max_chars )
373+ try :
374+ sig = documenter .format_signature (show_annotation = False )
375+ except TypeError :
376+ # the documenter does not support ``show_annotation`` option
377+ sig = documenter .format_signature ()
378+
379+ if not sig :
380+ sig = ''
381+ else :
382+ max_chars = max (10 , max_item_chars - len (display_name ))
383+ sig = mangle_signature (sig , max_chars = max_chars )
379384
380385 # -- Grab the summary
381386
@@ -389,7 +394,7 @@ def get_items(self, names: list[str]) -> list[tuple[str, str, str, str]]:
389394
390395 return items
391396
392- def get_table (self , items : list [tuple [str , str , str , str ]]) -> list [Node ]:
397+ def get_table (self , items : list [tuple [str , str | None , str , str ]]) -> list [Node ]:
393398 """Generate a proper list of table nodes for autosummary:: directive.
394399
395400 *items* is a list produced by :meth:`get_items`.
@@ -424,10 +429,11 @@ def append_row(*column_texts: str) -> None:
424429
425430 for name , sig , summary , real_name in items :
426431 qualifier = 'obj'
427- if 'nosignatures' not in self .options :
428- col1 = f':py:{ qualifier } :`{ name } <{ real_name } >`\\ { rst .escape (sig )} '
429- else :
432+ if sig is None :
430433 col1 = f':py:{ qualifier } :`{ name } <{ real_name } >`'
434+ else :
435+ col1 = f':py:{ qualifier } :`{ name } <{ real_name } >`\\ { rst .escape (sig )} '
436+
431437 col2 = summary
432438 append_row (col1 , col2 )
433439
0 commit comments