From 7542ef317368f4fed44608ab4fe3e3d40b7614d1 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 12 Aug 2016 17:08:43 -0400 Subject: [PATCH] [docs] Don't allow `[source,javascript]` The syntax highlighter doesn't support it. Just use `js`. --- .../org/elasticsearch/gradle/doc/DocsTestPlugin.groovy | 4 ++-- .../gradle/doc/RestTestsFromSnippetsTask.groovy | 10 ++++++++-- docs/plugins/discovery-azure-classic.asciidoc | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index 64031403279..0c2e37ab821 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -48,8 +48,8 @@ public class DocsTestPlugin extends RestTestPlugin { return } List languages = [ - // These languages should almost always be marked console - 'js', 'json', + // This language should almost always be marked console + 'js', // These are often curl commands that should be converted but // are probably false positives 'sh', 'shell', diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy index 100715586d3..61a07f4fbd4 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy @@ -32,6 +32,12 @@ import java.util.regex.Matcher * Generates REST tests for each snippet marked // TEST. */ public class RestTestsFromSnippetsTask extends SnippetsTask { + /** + * These languages aren't supported by the syntax highlighter so we + * shouldn't use them. + */ + private static final List BAD_LANGUAGES = ['json', 'javascript'] + @Input Map setups = new HashMap() @@ -87,9 +93,9 @@ public class RestTestsFromSnippetsTask extends SnippetsTask { * calls buildTest to actually build the test. */ void handleSnippet(Snippet snippet) { - if (snippet.language == 'json') { + if (BAD_LANGUAGES.contains(snippet.language)) { throw new InvalidUserDataException( - "$snippet: Use `js` instead of `json`.") + "$snippet: Use `js` instead of `${snippet.language}`.") } if (snippet.testSetup) { setup(snippet) diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index 5402e26b5f1..a9ec9929b49 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -387,7 +387,7 @@ curl http://localhost:9200/ This command should give you a JSON result: -[source,javascript] +[source,js] ---- { "status" : 200,