浏览代码

[docs] Don't allow `[source,javascript]`

The syntax highlighter doesn't support it. Just use `js`.
Nik Everett 9 年之前
父节点
当前提交
7542ef3173

+ 2 - 2
buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy

@@ -48,8 +48,8 @@ public class DocsTestPlugin extends RestTestPlugin {
                 return
             }
             List<String> 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',

+ 8 - 2
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<String, String> 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)

+ 1 - 1
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,