Added handler of title in get:: macro.
This fixes part of issue 2159. Change-Id: I32cba156b0e981ae259d610cc60e515ef83b571b
This commit is contained in:
parent
1967003e31
commit
71acd111f4
@ -20,6 +20,8 @@ import sys
|
||||
PAT_GERRIT = re.compile(r'^GERRIT')
|
||||
PAT_INCLUDE = re.compile(r'^(include::.*)(\[\])$')
|
||||
PAT_GET = re.compile(r'^get::([^ \t\n]*)')
|
||||
PAT_TITLE = re.compile(r'^\.(.*)')
|
||||
PAT_STARS = re.compile(r'^\*\*\*\*')
|
||||
|
||||
GERRIT_UPLINK = """
|
||||
|
||||
@ -31,18 +33,25 @@ GERRIT_UPLINK = """
|
||||
margin-bottom: 0.5em;
|
||||
\">
|
||||
++++
|
||||
|
||||
"""
|
||||
|
||||
GET_TITLE = '<div class="title">%s</div>'
|
||||
|
||||
GET_MACRO = """
|
||||
|
||||
++++
|
||||
%s
|
||||
<div class="content monospaced">
|
||||
<a id=\"{0}\" onmousedown="javascript:
|
||||
var i = document.URL.lastIndexOf(\'/Documentation/\');
|
||||
var url = document.URL.substring(0, i) + \'{0}\';
|
||||
document.getElementById(\'{0}\').href = url;">
|
||||
GET {0} HTTP/1.0
|
||||
</a>
|
||||
</div>
|
||||
++++
|
||||
|
||||
"""
|
||||
|
||||
opts = OptionParser()
|
||||
@ -56,6 +65,7 @@ try:
|
||||
src_file = open(options.src, 'r')
|
||||
last_line = ''
|
||||
ignore_next_line = False
|
||||
last_title = ''
|
||||
for line in src_file.xreadlines():
|
||||
if PAT_GERRIT.match(last_line):
|
||||
# Case of "GERRIT\n------" at the footer
|
||||
@ -66,10 +76,18 @@ try:
|
||||
match = PAT_INCLUDE.match(line)
|
||||
out_file.write(last_line)
|
||||
last_line = match.group(1) + options.suffix + match.group(2) + '\n'
|
||||
elif PAT_STARS.match(line):
|
||||
if PAT_TITLE.match(last_line):
|
||||
# Case of the title in '.<title>\n****\nget::<url>\n****'
|
||||
match = PAT_TITLE.match(last_line)
|
||||
last_title = GET_TITLE % match.group(1)
|
||||
else:
|
||||
out_file.write(last_line)
|
||||
last_title = ''
|
||||
elif PAT_GET.match(line):
|
||||
# Case of '****\nget::<url>\n****' in rest api
|
||||
url = PAT_GET.match(line).group(1)
|
||||
out_file.write(GET_MACRO.format(url))
|
||||
out_file.write(GET_MACRO.format(url) % last_title)
|
||||
ignore_next_line = True
|
||||
elif ignore_next_line:
|
||||
# Handle the trailing '****' of the 'get::' case
|
||||
|
Loading…
Reference in New Issue
Block a user