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
2727
2828## Release Notes
2929* 1.57 (unreleased)
30+ * Show more available method signatures in embedded API viewer
31+ ([ #982 ] ( https://github.com/jenkinsci/job-dsl-plugin/pull/982 ) )
3032* 1.56 (January 06 2016)
3133 * Fixed support for
3234 [ 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 {
9191 }
9292 knownMethods. addAll(extensions* . name)
9393
94+ methods. each { JSONObject method ->
95+ if (! hasOptionalClosureSignature(method)) {
96+ knownMethods. remove(method. getString(' name' ))
97+ }
98+ }
99+
94100 Map<String , DescribableModel > symbols = findDescribableModels(extensibleContextClass, knownMethods)
95101 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+ }
97108 }
98109 }
99110 }
100111
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+
101131 /**
102132 * Generates an extension method for an {@link ContextExtensionPoint} of a built-in context.
103133 */
Original file line number Diff line number Diff line change 121121 }
122122 ],
123123 "extension" : true
124+ },
125+ {
126+ "parameters" : [],
127+ "generated" : true
124128 }
125129 ]
126130 },
You can’t perform that action at this time.
0 commit comments