1+ use crate :: synth_description:: DescriptionSynth ;
12use crate :: synth_directive:: DirectiveSynth ;
23use crate :: synth_identifier:: IdentifierSynth ;
34use crate :: synth_value_data:: ValueDataSynth ;
45use crate :: synth_value_type:: ValueTypeSynth ;
56use crate :: synths:: {
6- ChainSynth , MultilineListSynth , OneLineListSynth , StringSynth , Synth , SynthContext ,
7+ ChainSynth , MultilineListSynth , OneLineListSynth , PairSynth , StringSynth , Synth , SynthContext ,
78} ;
89use graphqxl_parser:: { Argument , ArgumentDefaultValue } ;
910
1011pub ( crate ) struct ArgumentsSynth ( pub ( crate ) Vec < Argument > ) ;
1112
1213impl Synth for ArgumentsSynth {
1314 fn synth ( & self , context : & mut SynthContext ) -> bool {
14- let inner_synths = self
15+ let mut at_least_one_description = false ;
16+ let inner_synths: Vec < Box < dyn Synth > > = self
1517 . 0
1618 . iter ( )
1719 . map ( |argument| {
@@ -31,11 +33,21 @@ impl Synth for ArgumentsSynth {
3133 v. push ( Box :: new ( StringSynth :: from ( " " ) ) ) ;
3234 v. push ( Box :: new ( DirectiveSynth ( directive. clone ( ) ) ) ) ;
3335 }
34- ChainSynth ( v)
36+
37+ if !argument. description . is_empty ( ) {
38+ at_least_one_description = true ;
39+ Box :: new ( PairSynth {
40+ first : DescriptionSynth :: text ( & argument. description ) ,
41+ last : ChainSynth ( v) ,
42+ line_jump_sep : true ,
43+ } )
44+ } else {
45+ Box :: new ( ChainSynth ( v) ) as Box < dyn Synth >
46+ }
3547 } )
3648 . collect ( ) ;
3749
38- if self . 0 . len ( ) > context. config . max_one_line_args {
50+ if self . 0 . len ( ) > context. config . max_one_line_args || at_least_one_description {
3951 MultilineListSynth :: no_suffix ( ( "(" , inner_synths, ")" ) ) . synth ( context) ;
4052 } else {
4153 OneLineListSynth :: comma ( ( "(" , inner_synths, ")" ) ) . synth ( context) ;
0 commit comments