@@ -835,6 +835,19 @@ public let DECL_NODES: [Node] = [
835835 kind: . extensionDecl,
836836 base: . decl,
837837 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+ """ ,
838851 traits: [
839852 " DeclGroup " ,
840853 " WithAttributes " ,
@@ -844,7 +857,18 @@ public let DECL_NODES: [Node] = [
844857 Child (
845858 name: " attributes " ,
846859 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+ """
848872 ) ,
849873 Child (
850874 name: " modifiers " ,
@@ -854,16 +878,19 @@ public let DECL_NODES: [Node] = [
854878 ) ,
855879 Child (
856880 name: " extensionKeyword " ,
857- kind: . token( choices: [ . keyword( . extension) ] )
881+ kind: . token( choices: [ . keyword( . extension) ] ) ,
882+ documentation: " The `extension` keyword. "
858883 ) ,
859884 Child (
860885 name: " extendedType " ,
861- kind: . node( kind: . type)
886+ kind: . node( kind: . type) ,
887+ documentation: " The extended `type` for which the extension is added. "
862888 ) ,
863889 Child (
864890 name: " inheritanceClause " ,
865891 kind: . node( kind: . inheritanceClause) ,
866892 nameForDiagnostics: " inheritance clause " ,
893+ documentation: " The inheritance clause describing one or more conformances for this extension declaration. " ,
867894 isOptional: true
868895 ) ,
869896 Child (
@@ -887,6 +914,27 @@ public let DECL_NODES: [Node] = [
887914 kind: . functionDecl,
888915 base: . decl,
889916 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+ """ ,
890938 traits: [
891939 " NamedDecl " ,
892940 " WithAttributes " ,
@@ -898,7 +946,8 @@ public let DECL_NODES: [Node] = [
898946 Child (
899947 name: " attributes " ,
900948 kind: . collection( kind: . attributeList, collectionElementName: " Attribute " , defaultsToEmpty: true ) ,
901- nameForDiagnostics: " attributes "
949+ nameForDiagnostics: " attributes " ,
950+ documentation: " Attributes that are attached to the function declaration. "
902951 ) ,
903952 Child (
904953 name: " modifiers " ,
@@ -908,7 +957,8 @@ public let DECL_NODES: [Node] = [
908957 ) ,
909958 Child (
910959 name: " funcKeyword " ,
911- kind: . token( choices: [ . keyword( . func) ] )
960+ kind: . token( choices: [ . keyword( . func) ] ) ,
961+ documentation: " The `func` keyword. "
912962 ) ,
913963 Child (
914964 name: " name " ,
@@ -931,7 +981,10 @@ public let DECL_NODES: [Node] = [
931981 Child (
932982 name: " signature " ,
933983 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+ """
935988 ) ,
936989 Child (
937990 name: " genericWhereClause " ,
@@ -944,6 +997,7 @@ public let DECL_NODES: [Node] = [
944997 Child (
945998 name: " body " ,
946999 kind: . node( kind: . codeBlock) ,
1000+ documentation: " The function's body. " ,
9471001 isOptional: true
9481002 ) ,
9491003 ]
@@ -953,60 +1007,83 @@ public let DECL_NODES: [Node] = [
9531007 kind: . functionParameterList,
9541008 base: . syntaxCollection,
9551009 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+ """ ,
9561022 elementChoices: [ . functionParameter]
9571023 ) ,
9581024
9591025 Node (
9601026 kind: . functionParameter,
9611027 base: . syntax,
9621028 nameForDiagnostics: " parameter " ,
1029+ documentation: " A function parameter " ,
9631030 parserFunction: " parseFunctionParameter " ,
9641031 traits: [ " WithTrailingComma " , " WithAttributes " , " WithModifiers " ] ,
9651032 children: [
9661033 Child (
9671034 name: " attributes " ,
9681035 kind: . collection( kind: . attributeList, collectionElementName: " Attribute " , defaultsToEmpty: true ) ,
969- nameForDiagnostics: " attributes "
1036+ nameForDiagnostics: " attributes " ,
1037+ documentation: " Attributes that are attached to the parameter. "
9701038 ) ,
9711039 Child (
9721040 name: " modifiers " ,
9731041 kind: . collection( kind: . declModifierList, collectionElementName: " Modifier " , defaultsToEmpty: true ) ,
974- nameForDiagnostics: " modifiers "
1042+ nameForDiagnostics: " modifiers " ,
1043+ documentation: " Modifiers that are attached to the parameter. "
9751044 ) ,
9761045 Child (
9771046 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. "
9791049 ) ,
9801050 Child (
9811051 name: " secondName " ,
9821052 kind: . token( choices: [ . token( . identifier) , . token( . wildcard) ] , requiresLeadingSpace: true ) ,
9831053 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. " ,
9841056 isOptional: true
9851057 ) ,
9861058 Child (
9871059 name: " colon " ,
988- kind: . token( choices: [ . token( . colon) ] )
1060+ kind: . token( choices: [ . token( . colon) ] ) ,
1061+ documentation: " The colon separating the label from the type. "
9891062 ) ,
9901063 Child (
9911064 name: " type " ,
9921065 kind: . node( kind: . type) ,
993- nameForDiagnostics: " type "
1066+ nameForDiagnostics: " type " ,
1067+ documentation: " The parameter's type. "
9941068 ) ,
9951069 Child (
9961070 name: " ellipsis " ,
9971071 kind: . token( choices: [ . token( . ellipsis) ] ) ,
1072+ documentation: " If the parameter is variadic, `...` to indicate that. " ,
9981073 isOptional: true
9991074 ) ,
10001075 Child (
10011076 name: " defaultValue " ,
10021077 deprecatedName: " defaultArgument " ,
10031078 kind: . node( kind: . initializerClause) ,
10041079 nameForDiagnostics: " default value " ,
1080+ documentation: " If the parameter has a default value, the expression describing the default value. " ,
10051081 isOptional: true
10061082 ) ,
10071083 Child (
10081084 name: " trailingComma " ,
10091085 kind: . token( choices: [ . token( . comma) ] ) ,
1086+ documentation: " If the parameter is followed by another parameter, the comma separating them. " ,
10101087 isOptional: true
10111088 ) ,
10121089 ]
@@ -1016,21 +1093,25 @@ public let DECL_NODES: [Node] = [
10161093 kind: . functionSignature,
10171094 base: . syntax,
10181095 nameForDiagnostics: " function signature " ,
1096+ documentation: " A function signature that defines the interface of the function. " ,
10191097 children: [
10201098 Child (
10211099 name: " parameterClause " ,
10221100 deprecatedName: " input " ,
1023- kind: . node( kind: . functionParameterClause)
1101+ kind: . node( kind: . functionParameterClause) ,
1102+ documentation: " The parameters of the function. "
10241103 ) ,
10251104 Child (
10261105 name: " effectSpecifiers " ,
10271106 kind: . node( kind: . functionEffectSpecifiers) ,
1107+ documentation: " The effect indicators of the function, like `async` or `throws` " ,
10281108 isOptional: true
10291109 ) ,
10301110 Child (
10311111 name: " returnClause " ,
10321112 deprecatedName: " output " ,
10331113 kind: . node( kind: . returnClause) ,
1114+ documentation: " The return type of the function. " ,
10341115 isOptional: true
10351116 ) ,
10361117 ]
@@ -1941,13 +2022,15 @@ public let DECL_NODES: [Node] = [
19412022 children: [
19422023 Child (
19432024 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. "
19452027 ) ,
19462028 Child (
19472029 name: " type " ,
19482030 deprecatedName: " returnType " ,
19492031 kind: . node( kind: . type) ,
1950- nameForDiagnostics: " return type "
2032+ nameForDiagnostics: " return type " ,
2033+ documentation: " The `return` type. "
19512034 ) ,
19522035 ]
19532036 ) ,
0 commit comments