Skip to content

Commit 766f3c6

Browse files
committed
Fixed API doc generation process.
Updated yaml2xml.py. Updated ngx_http_api_module_head.xml. Minor changes and switching to python3. The code isn't compatible with python2 anymore. 1.1. Converting regex strings to raw stings 1.2. decode() the result to str 1.3. Adding workers to pretty_endpoint 1.4. Fixing time format 2.1. Remove closing </module> as it required by yaml/GNUmakefile erroneously introduced in https://hg.nginx.org/nginx.org/rev/8b8f94802f41
1 parent 848a7da commit 766f3c6

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

xml/en/docs/http/ngx_http_api_module_head.xml

-1
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,3 @@ were added in <link id="api_version">version</link> 2.
304304

305305
</section>
306306

307-
</module>

yaml/yaml2xml.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,29 @@ def node_description(node):
2222
return ""
2323

2424
#
25-
t = re.sub('\<code\>', r'<literal>', text)
26-
t = re.sub('\</code\>', r'</literal>', t)
25+
t = re.sub(r'\<code\>', r'<literal>', text)
26+
t = re.sub(r'\</code\>', r'</literal>', t)
2727

28-
t = re.sub('\<i\>', r'<value>', t)
29-
t = re.sub('\</i\>', r'</value>', t)
28+
t = re.sub(r'\<i\>', r'<value>', t)
29+
t = re.sub(r'\</i\>', r'</value>', t)
3030

31-
t = re.sub('\<a href=\"(.*?)\"\>(.*?)\</a\>', r'<link url="\1">\2</link>', t)
31+
t = re.sub(r'\<a href=\"(.*?)\"\>(.*?)\</a\>', r'<link url="\1">\2</link>', t)
3232

3333
# [desc](url)
34-
t = re.sub('\[(.*)\]\((.*?)\)', r'<link url="\2">\1</link>', t)
34+
t = re.sub(r'\[(.*)\]\((.*?)\)', r'<link url="\2">\1</link>', t)
3535

3636
# ** foo ** is value
37-
t = re.sub('[*?][*?](\w+)[*?][*?]', r'<value>\1</value>', t)
37+
t = re.sub(r'[*?][*?](\w+)[*?][*?]', r'<value>\1</value>', t)
3838

3939
# * foo * is literal
40-
t = re.sub('[*?](\w+)[*?]', r'<literal>\1</literal>', t)
40+
t = re.sub(r'[*?](\w+)[*?]', r'<literal>\1</literal>', t)
4141

4242

43-
return t.encode('utf-8').rstrip()
43+
return t.encode('utf-8').rstrip().decode()
4444

4545

4646
def pretty_endpoint(ep):
47-
return ep.replace('/slabs/','slabs').replace('/resolvers/','resolvers').replace('/http/','HTTP ').replace('/stream/','stream ').replace('s/','s').replace('_',' ')
47+
return ep.replace('/slabs/','slabs').replace('/resolvers/','resolvers').replace('/http/','HTTP ').replace('/stream/','stream ').replace('/workers/','workers').replace('s/','s').replace('_',' ')
4848

4949

5050
# human-readable html element id based on path
@@ -73,8 +73,8 @@ def multiple(str):
7373
return str + last
7474

7575
def uncamelcase(name):
76-
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
77-
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
76+
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', name)
77+
return re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
7878

7979
def make_defid(str):
8080
return 'def_' + uncamelcase(str)
@@ -395,7 +395,7 @@ def json_simple_type(obj):
395395

396396
elif isinstance(obj,datetime.datetime):
397397
t = obj.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]
398-
z = obj.strftime("Z%Z")
398+
z = obj.strftime("Z")
399399
return '"' + t + z + '"'
400400

401401
else:

0 commit comments

Comments
 (0)