@@ -342,10 +342,11 @@ def _transition_to_rng(old_name, *, position_num=None, end_version=None,
342
342
Whether the decorator should replace the documentation for parameter `rng` with
343
343
`_rng_desc` (defined above), which documents both new `rng` keyword behavior
344
344
and typical legacy `random_state`/`seed` behavior. If True, manually replace
345
- the function's old `random_state`/`seed` documentation with the desired *final*
346
- `rng` documentation; this way, no changes to documentation are needed when the
347
- decorator is removed. Use False if the function's old `random_state`/`seed`
348
- behavior does not match that described by `_rng_desc`.
345
+ the first paragraph of the function's old `random_state`/`seed` documentation
346
+ with the desired *final* `rng` documentation; this way, no changes to
347
+ documentation are needed when the decorator is removed. Documentation of `rng`
348
+ after the first blank line is preserved. Use False if the function's old
349
+ `random_state`/`seed` behavior does not match that described by `_rng_desc`.
349
350
350
351
"""
351
352
NEW_NAME = "rng"
@@ -446,10 +447,13 @@ def wrapper(*args, **kwargs):
446
447
if 'rng' in parameter_names :
447
448
_type = "{None, int, `numpy.random.Generator`}, optional"
448
449
_desc = _rng_desc .replace ("{old_name}" , old_name )
449
- _rng_parameter_doc = Parameter ('rng' , _type , [_desc ])
450
+ old_doc = doc ['Parameters' ][parameter_names .index ('rng' )].desc
451
+ old_doc_keep = old_doc [old_doc .index ("" ) + 1 :] if "" in old_doc else []
452
+ new_doc = [_desc ] + old_doc_keep
453
+ _rng_parameter_doc = Parameter ('rng' , _type , new_doc )
450
454
doc ['Parameters' ][parameter_names .index ('rng' )] = _rng_parameter_doc
451
- doc = str (doc ).split ("\n " , 1 )[1 ] # remove signature
452
- wrapper .__doc__ = str (doc )
455
+ doc = str (doc ).split ("\n " , 1 )[1 ] # remove signature
456
+ wrapper .__doc__ = str (doc )
453
457
return wrapper
454
458
455
459
return decorator
0 commit comments