forked from Z3Prover/z3
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmk_params_doc.py
64 lines (55 loc) · 1.73 KB
/
mk_params_doc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (c) Microsoft Corporation 2015
"""
Z3 API documentation for parameters
"""
import argparse
import subprocess
import sys
import re
import os
BUILD_DIR='../build'
OUTPUT_DIRECTORY=os.path.join(os.getcwd(), 'api')
def parse_options():
global BUILD_DIR, OUTPUT_DIRECTORY
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-b',
'--build',
default=BUILD_DIR,
help='Directory where Z3 is built (default: %(default)s)',
)
parser.add_argument('--output-dir',
dest='output_dir',
default=OUTPUT_DIRECTORY,
help='Path to output directory (default: %(default)s)',
)
pargs = parser.parse_args()
BUILD_DIR = pargs.build
OUTPUT_DIRECTORY = pargs.output_dir
def help(ous):
global BUILD_DIR
ous.write("Z3 Options\n")
z3_exe = BUILD_DIR + "/z3"
out = subprocess.Popen([z3_exe, "-pm"],stdout=subprocess.PIPE).communicate()[0]
modules = ["global"]
if out != None:
out = out.decode(sys.getdefaultencoding())
module_re = re.compile(r"\[module\] (.*)\,")
lines = out.split("\n")
for line in lines:
m = module_re.search(line)
if m:
modules += [m.group(1)]
for module in modules:
out = subprocess.Popen([z3_exe, "-pmmd:%s" % module],stdout=subprocess.PIPE).communicate()[0]
if out == None:
continue
out = out.decode(sys.getdefaultencoding())
out = out.replace("\r","")
ous.write(out)
parse_options()
def mk_dir(d):
if not os.path.exists(d):
os.makedirs(d)
mk_dir(os.path.join(OUTPUT_DIRECTORY, 'md'))
with open(OUTPUT_DIRECTORY + "/md/Parameters.md",'w') as ous:
help(ous)