Skip to content

Commit 4ffd3db

Browse files
committed
Support passing kwargs to _SnippetManager
1 parent 94904d5 commit 4ffd3db

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

proplot/internals/docstring.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,27 @@ def _concatenate_inherited(func, prepend_summary=False):
109109

110110
class _SnippetManager(dict):
111111
"""
112-
A simple database for documentation snippets.
112+
A simple database for handling documentation snippets.
113113
"""
114-
def __call__(self, obj):
114+
def __call__(self, obj, **kwargs):
115115
"""
116-
Add snippets to the string or object using ``%(name)s`` substitution.
117-
This lets snippet keys have invalid variable names.
116+
Add snippets to the string or object using ``%(name)s`` substitution. Use
117+
`kwargs` to format the snippets themselves with ``%(name)s`` substitution.
118118
"""
119119
if isinstance(obj, str):
120120
obj %= self # add snippets to a string
121+
obj %= kwargs
121122
else:
122123
obj.__doc__ = inspect.getdoc(obj) # also dedents the docstring
123124
if obj.__doc__:
124125
obj.__doc__ %= self # insert snippets after dedent
126+
obj.__doc__ %= kwargs
125127
return obj
126128

127129
def __setitem__(self, key, value):
128130
"""
129-
Populate input strings with other snippets. Developers should take
130-
care to import modules in the correct order.
131+
Populate input strings with other snippets and strip newlines. Developers
132+
should take care to import modules in the correct order.
131133
"""
132134
value = self(value)
133135
value = value.strip('\n')

0 commit comments

Comments
 (0)