@@ -70,25 +70,6 @@ func getMapValueString(m map[string]interface{}, key string) string {
7070 }
7171 return ""
7272}
73- func getDescription (raw interface {}) string {
74- var desc string
75-
76- switch node := raw .(type ) {
77- case ast.DescribableNode :
78- if sval := node .GetDescription (); sval != nil {
79- desc = sval .Value
80- }
81- case map [string ]interface {}:
82- desc = getMapValueString (node , "Description.Value" )
83- }
84- if desc != "" {
85- if strings .ContainsRune (desc , '\n' ) {
86-
87- }
88- desc = fmt .Sprintf (`"""%s"""` , desc )
89- }
90- return desc
91- }
9273
9374func toSliceString (slice interface {}) []string {
9475 if slice == nil {
@@ -525,9 +506,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
525506 fmt .Sprintf ("%v" , node .Name ),
526507 join (directives , " " ),
527508 }, " " )
528- if desc := getDescription (node ); desc != "" {
529- str = join ([]string {desc , str }, "\n " )
530- }
531509 return visitor .ActionUpdate , str
532510 case map [string ]interface {}:
533511 name := getMapValueString (node , "Name" )
@@ -540,9 +518,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
540518 name ,
541519 join (directives , " " ),
542520 }, " " )
543- if desc := getDescription (node ); desc != "" {
544- str = join ([]string {desc , str }, "\n " )
545- }
546521 return visitor .ActionUpdate , str
547522 }
548523 return visitor .ActionNoChange , nil
@@ -564,9 +539,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
564539 join (directives , " " ),
565540 block (fields ),
566541 }, " " )
567- if desc := getDescription (node ); desc != "" {
568- str = join ([]string {desc , str }, "\n " )
569- }
570542 return visitor .ActionUpdate , str
571543 case map [string ]interface {}:
572544 name := getMapValueString (node , "Name" )
@@ -583,9 +555,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
583555 join (directives , " " ),
584556 block (fields ),
585557 }, " " )
586- if desc := getDescription (node ); desc != "" {
587- str = join ([]string {desc , str }, "\n " )
588- }
589558 return visitor .ActionUpdate , str
590559 }
591560 return visitor .ActionNoChange , nil
@@ -601,9 +570,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
601570 directives = append (directives , fmt .Sprintf ("%v" , directive .Name ))
602571 }
603572 str := name + wrap ("(" , join (args , ", " ), ")" ) + ": " + ttype + wrap (" " , join (directives , " " ), "" )
604- if desc := getDescription (node ); desc != "" {
605- str = join ([]string {desc , str }, "\n " )
606- }
607573 return visitor .ActionUpdate , str
608574 case map [string ]interface {}:
609575 name := getMapValueString (node , "Name" )
@@ -614,9 +580,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
614580 directives = append (directives , fmt .Sprintf ("%v" , directive ))
615581 }
616582 str := name + wrap ("(" , join (args , ", " ), ")" ) + ": " + ttype + wrap (" " , join (directives , " " ), "" )
617- if desc := getDescription (node ); desc != "" {
618- str = join ([]string {desc , str }, "\n " )
619- }
620583 return visitor .ActionUpdate , str
621584 }
622585 return visitor .ActionNoChange , nil
@@ -636,9 +599,7 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
636599 wrap ("= " , defaultValue , "" ),
637600 join (directives , " " ),
638601 }, " " )
639- if desc := getDescription (node ); desc != "" {
640- str = join ([]string {desc , str }, " " )
641- }
602+
642603 return visitor .ActionUpdate , str
643604 case map [string ]interface {}:
644605 name := getMapValueString (node , "Name" )
@@ -653,9 +614,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
653614 wrap ("= " , defaultValue , "" ),
654615 join (directives , " " ),
655616 }, " " )
656- if desc := getDescription (node ); desc != "" {
657- str = join ([]string {desc , str }, " " )
658- }
659617 return visitor .ActionUpdate , str
660618 }
661619 return visitor .ActionNoChange , nil
@@ -675,9 +633,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
675633 join (directives , " " ),
676634 block (fields ),
677635 }, " " )
678- if desc := getDescription (node ); desc != "" {
679- str = join ([]string {desc , str }, "\n " )
680- }
681636 return visitor .ActionUpdate , str
682637 case map [string ]interface {}:
683638 name := getMapValueString (node , "Name" )
@@ -692,9 +647,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
692647 join (directives , " " ),
693648 block (fields ),
694649 }, " " )
695- if desc := getDescription (node ); desc != "" {
696- str = join ([]string {desc , str }, "\n " )
697- }
698650 return visitor .ActionUpdate , str
699651 }
700652 return visitor .ActionNoChange , nil
@@ -714,9 +666,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
714666 join (directives , " " ),
715667 "= " + join (types , " | " ),
716668 }, " " )
717- if desc := getDescription (node ); desc != "" {
718- str = join ([]string {desc , str }, "\n " )
719- }
720669 return visitor .ActionUpdate , str
721670 case map [string ]interface {}:
722671 name := getMapValueString (node , "Name" )
@@ -731,9 +680,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
731680 join (directives , " " ),
732681 "= " + join (types , " | " ),
733682 }, " " )
734- if desc := getDescription (node ); desc != "" {
735- str = join ([]string {desc , str }, "\n " )
736- }
737683 return visitor .ActionUpdate , str
738684 }
739685 return visitor .ActionNoChange , nil
@@ -753,9 +699,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
753699 join (directives , " " ),
754700 block (values ),
755701 }, " " )
756- if desc := getDescription (node ); desc != "" {
757- str = join ([]string {desc , str }, "\n " )
758- }
759702 return visitor .ActionUpdate , str
760703 case map [string ]interface {}:
761704 name := getMapValueString (node , "Name" )
@@ -770,9 +713,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
770713 join (directives , " " ),
771714 block (values ),
772715 }, " " )
773- if desc := getDescription (node ); desc != "" {
774- str = join ([]string {desc , str }, "\n " )
775- }
776716 return visitor .ActionUpdate , str
777717 }
778718 return visitor .ActionNoChange , nil
@@ -789,9 +729,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
789729 name ,
790730 join (directives , " " ),
791731 }, " " )
792- if desc := getDescription (node ); desc != "" {
793- str = join ([]string {desc , str }, "\n " )
794- }
795732 return visitor .ActionUpdate , str
796733 case map [string ]interface {}:
797734 name := getMapValueString (node , "Name" )
@@ -803,9 +740,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
803740 name ,
804741 join (directives , " " ),
805742 }, " " )
806- if desc := getDescription (node ); desc != "" {
807- str = join ([]string {desc , str }, "\n " )
808- }
809743 return visitor .ActionUpdate , str
810744 }
811745 return visitor .ActionNoChange , nil
@@ -825,9 +759,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
825759 join (directives , " " ),
826760 block (fields ),
827761 }, " " )
828- if desc := getDescription (node ); desc != "" {
829- str = join ([]string {desc , str }, "\n " )
830- }
831762 return visitor .ActionUpdate , str
832763 case map [string ]interface {}:
833764 name := getMapValueString (node , "Name" )
@@ -842,9 +773,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
842773 join (directives , " " ),
843774 block (fields ),
844775 }, " " )
845- if desc := getDescription (node ); desc != "" {
846- str = join ([]string {desc , str }, "\n " )
847- }
848776 return visitor .ActionUpdate , str
849777 }
850778 return visitor .ActionNoChange , nil
@@ -854,16 +782,10 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
854782 case * ast.TypeExtensionDefinition :
855783 definition := fmt .Sprintf ("%v" , node .Definition )
856784 str := "extend " + definition
857- if desc := getDescription (node ); desc != "" {
858- str = join ([]string {desc , str }, "\n " )
859- }
860785 return visitor .ActionUpdate , str
861786 case map [string ]interface {}:
862787 definition := getMapValueString (node , "Definition" )
863788 str := "extend " + definition
864- if desc := getDescription (node ); desc != "" {
865- str = join ([]string {desc , str }, "\n " )
866- }
867789 return visitor .ActionUpdate , str
868790 }
869791 return visitor .ActionNoChange , nil
@@ -873,19 +795,13 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
873795 case * ast.DirectiveDefinition :
874796 args := wrap ("(" , join (toSliceString (node .Arguments ), ", " ), ")" )
875797 str := fmt .Sprintf ("directive @%v%v on %v" , node .Name , args , join (toSliceString (node .Locations ), " | " ))
876- if desc := getDescription (node ); desc != "" {
877- str = join ([]string {desc , str }, "\n " )
878- }
879798 return visitor .ActionUpdate , str
880799 case map [string ]interface {}:
881800 name := getMapValueString (node , "Name" )
882801 locations := toSliceString (getMapValue (node , "Locations" ))
883802 args := toSliceString (getMapValue (node , "Arguments" ))
884803 argsStr := wrap ("(" , join (args , ", " ), ")" )
885804 str := fmt .Sprintf ("directive @%v%v on %v" , name , argsStr , join (locations , " | " ))
886- if desc := getDescription (node ); desc != "" {
887- str = join ([]string {desc , str }, "\n " )
888- }
889805 return visitor .ActionUpdate , str
890806 }
891807 return visitor .ActionNoChange , nil
0 commit comments