Permalink
Browse files

Merge pull request #203 from jglick/symbols-JENKINS-37215

[JENKINS-37215] Symbol support
  • Loading branch information...
svanoort committed Feb 5, 2018
2 parents e61a02a + 509b623 commit b5542d99c8fba610538e1974a86785e62223c230
@@ -28,7 +28,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.1</version>
<version>3.4</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
@@ -105,7 +105,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.12</version>
<version>1.14-20180205.130907-1</version> <!-- TODO https://github.com/jenkinsci/structs-plugin/pull/35 -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -1,5 +1,6 @@
package org.jenkinsci.plugins.workflow.cps.Snippetizer

import org.jenkinsci.plugins.structs.SymbolLookup
import org.jenkinsci.plugins.structs.describable.ArrayType
import org.jenkinsci.plugins.structs.describable.AtomicType
import org.jenkinsci.plugins.structs.describable.DescribableModel
@@ -57,11 +58,11 @@ div(class:'dsl-reference'){

def generateStepHelp(Snippetizer.QuasiDescriptor d) throws Exception {
return {
dt(class:'step-title'){
dt(class:'step-title show-minimize'){
code(d.getSymbol())
raw(": ${d.real.getDisplayName()}")
}
dd(class:'step-body'){
dd(class:'step-body minimize'){
try {
generateHelp(new DescribableModel(d.real.clazz), 3);
} catch (Exception x) {
@@ -147,9 +148,11 @@ def describeType(ParameterType type, int headerLevel) throws Exception {
}
} else if (type instanceof HomogeneousObjectType) {
dl(class:'nested-object-box nested') {
dt(_("Nested object"))
DescribableModel model = ((HomogeneousObjectType) type).getSchemaType();
Set<String> symbols = SymbolLookup.getSymbolValue(model.getType());
dt(symbols.isEmpty() ? _("Nested object") : code(symbols.iterator().next()))
dd{
generateHelp(((HomogeneousObjectType) type).getSchemaType(), nextHeaderLevel);
generateHelp(model, nextHeaderLevel);
}
}
} else if (type instanceof HeterogeneousObjectType) {
@@ -159,12 +162,14 @@ def describeType(ParameterType type, int headerLevel) throws Exception {
if (type.actualType == Object) {
span(_("(not enumerable)"))
} else {
dl(class:'schema') {
dl(class:'schema root') {
for (Map.Entry<String, DescribableModel> entry : ((HeterogeneousObjectType) type).getTypes().entrySet()) {
dt {
code(DescribableModel.CLAZZ + ": '" + entry.key + "'")
Set<String> symbols = SymbolLookup.getSymbolValue(entry.getValue().getType());
String symbol = symbols.isEmpty() ? DescribableModel.CLAZZ + ": '" + entry.getKey() + "'" : symbols.iterator().next();
dt(class: 'show-minimize') {
code(symbol)
}
dd{
dd(class: 'minimize') {
generateHelp(entry.value, nextHeaderLevel);
}
}
@@ -233,14 +233,16 @@
st.assertGenerateSnippet("{'stapler-class':'" + CatchErrorStep.class.getName() + "'}", "// " + Messages.Snippetizer_this_step_should_not_normally_be_used_in() + "\ncatchError {\n // some block\n}", null);
}

@Issue("JENKINS-26126")
@Issue({"JENKINS-26126", "JENKINS-37215"})
@Test public void doDslRef() throws Exception {
JenkinsRule.WebClient wc = r.createWebClient();
String html = wc.goTo(Snippetizer.ACTION_URL + "/html").getWebResponse().getContentAsString();
assertThat("text from LoadStep/help-path.html is included", html, containsString("the Groovy file to load"));
assertThat("GitSCM.submoduleCfg is mentioned as an attribute of a value of GenericSCMStep.scm", html, containsString("submoduleCfg"));
assertThat("CleanBeforeCheckout is mentioned as an option", html, containsString("CleanBeforeCheckout"));
assertThat("content is written to the end", html, containsString("</body></html>"));
assertThat("symbols are noted for heterogeneous lists", html, containsString("<code>booleanParam</code>"));
assertThat("symbols are noted for homogeneous lists", html, containsString("<code>configFile</code>"));
}

@Issue({"JENKINS-35395", "JENKINS-38114"})

0 comments on commit b5542d9

Please sign in to comment.