File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
main/groovy/javaposse/jobdsl/plugin Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
27
27
28
28
## Release Notes
29
29
* 1.57 (unreleased)
30
+ * Show more available method signatures in embedded API viewer
31
+ ([ #982 ] ( https://github.com/jenkinsci/job-dsl-plugin/pull/982 ) )
30
32
* 1.56 (January 06 2016)
31
33
* Fixed support for
32
34
[ Config File Provider Plugin] ( https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin )
Original file line number Diff line number Diff line change @@ -91,13 +91,43 @@ class EmbeddedApiDocGenerator {
91
91
}
92
92
knownMethods. addAll(extensions* . name)
93
93
94
+ methods. each { JSONObject method ->
95
+ if (! hasOptionalClosureSignature(method)) {
96
+ knownMethods. remove(method. getString(' name' ))
97
+ }
98
+ }
99
+
94
100
Map<String , DescribableModel > symbols = findDescribableModels(extensibleContextClass, knownMethods)
95
101
symbols. sort(). each { String symbol , DescribableModel model ->
96
- methods << generateMethod(symbol, model)
102
+ JSONObject method = methods. find { it. getString(' name' ) == symbol } as JSONObject
103
+ if (method) {
104
+ method. getJSONArray(' signatures' ). add(generateSignature(model))
105
+ } else {
106
+ methods << generateMethod(symbol, model)
107
+ }
97
108
}
98
109
}
99
110
}
100
111
112
+ private static boolean hasOptionalClosureSignature (JSONObject method ) {
113
+ method. getJSONArray(' signatures' ). any { JSONObject signature ->
114
+ isOptionalClosureSignature(signature)
115
+ }
116
+ }
117
+
118
+ private static boolean isOptionalClosureSignature (JSONObject signature ) {
119
+ if (! signature. has(' parameters' )) {
120
+ return true
121
+ }
122
+ JSONArray parameters = signature. getJSONArray(' parameters' )
123
+ if (parameters. size() > 1 ) {
124
+ return false
125
+ } else if (parameters. empty) {
126
+ return true
127
+ }
128
+ parameters[0 ]. getString(' type' ) == ' Closure'
129
+ }
130
+
101
131
/**
102
132
* Generates an extension method for an {@link ContextExtensionPoint} of a built-in context.
103
133
*/
Original file line number Diff line number Diff line change 121
121
}
122
122
],
123
123
"extension" : true
124
+ },
125
+ {
126
+ "parameters" : [],
127
+ "generated" : true
124
128
}
125
129
]
126
130
},
You can’t perform that action at this time.
0 commit comments