Switch from asciidoc to asciidoctor

To avoid possible GPL licensing issues, switch documentation
rendering from asciidoc to to the MIT licensed asciidoctor.

Asciidoctor can't render our docs if it uses xhtml11 backend, so use
the html5 backend instead.

The current stable version of asciidoctor (0.1.3) has no default CSS.
Configure documentation to reference a modified copy of Gerrit's own
pegdown.css, which is used by plugin documentation rendering to get a
close approximation to the original asciidoc look.

Change-Id: If1ee984c77533d603768e5fac8a91eee211f0d5b
diff --git a/Documentation/BUCK b/Documentation/BUCK
index b1a8220..faa2553 100644
--- a/Documentation/BUCK
+++ b/Documentation/BUCK
@@ -20,23 +20,32 @@
       'images/*.jpg',
       'images/*.png',
     ]) + [
+    genfile('doc.css'),
     genfile('licenses.html'),
     genfile('licenses.txt'),
   ],
   deps = [':' + d for d in HTML] + [
     ':licenses.html',
     ':licenses.txt',
+    ':doc.css',
   ],
   out = 'html.zip',
   visibility = ['PUBLIC'],
 )
 
+genrule(
+  name = 'doc.css',
+  cmd = 'ln -s $SRCDIR/doc.css $OUT',
+  srcs = ['doc.css'],
+  out = 'doc.css',
+)
+
 genasciidoc(
   srcs = SRCS + [genfile('licenses.txt')],
   outs = HTML + ['licenses.html'],
   deps = DOCUMENTATION_DEPS,
   attributes = documentation_attributes(git_describe()),
-  backend = 'xhtml11',
+  backend = 'html5',
 )
 
 genrule(
diff --git a/Documentation/asciidoc.defs b/Documentation/asciidoc.defs
index 694d6b5..8279847 100644
--- a/Documentation/asciidoc.defs
+++ b/Documentation/asciidoc.defs
@@ -21,7 +21,7 @@
     visibility = []):
   EXPN = '.expn'
 
-  asciidoc = ['asciidoc']
+  asciidoc = ['$(exe //lib/asciidoctor:asciidoc)']
   if backend:
     asciidoc.extend(['-b', backend])
   for attribute in attributes:
@@ -52,7 +52,10 @@
       name = out,
       cmd = ' '.join(asciidoc + ['$SRCDIR/' + ex]),
       srcs = [genfile(ex)] + [genfile(n + EXPN) for n in dep],
-      deps = [':' + ex] + [':' + n + EXPN for n in dep],
+      deps = [':' + n + EXPN for n in dep] + [
+        ':' + ex,
+        '//lib/asciidoctor:asciidoc',
+      ],
       out = out,
       visibility = visibility,
     )
diff --git a/Documentation/config.defs b/Documentation/config.defs
index af5c729..28dd2c8 100644
--- a/Documentation/config.defs
+++ b/Documentation/config.defs
@@ -13,5 +13,7 @@
     'startsb="["',
     'endsb="]"',
     'tilde="~"',
-    'revision="%s"' % revision,
+    'source-highlighter=prettify',
+    'stylesheet=doc.css',
+    'revnumber="%s"' % revision,
   ]
diff --git a/Documentation/doc.css b/Documentation/doc.css
new file mode 100644
index 0000000..3e226fe
--- /dev/null
+++ b/Documentation/doc.css
@@ -0,0 +1,37 @@
+body {
+  margin: 1em;
+}
+
+#toctitle {
+  margin-top: 0.5em;
+  font-weight: bold;
+}
+
+h1, h2, h3, h4, h5, h6, #toctitle {
+  color: #527bbd;
+  font-family: sans-serif;
+}
+
+h1, h2, h3 {
+  border-bottom: 2px solid silver;
+}
+
+p {
+  margin: 0.5em 0 0.5em 0;
+}
+li p {
+  margin: 0.2em 0 0.2em 0;
+}
+
+pre {
+  border: 2px solid silver;
+  background: #ebebeb;
+  margin-left: 2em;
+  width: 100em;
+  color: darkgreen;
+  padding: 2px;
+}
+
+dl dt {
+  margin-top: 1em;
+}
diff --git a/lib/asciidoctor/BUCK b/lib/asciidoctor/BUCK
new file mode 100644
index 0000000..25b9eb8
--- /dev/null
+++ b/lib/asciidoctor/BUCK
@@ -0,0 +1,39 @@
+include_defs('//lib/maven.defs')
+
+java_binary(
+  name = 'asciidoc',
+  main_class = 'org.asciidoctor.cli.AsciidoctorInvoker',
+  deps = [':asciidoctor'],
+  visibility = ['PUBLIC'],
+)
+
+maven_jar(
+  name = 'asciidoctor',
+  id = 'org.asciidoctor:asciidoctor-java-integration:0.1.3',
+  sha1 = '5cf21b4331d737ef0f3b3f543a7e5a343c1f27ec',
+  license = 'Apache2.0',
+  visibility = [],
+  attach_source = False,
+  deps = [
+    ':jcommander',
+    ':jruby',
+  ],
+)
+
+maven_jar(
+  name = 'jcommander',
+  id = 'com.beust:jcommander:1.30',
+  sha1 = 'c440b30a944ba199751551aee393f8aa03b3c327',
+  license = 'Apache2.0',
+  visibility = [],
+  attach_source = False,
+)
+
+maven_jar(
+  name = 'jruby',
+  id = 'org.jruby:jruby-complete:1.7.4',
+  sha1 = '74984d84846523bd7da49064679ed1ccf199e1db',
+  license = 'DO_NOT_DISTRIBUTE',
+  visibility = [],
+  attach_source = False,
+)