@@ -835,6 +835,19 @@ public let DECL_NODES: [Node] = [
835
835
kind: . extensionDecl,
836
836
base: . decl,
837
837
nameForDiagnostics: " extension " ,
838
+ documentation: """
839
+ An `extension` declaration.
840
+
841
+ ### Example
842
+
843
+ ```swift
844
+ extension String {
845
+ var url: URL? {
846
+ URL(string: self)
847
+ }
848
+ }
849
+ ```
850
+ """ ,
838
851
traits: [
839
852
" DeclGroup " ,
840
853
" WithAttributes " ,
@@ -844,7 +857,18 @@ public let DECL_NODES: [Node] = [
844
857
Child (
845
858
name: " attributes " ,
846
859
kind: . collection( kind: . attributeList, collectionElementName: " Attribute " , defaultsToEmpty: true ) ,
847
- nameForDiagnostics: " attributes "
860
+ nameForDiagnostics: " attributes " ,
861
+ documentation: """
862
+ Attributes that are attached to the extension declaration.
863
+
864
+ ### Example
865
+
866
+ `@MainActor` in
867
+
868
+ ```swift
869
+ @MainActor extension SomeType {}
870
+ ```
871
+ """
848
872
) ,
849
873
Child (
850
874
name: " modifiers " ,
@@ -854,16 +878,19 @@ public let DECL_NODES: [Node] = [
854
878
) ,
855
879
Child (
856
880
name: " extensionKeyword " ,
857
- kind: . token( choices: [ . keyword( . extension) ] )
881
+ kind: . token( choices: [ . keyword( . extension) ] ) ,
882
+ documentation: " The `extension` keyword. "
858
883
) ,
859
884
Child (
860
885
name: " extendedType " ,
861
- kind: . node( kind: . type)
886
+ kind: . node( kind: . type) ,
887
+ documentation: " The extended `type` for which the extension is added. "
862
888
) ,
863
889
Child (
864
890
name: " inheritanceClause " ,
865
891
kind: . node( kind: . inheritanceClause) ,
866
892
nameForDiagnostics: " inheritance clause " ,
893
+ documentation: " The inheritance clause describing one or more conformances for this extension declaration. " ,
867
894
isOptional: true
868
895
) ,
869
896
Child (
@@ -887,6 +914,27 @@ public let DECL_NODES: [Node] = [
887
914
kind: . functionDecl,
888
915
base: . decl,
889
916
nameForDiagnostics: " function " ,
917
+ documentation: """
918
+ A Swift `func` declaration.
919
+
920
+ ### Example
921
+
922
+ A func declaration may be declared without any parameter.
923
+
924
+ ```swift
925
+ func foo() {
926
+
927
+ }
928
+ ```
929
+
930
+ A func declaration with multiple parameters.
931
+
932
+ ```swift
933
+ func bar(_ arg1: Int, _ arg2: Int) {
934
+
935
+ }
936
+ ```
937
+ """ ,
890
938
traits: [
891
939
" NamedDecl " ,
892
940
" WithAttributes " ,
@@ -898,7 +946,8 @@ public let DECL_NODES: [Node] = [
898
946
Child (
899
947
name: " attributes " ,
900
948
kind: . collection( kind: . attributeList, collectionElementName: " Attribute " , defaultsToEmpty: true ) ,
901
- nameForDiagnostics: " attributes "
949
+ nameForDiagnostics: " attributes " ,
950
+ documentation: " Attributes that are attached to the function declaration. "
902
951
) ,
903
952
Child (
904
953
name: " modifiers " ,
@@ -908,7 +957,8 @@ public let DECL_NODES: [Node] = [
908
957
) ,
909
958
Child (
910
959
name: " funcKeyword " ,
911
- kind: . token( choices: [ . keyword( . func) ] )
960
+ kind: . token( choices: [ . keyword( . func) ] ) ,
961
+ documentation: " The `func` keyword. "
912
962
) ,
913
963
Child (
914
964
name: " name " ,
@@ -931,7 +981,10 @@ public let DECL_NODES: [Node] = [
931
981
Child (
932
982
name: " signature " ,
933
983
kind: . node( kind: . functionSignature) ,
934
- nameForDiagnostics: " function signature "
984
+ nameForDiagnostics: " function signature " ,
985
+ documentation: """
986
+ A function signature that defines the interface of the function.
987
+ """
935
988
) ,
936
989
Child (
937
990
name: " genericWhereClause " ,
@@ -944,6 +997,7 @@ public let DECL_NODES: [Node] = [
944
997
Child (
945
998
name: " body " ,
946
999
kind: . node( kind: . codeBlock) ,
1000
+ documentation: " The function's body. " ,
947
1001
isOptional: true
948
1002
) ,
949
1003
]
@@ -953,60 +1007,83 @@ public let DECL_NODES: [Node] = [
953
1007
kind: . functionParameterList,
954
1008
base: . syntaxCollection,
955
1009
nameForDiagnostics: " parameter list " ,
1010
+ documentation: """
1011
+ A list of function parameters that are type annotated and a label.
1012
+ The function parameters are represented by `FunctionParameterListSyntax`.
1013
+
1014
+ ### Example
1015
+
1016
+ ```swift
1017
+ func foo(bar: Int, baz: Int) {
1018
+
1019
+ }
1020
+ ```
1021
+ """ ,
956
1022
elementChoices: [ . functionParameter]
957
1023
) ,
958
1024
959
1025
Node (
960
1026
kind: . functionParameter,
961
1027
base: . syntax,
962
1028
nameForDiagnostics: " parameter " ,
1029
+ documentation: " A function parameter " ,
963
1030
parserFunction: " parseFunctionParameter " ,
964
1031
traits: [ " WithTrailingComma " , " WithAttributes " , " WithModifiers " ] ,
965
1032
children: [
966
1033
Child (
967
1034
name: " attributes " ,
968
1035
kind: . collection( kind: . attributeList, collectionElementName: " Attribute " , defaultsToEmpty: true ) ,
969
- nameForDiagnostics: " attributes "
1036
+ nameForDiagnostics: " attributes " ,
1037
+ documentation: " Attributes that are attached to the parameter. "
970
1038
) ,
971
1039
Child (
972
1040
name: " modifiers " ,
973
1041
kind: . collection( kind: . declModifierList, collectionElementName: " Modifier " , defaultsToEmpty: true ) ,
974
- nameForDiagnostics: " modifiers "
1042
+ nameForDiagnostics: " modifiers " ,
1043
+ documentation: " Modifiers that are attached to the parameter. "
975
1044
) ,
976
1045
Child (
977
1046
name: " firstName " ,
978
- kind: . token( choices: [ . token( . identifier) , . token( . wildcard) ] )
1047
+ kind: . token( choices: [ . token( . identifier) , . token( . wildcard) ] ) ,
1048
+ documentation: " The label of this parameter that will be used when the function is called. "
979
1049
) ,
980
1050
Child (
981
1051
name: " secondName " ,
982
1052
kind: . token( choices: [ . token( . identifier) , . token( . wildcard) ] , requiresLeadingSpace: true ) ,
983
1053
nameForDiagnostics: " internal name " ,
1054
+ documentation:
1055
+ " If this is specified, it is the name by which the parameter can be referenced inside the function body. " ,
984
1056
isOptional: true
985
1057
) ,
986
1058
Child (
987
1059
name: " colon " ,
988
- kind: . token( choices: [ . token( . colon) ] )
1060
+ kind: . token( choices: [ . token( . colon) ] ) ,
1061
+ documentation: " The colon separating the label from the type. "
989
1062
) ,
990
1063
Child (
991
1064
name: " type " ,
992
1065
kind: . node( kind: . type) ,
993
- nameForDiagnostics: " type "
1066
+ nameForDiagnostics: " type " ,
1067
+ documentation: " The parameter's type. "
994
1068
) ,
995
1069
Child (
996
1070
name: " ellipsis " ,
997
1071
kind: . token( choices: [ . token( . ellipsis) ] ) ,
1072
+ documentation: " If the parameter is variadic, `...` to indicate that. " ,
998
1073
isOptional: true
999
1074
) ,
1000
1075
Child (
1001
1076
name: " defaultValue " ,
1002
1077
deprecatedName: " defaultArgument " ,
1003
1078
kind: . node( kind: . initializerClause) ,
1004
1079
nameForDiagnostics: " default value " ,
1080
+ documentation: " If the parameter has a default value, the expression describing the default value. " ,
1005
1081
isOptional: true
1006
1082
) ,
1007
1083
Child (
1008
1084
name: " trailingComma " ,
1009
1085
kind: . token( choices: [ . token( . comma) ] ) ,
1086
+ documentation: " If the parameter is followed by another parameter, the comma separating them. " ,
1010
1087
isOptional: true
1011
1088
) ,
1012
1089
]
@@ -1016,21 +1093,25 @@ public let DECL_NODES: [Node] = [
1016
1093
kind: . functionSignature,
1017
1094
base: . syntax,
1018
1095
nameForDiagnostics: " function signature " ,
1096
+ documentation: " A function signature that defines the interface of the function. " ,
1019
1097
children: [
1020
1098
Child (
1021
1099
name: " parameterClause " ,
1022
1100
deprecatedName: " input " ,
1023
- kind: . node( kind: . functionParameterClause)
1101
+ kind: . node( kind: . functionParameterClause) ,
1102
+ documentation: " The parameters of the function. "
1024
1103
) ,
1025
1104
Child (
1026
1105
name: " effectSpecifiers " ,
1027
1106
kind: . node( kind: . functionEffectSpecifiers) ,
1107
+ documentation: " The effect indicators of the function, like `async` or `throws` " ,
1028
1108
isOptional: true
1029
1109
) ,
1030
1110
Child (
1031
1111
name: " returnClause " ,
1032
1112
deprecatedName: " output " ,
1033
1113
kind: . node( kind: . returnClause) ,
1114
+ documentation: " The return type of the function. " ,
1034
1115
isOptional: true
1035
1116
) ,
1036
1117
]
@@ -1941,13 +2022,15 @@ public let DECL_NODES: [Node] = [
1941
2022
children: [
1942
2023
Child (
1943
2024
name: " arrow " ,
1944
- kind: . token( choices: [ . token( . arrow) ] )
2025
+ kind: . token( choices: [ . token( . arrow) ] ) ,
2026
+ documentation: " If return type is presented, the arrow introducing the return type. "
1945
2027
) ,
1946
2028
Child (
1947
2029
name: " type " ,
1948
2030
deprecatedName: " returnType " ,
1949
2031
kind: . node( kind: . type) ,
1950
- nameForDiagnostics: " return type "
2032
+ nameForDiagnostics: " return type " ,
2033
+ documentation: " The `return` type. "
1951
2034
) ,
1952
2035
]
1953
2036
) ,
0 commit comments