package org.sonar.server.rule.ws;
import com.google.common.collect.Maps;
+import org.apache.commons.lang.StringEscapeUtils;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.server.debt.DebtCharacteristic;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.Collection;
import java.util.Map;
map("htmlDesc", new Mapper<RuleDoc, RuleMappingContext>() {
@Override
public void write(JsonWriter json, RuleDoc rule, RuleMappingContext context) {
- if (rule.markdownDescription() != null) {
- json.prop("htmlDesc", macroInterpreter.interpret(Markdown.convertToHtml(rule.markdownDescription())));
- } else {
- json.prop("htmlDesc", macroInterpreter.interpret(rule.htmlDescription()));
+ String html = rule.htmlDescription();
+ if (html != null) {
+ if (rule.isManual() || rule.templateKey() != null) {
+ String desc = StringEscapeUtils.escapeHtml(html);
+ desc = desc.replaceAll("\\n", "<br/>");
+ json.prop("htmlDesc", desc);
+ } else {
+ json.prop("htmlDesc", macroInterpreter.interpret(html));
+ }
}
}
});
- map("mdDesc", RuleNormalizer.RuleField.MARKDOWN_DESCRIPTION.field());
map("noteLogin", RuleNormalizer.RuleField.NOTE_LOGIN.field());
map("mdNote", RuleNormalizer.RuleField.NOTE.field());
map("htmlNote", new IndexMapper<RuleDoc, RuleMappingContext>(RuleNormalizer.RuleField.NOTE.field()) {
json
.beginObject()
.prop("key", param.key())
- .prop("htmlDesc", param.description() == null ? null : Markdown.convertToHtml(param.description()))
+ .prop("desc", param.description())
+ .prop("type", param.type().type())
.prop("defaultValue", param.defaultValue())
.endObject();
}
"params": [
{
"key": "my_var",
- "htmlDesc": "My small description",
- "defaultValue": "some value"
+ "desc": "My small description",
+ "defaultValue": "some value",
+ "type": "string"
},
{
"key": "the_var",
- "htmlDesc": "My small description",
- "defaultValue": "other value"
+ "desc": "My small description",
+ "defaultValue": "other value",
+ "type": "integer"
}
]
}
{{#eq type 'TEXT'}}
<textarea class="width100" rows="3" name="{{key}}" placeholder="{{defaultValue}}">{{value}}</textarea>
{{else}}
+ {{#eq type 'BOOLEAN'}}
+ <select name="{{key}}" value="{{value}}">
+ <option value="{{defaultValue}}">{{t 'default'}}</option>
+ <option value="true"{{#eq value 'true'}} selected="selected"{{/eq}}>{{t 'true'}}</option>
+ <option value="false"{{#eq value 'false'}} selected="selected"{{/eq}}>{{t 'false'}}</option>
+ </select>
+ {{else}}
<input type="text" name="{{key}}" value="{{value}}" placeholder="{{defaultValue}}">
+ {{/eq}}
{{/eq}}
<div class="note">{{description}}</div>
{{#if extra}}