From 21033790be355b87286ac746a44418a565821f43 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 16 Aug 2022 15:07:19 -0700 Subject: [PATCH] add parameter documentation to nightly --- doc/mk_params_doc.py | 64 ++++++++++++++++++++++++++++++++++++++++++++ doc/parameterhelp.py | 30 --------------------- scripts/nightly.yaml | 1 + 3 files changed, 65 insertions(+), 30 deletions(-) create mode 100644 doc/mk_params_doc.py delete mode 100644 doc/parameterhelp.py diff --git a/doc/mk_params_doc.py b/doc/mk_params_doc.py new file mode 100644 index 000000000..cc4354f84 --- /dev/null +++ b/doc/mk_params_doc.py @@ -0,0 +1,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 = [] + if out != None: + out = out.decode(sys.stdout.encoding) + 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.stdout.encoding) + 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) diff --git a/doc/parameterhelp.py b/doc/parameterhelp.py deleted file mode 100644 index 3edf9793e..000000000 --- a/doc/parameterhelp.py +++ /dev/null @@ -1,30 +0,0 @@ - -import subprocess -import sys -import re - -Z3_EXE = "z3.exe" - -def help(ous): - - ous.write("Z3 Options\n") - out = subprocess.Popen([Z3_EXE, "-pm"],stdout=subprocess.PIPE).communicate()[0] - modules = [] - if out != None: - out = out.decode(sys.stdout.encoding) - 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.stdout.encoding) - out = out.replace("\r","") - ous.write(out) - -with open("Parameters.md",'w') as ous: - help(ous) diff --git a/scripts/nightly.yaml b/scripts/nightly.yaml index d935d9d89..ad81b4d4b 100644 --- a/scripts/nightly.yaml +++ b/scripts/nightly.yaml @@ -76,6 +76,7 @@ stages: eval `opam config env` cd doc python mk_api_doc.py --mld --z3py-package-path=../build/python/z3 + python mk_params_doc.py mkdir api/html/ml ocamldoc -html -d api/html/ml -sort -hide Z3 -I $( ocamlfind query zarith ) -I ../build/api/ml ../build/api/ml/z3enums.mli ../build/api/ml/z3.mli cd ..