7171from sphinx .ext .autodoc ._member_finder import _best_object_type_for_member
7272from sphinx .ext .autodoc ._sentinels import INSTANCE_ATTR
7373from sphinx .ext .autodoc .directive import DocumenterBridge
74- from sphinx .ext .autodoc .importer import _format_signatures , import_module
74+ from sphinx .ext .autodoc .importer import import_module
7575from sphinx .ext .autodoc .mock import mock
7676from sphinx .locale import __
7777from sphinx .pycode import ModuleAnalyzer
@@ -361,7 +361,7 @@ def get_items(self, names: list[str]) -> list[tuple[str, str | None, str, str]]:
361361 )
362362 continue
363363
364- self . bridge . result = StringList () # initialize for each documenter
364+ result = StringList () # initialize for each documenter
365365 obj_type = _get_documenter (obj , parent )
366366 doccls = self .env ._registry .documenters [obj_type ]
367367 full_name = real_name
@@ -371,6 +371,7 @@ def get_items(self, names: list[str]) -> list[tuple[str, str | None, str, str]]:
371371 full_name = modname + '::' + full_name [len (modname ) + 1 :]
372372 # NB. using full_name here is important, since Documenters
373373 # handle module prefixes slightly differently
374+ self .bridge .result = result
374375 documenter = doccls (self .bridge , full_name )
375376 if documenter ._load_object_by_name () is None :
376377 logger .warning (
@@ -380,57 +381,38 @@ def get_items(self, names: list[str]) -> list[tuple[str, str | None, str, str]]:
380381 )
381382 items .append ((display_name , '' , '' , real_name ))
382383 continue
384+ props = documenter .props
383385
384386 # try to also get a source code analyzer for attribute docs
385- real_module = (
386- documenter .props ._obj___module__ or documenter .props .module_name
387- )
387+ real_module = props ._obj___module__ or props .module_name
388388 try :
389- documenter . analyzer = ModuleAnalyzer .for_module (real_module )
389+ analyzer = ModuleAnalyzer .for_module (real_module )
390390 # parse right now, to get PycodeErrors on parsing (results will
391391 # be cached anyway)
392- documenter . analyzer .find_attr_docs ()
392+ analyzer .analyze ()
393393 except PycodeError as err :
394394 logger .debug ('[autodoc] module analyzer failed: %s' , err )
395395 # no source file -- e.g. for builtin and C modules
396- documenter .analyzer = None
396+ analyzer = None
397+ documenter .analyzer = analyzer
397398
398399 # -- Grab the signature
399400
400401 if signatures_option == 'none' :
401402 sig = None
402- else :
403- try :
404- signatures = tuple (
405- f'{ args } -> { retann } ' if retann else str (args )
406- for args , retann in _format_signatures (
407- config = self .env .config ,
408- events = self .env .events ,
409- get_attr = documenter .get_attr ,
410- options = _AutoDocumenterOptions (),
411- parent = documenter .parent ,
412- props = documenter .props ,
413- show_annotation = False ,
414- )
415- )
416- except TypeError :
417- # the documenter does not support ``show_annotation`` option
418- signatures = documenter .props .signatures
419- sig = '\n ' .join (signatures )
420- if not sig :
421- sig = ''
422- elif signatures_option == 'short' :
423- if sig != '()' :
424- sig = '(…)'
425- else : # signatures_option == 'long'
426- max_chars = max (10 , max_item_chars - len (display_name ))
427- sig = mangle_signature (sig , max_chars = max_chars )
403+ elif not props .signatures :
404+ sig = ''
405+ elif signatures_option == 'short' :
406+ sig = '()' if props .signatures == ('()' ,) else '(…)'
407+ else : # signatures_option == 'long'
408+ max_chars = max (10 , max_item_chars - len (display_name ))
409+ sig = mangle_signature ('\n ' .join (props .signatures ), max_chars = max_chars )
428410
429411 # -- Grab the summary
430412
431413 documenter .add_content (None , indent = documenter .indent )
432- lines = self . bridge . result .data [:]
433- if documenter . props .obj_type != 'module' :
414+ lines = result .data [:]
415+ if props .obj_type != 'module' :
434416 lines [:] = [line .removeprefix (' ' ) for line in lines ]
435417 summary = extract_summary (lines , self .state .document )
436418
0 commit comments