File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 66"""
77
88import functools
9+ import string
910import textwrap
1011import warnings
1112from inspect import Parameter , signature
@@ -442,21 +443,14 @@ def fmt_docstring(module_func):
442443 <BLANKLINE>
443444 """ # noqa: D410,D411
444445
445- class _Placeholder ( dict ):
446+ class _MyTemplate ( string . Template ):
446447 """
447- A dict subclass that allows missing placeholders in docstrings.
448-
449- Related to https://github.com/GenericMappingTools/pygmt/issues/3815.
448+ A Template subclass that allows missing placeholders in docstrings.
450449 """
451450
452- def __missing__ (self , key ):
453- """
454- Return "{key}" for a missing key.
455- """
456- return "{" + key + "}"
457-
458- filler_text = _Placeholder ()
451+ delimiter = "" # Default delimiter is $.
459452
453+ filler_text = {}
460454 if hasattr (module_func , "aliases" ):
461455 aliases = ["**Aliases:**\n " ]
462456 aliases .append (".. hlist::" )
@@ -481,7 +475,7 @@ def __missing__(self, key):
481475 # Dedent the docstring to make it all match the option text.
482476 docstring = textwrap .dedent (module_func .__doc__ )
483477
484- module_func .__doc__ = docstring . format_map ( filler_text )
478+ module_func .__doc__ = _MyTemplate ( docstring ). safe_substitute ( ** filler_text )
485479 return module_func
486480
487481
You can’t perform that action at this time.
0 commit comments