@@ -329,7 +329,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]:
329
329
return decorate
330
330
331
331
332
- def doc (* supplements : Union [str , Callable ], ** substitutes : str ) -> Callable [[F ], F ]:
332
+ def doc (* docstrings : Union [str , Callable ], ** params : str ) -> Callable [[F ], F ]:
333
333
"""
334
334
A decorator take docstring templates, concatenate them and perform string
335
335
substitution on it.
@@ -342,39 +342,39 @@ def doc(*supplements: Union[str, Callable], **substitutes: str) -> Callable[[F],
342
342
343
343
Parameters
344
344
----------
345
- *supplements : str or callable
345
+ *docstrings : str or callable
346
346
The string / docstring / docstring template to be appended in order
347
347
after default docstring under callable.
348
- **substitutes : str
348
+ **params : str
349
349
The string which would be used to format docstring template.
350
350
"""
351
351
352
- def decorator (call : F ) -> F :
352
+ def decorator (decorated : F ) -> F :
353
353
# collecting docstring and docstring templates
354
354
docstring_components : List [Union [str , Callable ]] = []
355
- if call .__doc__ :
356
- docstring_components .append (dedent (call .__doc__ ))
355
+ if decorated .__doc__ :
356
+ docstring_components .append (dedent (decorated .__doc__ ))
357
357
358
- for supplement in supplements :
359
- if hasattr (supplement , "_docstring_components" ):
358
+ for docstring in docstrings :
359
+ if hasattr (docstring , "_docstring_components" ):
360
360
docstring_components .extend (
361
- supplement ._docstring_components # type: ignore
361
+ docstring ._docstring_components # type: ignore
362
362
)
363
- elif isinstance (supplement , str ) or supplement .__doc__ :
364
- docstring_components .append (supplement )
363
+ elif isinstance (docstring , str ) or docstring .__doc__ :
364
+ docstring_components .append (docstring )
365
365
366
366
# formatting templates and concatenating docstring
367
- call .__doc__ = "" .join (
367
+ decorated .__doc__ = "" .join (
368
368
[
369
- component .format (** substitutes )
369
+ component .format (** params )
370
370
if isinstance (component , str )
371
371
else dedent (component .__doc__ or "" )
372
372
for component in docstring_components
373
373
]
374
374
)
375
375
376
- call ._docstring_components = docstring_components # type: ignore
377
- return call
376
+ decorated ._docstring_components = docstring_components # type: ignore
377
+ return decorated
378
378
379
379
return decorator
380
380
0 commit comments