@@ -624,5 +624,112 @@ def preprocessor(another_input, _a_private_input, another_input2=None):
624
624
assert doc .template_config == expected_config
625
625
626
626
627
+ def test_command_documentation_duplicate_params ():
628
+ """Test `CommandDocumentation` for duplicated parameters."""
629
+
630
+ class TestCommand :
631
+ """A test command as a class."""
632
+
633
+ def __init__ (
634
+ self , _arg0 , arg1 , arg2 = None , arg3 = "hello" , max_workers = None
635
+ ):
636
+ """Initialize Model.
637
+
638
+ Extended from init.
639
+
640
+ Parameters
641
+ ----------
642
+ _arg0 : int
643
+ A private input.
644
+ arg1 : int
645
+ Arg1 for model.
646
+ arg2 : float, optional
647
+ Arg2 for model. By default, ``None``.
648
+ arg3 : str, optional
649
+ Arg3 for model. By default, ``"hello"``.
650
+ max_workers : int, optional
651
+ Max num workers. By default, ``None``.
652
+ """
653
+
654
+ def func (self , project_points , a , _private_arg1 , b = 1 , arg3 = "test" ):
655
+ """A test function.
656
+
657
+ Extended from func.
658
+
659
+ Parameters
660
+ ----------
661
+ project_points : str
662
+ Path to project points file.
663
+ a : float
664
+ An arg.
665
+ b : int, optional
666
+ Another arg. By default, ``1``.
667
+ arg3 : str, optional
668
+ Arg3 for func. By default, ``"test"``.
669
+ """
670
+
671
+ def preprocessor (another_input , _a_private_input , arg3 = "pre" ):
672
+ """A sample pre-processor function
673
+
674
+ Extended from preprocessor.
675
+
676
+ Parameters
677
+ ----------
678
+ another_input : int
679
+ Another model input.
680
+ arg3 : str, optional
681
+ Arg3 for preprocessing. By default, ``"pre"``.
682
+ """
683
+
684
+ doc = CommandDocumentation (
685
+ TestCommand ,
686
+ getattr (TestCommand , "func" ),
687
+ preprocessor ,
688
+ skip_params = {"a" },
689
+ is_split_spatially = True ,
690
+ )
691
+ assert len (doc .signatures ) == 3
692
+
693
+ docstring = doc .hpc_parameter_help
694
+ assert ":max_workers:" in docstring
695
+ assert "\n arg1 :" in docstring
696
+ assert "\n arg2 :" in docstring
697
+ assert "\n arg3 :" in docstring
698
+ assert "project_points :" in docstring
699
+ assert "\n b :" in docstring
700
+ assert "\n another_input :" in docstring
701
+ assert "log_directory :" in docstring
702
+ assert "log_level :" in docstring
703
+
704
+ assert "\n a :" not in docstring
705
+ assert "\n self :" not in docstring
706
+ assert "_private_arg1" not in docstring
707
+ assert "_a_private_input" not in docstring
708
+
709
+ assert 'Arg3 for preprocessing. By default, ``"pre"``.' in docstring
710
+ assert 'Arg3 for model. By default, ``"hello"``.' not in docstring
711
+ assert 'Arg3 for func. By default, ``"test"``.' not in docstring
712
+
713
+ assert "Extended from init" in doc .extended_summary
714
+ assert "Extended from func" not in doc .extended_summary
715
+ assert "Extended from preprocessor" not in doc .extended_summary
716
+
717
+ exec_vals = deepcopy (DEFAULT_EXEC_VALUES )
718
+ exec_vals ["max_workers" ] = None
719
+ expected_config = {
720
+ "execution_control" : exec_vals ,
721
+ "log_directory" : "./logs" ,
722
+ "log_level" : "INFO" ,
723
+ "arg1" : doc .REQUIRED_TAG ,
724
+ "arg2" : None ,
725
+ "arg3" : "pre" ,
726
+ "project_points" : doc .REQUIRED_TAG ,
727
+ "b" : 1 ,
728
+ "another_input" : doc .REQUIRED_TAG ,
729
+ }
730
+ assert doc .template_config == expected_config
731
+
732
+
733
+
627
734
if __name__ == "__main__" :
628
735
pytest .main (["-q" , "--show-capture=all" , Path (__file__ ), "-rapP" ])
0 commit comments