@@ -450,7 +450,9 @@ def fmt_docstring(module_func):
450450 aliases .append (" :columns: 3\n " )
451451 for arg in sorted (module_func .aliases ):
452452 alias = module_func .aliases [arg ]
453- aliases .append (f" - { arg } = { alias } " )
453+ # Trailing dash means it's not aliased but should be listed.
454+ # Remove the trailing dash if it exists.
455+ aliases .append (f" - { arg } = { alias .rstrip ('-' )} " )
454456 filler_text ["aliases" ] = "\n " .join (aliases )
455457
456458 filler_text ["table-classes" ] = (
@@ -484,6 +486,9 @@ def _insert_alias(module_func, default_value=None):
484486 kwargs_param = wrapped_params .pop (- 1 )
485487 # Add new parameters from aliases
486488 for alias in module_func .aliases .values ():
489+ if alias .endswith ("-" ):
490+ # Trailing dash means it's not aliased but should be listed.
491+ continue
487492 if alias not in sig .parameters :
488493 new_param = Parameter (
489494 alias , kind = Parameter .KEYWORD_ONLY , default = default_value
@@ -548,6 +553,31 @@ def new_module(*args, **kwargs):
548553 New module that parses and replaces the registered aliases.
549554 """
550555 for short_param , long_alias in aliases .items ():
556+ if long_alias .endswith ("-" ):
557+ _long_alias = long_alias .rstrip ("-" )
558+ # Trailing dash means it's not aliased but should be listed.
559+ _alias_list = _long_alias .split ("/" )
560+ if (
561+ any (_alias in kwargs for _alias in _alias_list )
562+ and short_param in kwargs
563+ ): # Both long- and short- forms are given.
564+ msg = (
565+ f"Parameters in short-form ({ short_param } ) and "
566+ f"long-form ({ _long_alias } ) can't coexist."
567+ )
568+ raise GMTInvalidInput (msg )
569+ if short_param in kwargs : # Only short-alias is given
570+ if len (_alias_list ) > 1 : # Aliased to multiple long-forms
571+ msg = (
572+ f"Short-form parameter ({ short_param } ) is not "
573+ f"recognized. Use long-form parameter(s) "
574+ f"'{ _long_alias } ' instead."
575+ )
576+ raise GMTInvalidInput (msg )
577+ # If there is only one long-form parameter, use it.
578+ kwargs [_long_alias ] = kwargs .pop (short_param )
579+ continue
580+
551581 if long_alias in kwargs and short_param in kwargs :
552582 msg = (
553583 f"Parameters in short-form ({ short_param } ) and "
0 commit comments