Include language in snippets so that their syntax can be highlighted
cURL requests are marked as being bash and cURL responses are marked as being http. This allows their syntax to be highlighted in the resulting HTML.
This commit is contained in:
@@ -3,7 +3,7 @@ Andy Wilkinson;
|
||||
:doctype: book
|
||||
:toc:
|
||||
:toclevels: 4
|
||||
:source-highlighter: prettify
|
||||
:source-highlighter: highlightjs
|
||||
|
||||
[introduction]
|
||||
= Introduction
|
||||
|
||||
@@ -3,7 +3,7 @@ Andy Wilkinson;
|
||||
:doctype: book
|
||||
:toc:
|
||||
:toclevels: 4
|
||||
:source-highlighter: prettify
|
||||
:source-highlighter: highlightjs
|
||||
|
||||
[introduction]
|
||||
= Introduction
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DocumentationWriter extends PrintWriter {
|
||||
}
|
||||
|
||||
public void shellCommand(final DocumentationAction... actions) throws Exception {
|
||||
codeBlock(new DocumentationAction() {
|
||||
codeBlock("bash", new DocumentationAction() {
|
||||
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
@@ -54,8 +54,11 @@ public class DocumentationWriter extends PrintWriter {
|
||||
super.write(s);
|
||||
}
|
||||
|
||||
public void codeBlock(DocumentationAction... actions) throws Exception {
|
||||
public void codeBlock(String language, DocumentationAction... actions) throws Exception {
|
||||
println();
|
||||
if (language != null) {
|
||||
println("[source," + language + "]");
|
||||
}
|
||||
println("----");
|
||||
for (DocumentationAction action : actions) {
|
||||
action.perform();
|
||||
|
||||
@@ -51,7 +51,7 @@ public abstract class RestDocumentationResultHandlers {
|
||||
@Override
|
||||
public void handle(MvcResult result, DocumentationWriter writer)
|
||||
throws Exception {
|
||||
writer.codeBlock(new CurlResponseDocumentationAction(writer, result,
|
||||
writer.codeBlock("http", new CurlResponseDocumentationAction(writer, result,
|
||||
getCurlConfiguration()));
|
||||
}
|
||||
};
|
||||
@@ -64,7 +64,7 @@ public abstract class RestDocumentationResultHandlers {
|
||||
throws Exception {
|
||||
writer.shellCommand(new CurlRequestDocumentationAction(writer, result,
|
||||
getCurlConfiguration()));
|
||||
writer.codeBlock(new CurlResponseDocumentationAction(writer, result,
|
||||
writer.codeBlock("http", new CurlResponseDocumentationAction(writer, result,
|
||||
getCurlConfiguration()));
|
||||
}
|
||||
};
|
||||
@@ -195,7 +195,7 @@ public abstract class RestDocumentationResultHandlers {
|
||||
printStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private PrintStream createPrintStream()
|
||||
throws FileNotFoundException {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user