Cleanups in gen_licenses.py

Changes include:

- Using asciidoctor's heading style

- (Issue 4424) Add extra \n before closing blockquote so that an
imported LICENSE file without \n at the end won't screw up the rest of
the file

- Change the license anchor to something more distinguishable

- Use '----' instead of '[verse]\n--' for license blockquote, as we have
some hack inside lib/LICENSE-prologcafe using '----' as blockquote.
We could also just change lib/LICENSE-prologcafe file to use '--'
instead, but I feel under asciidoctor's default css, '----' blockquotes
has a slightly grey background, which is easier to read.

Change-Id: I8260c47ffa66cd303b97f78c590cdfd97a8626d4
This commit is contained in:
Yuxuan 'fishy' Wang 2016-08-22 15:46:24 -07:00 committed by David Pursehouse
parent 4feb667bf7
commit 13737a286a

View File

@ -95,16 +95,14 @@ used = sorted(licenses.keys())
if args.asciidoc: if args.asciidoc:
print("""\ print("""\
Gerrit Code Review - Licenses = Gerrit Code Review - Licenses
=============================
Gerrit open source software is licensed under the <<Apache2_0,Apache Gerrit open source software is licensed under the <<Apache2_0,Apache
License 2.0>>. Executable distributions also include other software License 2.0>>. Executable distributions also include other software
components that are provided under additional licenses. components that are provided under additional licenses.
[[cryptography]] [[cryptography]]
Cryptography Notice == Cryptography Notice
-------------------
This distribution includes cryptographic software. The country This distribution includes cryptographic software. The country
in which you currently reside may have restrictions on the import, in which you currently reside may have restrictions on the import,
@ -139,8 +137,7 @@ and/or the
link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API] link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API]
to be installed by the end-user. to be installed by the end-user.
Licenses == Licenses
--------
""") """)
for n in used: for n in used:
@ -149,13 +146,13 @@ for n in used:
if args.asciidoc: if args.asciidoc:
print() print()
print('[[%s]]' % name.replace('.', '_')) print('[[%s]]' % name.replace('.', '_'))
print(name) print("=== " + name)
print('~' * len(name))
print() print()
else: else:
print() print()
print(name) print(name)
print('--') print()
print('----')
for d in libs: for d in libs:
if d.startswith('//lib:') or d.startswith('//lib/'): if d.startswith('//lib:') or d.startswith('//lib/'):
p = d[len('//lib:'):] p = d[len('//lib:'):]
@ -166,12 +163,12 @@ for n in used:
print('* ' + p) print('* ' + p)
if args.asciidoc: if args.asciidoc:
print() print()
print('[[license]]') print('[[%s_license]]' % name.replace('.', '_'))
print('[verse]') print('----')
print('--')
with open(n[2:].replace(':', '/')) as fd: with open(n[2:].replace(':', '/')) as fd:
copyfileobj(fd, stdout) copyfileobj(fd, stdout)
print('--') print()
print('----')
if args.asciidoc: if args.asciidoc:
print(""" print("""