From 1bfb51d524ef55b6257d26911b8377998af09aae Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 5 Sep 2013 11:44:11 -0700 Subject: [PATCH] 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 --- Documentation/BUCK | 11 ++++++++++- Documentation/asciidoc.defs | 7 +++++-- Documentation/config.defs | 4 +++- Documentation/doc.css | 37 +++++++++++++++++++++++++++++++++++ lib/asciidoctor/BUCK | 39 +++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 Documentation/doc.css create mode 100644 lib/asciidoctor/BUCK diff --git a/Documentation/BUCK b/Documentation/BUCK index b1a8220212..faa2553025 100644 --- a/Documentation/BUCK +++ b/Documentation/BUCK @@ -20,23 +20,32 @@ genrule( '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 694d6b5aa6..82798471bf 100644 --- a/Documentation/asciidoc.defs +++ b/Documentation/asciidoc.defs @@ -21,7 +21,7 @@ def genasciidoc( visibility = []): EXPN = '.expn' - asciidoc = ['asciidoc'] + asciidoc = ['$(exe //lib/asciidoctor:asciidoc)'] if backend: asciidoc.extend(['-b', backend]) for attribute in attributes: @@ -52,7 +52,10 @@ def genasciidoc( 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 af5c7295cd..28dd2c81ce 100644 --- a/Documentation/config.defs +++ b/Documentation/config.defs @@ -13,5 +13,7 @@ def documentation_attributes(revision): '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 0000000000..3e226fea36 --- /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 0000000000..25b9eb8c40 --- /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, +)