@@ -450,7 +450,9 @@ def fmt_docstring(module_func):
450
450
aliases .append (" :columns: 3\n " )
451
451
for arg in sorted (module_func .aliases ):
452
452
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 ('-' )} " )
454
456
filler_text ["aliases" ] = "\n " .join (aliases )
455
457
456
458
filler_text ["table-classes" ] = (
@@ -484,6 +486,9 @@ def _insert_alias(module_func, default_value=None):
484
486
kwargs_param = wrapped_params .pop (- 1 )
485
487
# Add new parameters from aliases
486
488
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
487
492
if alias not in sig .parameters :
488
493
new_param = Parameter (
489
494
alias , kind = Parameter .KEYWORD_ONLY , default = default_value
@@ -548,6 +553,31 @@ def new_module(*args, **kwargs):
548
553
New module that parses and replaces the registered aliases.
549
554
"""
550
555
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
+
551
581
if long_alias in kwargs and short_param in kwargs :
552
582
msg = (
553
583
f"Parameters in short-form ({ short_param } ) and "
0 commit comments