File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -441,7 +441,21 @@ def fmt_docstring(module_func):
441441 - R = region
442442 <BLANKLINE>
443443 """ # noqa: D410,D411
444- filler_text = {}
444+
445+ class _Placeholder (dict ):
446+ """
447+ A dict subclass that allows missing placeholders in docstrings.
448+
449+ Related to https://github.com/GenericMappingTools/pygmt/issues/3815.
450+ """
451+
452+ def __missing__ (self , key ):
453+ """
454+ Return "{key}" for a missing key.
455+ """
456+ return "{" + key + "}"
457+
458+ filler_text = _Placeholder ()
445459
446460 if hasattr (module_func , "aliases" ):
447461 aliases = ["**Aliases:**\n " ]
@@ -467,8 +481,7 @@ def fmt_docstring(module_func):
467481 # Dedent the docstring to make it all match the option text.
468482 docstring = textwrap .dedent (module_func .__doc__ )
469483
470- module_func .__doc__ = docstring .format (** filler_text )
471-
484+ module_func .__doc__ = docstring .format_map (filler_text )
472485 return module_func
473486
474487
You can’t perform that action at this time.
0 commit comments