File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -604,16 +604,22 @@ def register(multimethod):
604604
605605 # Update entry point docstring to include docs for the new multimethod,
606606 # and its call signature.
607- our_doc = _format_method ((multimethod , type_signature ))
607+ call_signature_desc = _format_method ((multimethod , type_signature ))
608+ our_doc = call_signature_desc
608609 if multimethod .__doc__ :
609610 our_doc += "\n " + multimethod .__doc__
610- if dispatcher .__doc__ :
611+
612+ isfirstmultimethod = len (dispatcher ._method_registry ) == 1
613+ if isfirstmultimethod or not dispatcher .__doc__ :
614+ # Override the original doc of the function that was converted
615+ # into the dispatcher; this adds the call signature to the top.
616+ dispatcher .__doc__ = our_doc
617+ else :
618+ # Add the call signature and doc for the new multimethod.
611619 dispatcher .__doc__ += "\n \n " + ("-" * 80 ) + "\n "
612620 dispatcher .__doc__ += our_doc
613- else :
614- dispatcher .__doc__ = our_doc
615621
616- return dispatcher # Replace the callable with this generic function's dispatcher.
622+ return dispatcher # Replace the multimethod callable with this generic function's dispatcher.
617623
618624 dispatcher ._register = register
619625 _dispatcher_registry [fullname ] = dispatcher
You can’t perform that action at this time.
0 commit comments