Skip to content

Commit 7542ef3

Browse files
committed
[docs] Don't allow [source,javascript]
The syntax highlighter doesn't support it. Just use `js`.
1 parent ffd226e commit 7542ef3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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',

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ import java.util.regex.Matcher
3232
* Generates REST tests for each snippet marked // TEST.
3333
*/
3434
public 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)

docs/plugins/discovery-azure-classic.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ curl http://localhost:9200/
387387

388388
This command should give you a JSON result:
389389

390-
[source,javascript]
390+
[source,js]
391391
----
392392
{
393393
"status" : 200,

0 commit comments

Comments
 (0)