File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
buildSrc/src/main/groovy/org/elasticsearch/gradle/doc Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ public class DocsTestPlugin extends RestTestPlugin {
4848 return
4949 }
5050 List<String > languages = [
51- // These languages should almost always be marked console
52- ' js' , ' json ' ,
51+ // This language should almost always be marked console
52+ ' js' ,
5353 // These are often curl commands that should be converted but
5454 // are probably false positives
5555 ' sh' , ' shell' ,
Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ import java.util.regex.Matcher
3232 * Generates REST tests for each snippet marked // TEST.
3333 */
3434public class RestTestsFromSnippetsTask extends SnippetsTask {
35+ /**
36+ * These languages aren't supported by the syntax highlighter so we
37+ * shouldn't use them.
38+ */
39+ private static final List BAD_LANGUAGES = [' json' , ' javascript' ]
40+
3541 @Input
3642 Map<String , String > setups = new HashMap ()
3743
@@ -87,9 +93,9 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
8793 * calls buildTest to actually build the test.
8894 */
8995 void handleSnippet (Snippet snippet ) {
90- if (snippet. language == ' json ' ) {
96+ if (BAD_LANGUAGES . contains( snippet. language) ) {
9197 throw new InvalidUserDataException (
92- " $snippet : Use `js` instead of `json `." )
98+ " $snippet : Use `js` instead of `${ snippet.language } `." )
9399 }
94100 if (snippet. testSetup) {
95101 setup(snippet)
Original file line number Diff line number Diff line change @@ -387,7 +387,7 @@ curl http://localhost:9200/
387387
388388This command should give you a JSON result:
389389
390- [source,javascript ]
390+ [source,js ]
391391----
392392{
393393 "status" : 200,
You can’t perform that action at this time.
0 commit comments