Embed client and server release numbers

Note that this also removes the changelog - I'm going to re-add the
changelog differently soon.
This commit is contained in:
Daniel Wagner-Hall 2015-12-01 17:02:23 +00:00
parent bcead3b0a5
commit 97fd1fdd62
6 changed files with 73 additions and 42 deletions

View file

@ -250,7 +250,7 @@ def addAnchors(path):
f.write(line + "\n")
def run_through_template(input, set_verbose):
def run_through_template(input, set_verbose, substitutions):
tmpfile = './tmp/output'
try:
with open(tmpfile, 'w') as out:
@ -260,6 +260,9 @@ def run_through_template(input, set_verbose):
"-o", "../scripts/tmp",
"../scripts/"+input
]
for k, v in substitutions.items():
args.append("--substitution=%s=%s" % (k, v))
if set_verbose:
args.insert(2, "-v")
log("EXEC: %s" % " ".join(args))
@ -392,7 +395,7 @@ def cleanup_env():
shutil.rmtree("./tmp")
def main(requested_target_name, keep_intermediates):
def main(requested_target_name, keep_intermediates, substitutions):
prepare_env()
log("Building spec [target=%s]" % requested_target_name)
@ -407,7 +410,7 @@ def main(requested_target_name, keep_intermediates):
target = get_build_target("../specification/targets.yaml", target_name)
build_spec(target=target, out_filename=templated_file)
run_through_template(templated_file, VERBOSE)
run_through_template(templated_file, VERBOSE, substitutions)
fix_relative_titles(
target=target, filename=templated_file,
out_filename=rst_file,
@ -417,13 +420,21 @@ def main(requested_target_name, keep_intermediates):
if requested_target_name == "all":
shutil.copy("../supporting-docs/howtos/client-server.rst", "tmp/howto.rst")
run_through_template("tmp/howto.rst", False) # too spammy to mark -v on this
run_through_template("tmp/howto.rst", False, substitutions) # too spammy to mark -v on this
rst2html("tmp/howto.rst", "gen/howtos.html")
if not keep_intermediates:
cleanup_env()
def extract_major(s):
major_version = s
match = re.match("^(r\d)+(\.\d+)?$", s)
if match:
major_version = match.group(1)
return major_version
if __name__ == '__main__':
parser = ArgumentParser(
"gendoc.py - Generate the Matrix specification as HTML to the gen/ folder."
@ -441,9 +452,23 @@ if __name__ == '__main__':
"--verbose", "-v", action="store_true",
help="Turn on verbose mode."
)
parser.add_argument(
"--client_release", "-c", action="store", default="unstable",
help="The client-server release tag to generate, e.g. r1.2"
)
parser.add_argument(
"--server_release", "-s", action="store", default="unstable",
help="The server-server release tag to generate, e.g. r1.2"
)
args = parser.parse_args()
if not args.target:
parser.print_help()
sys.exit(1)
VERBOSE = args.verbose
main(args.target, args.nodelete)
substitutions = {
"%CLIENT_RELEASE_LABEL%": args.client_release,
"%CLIENT_MAJOR_VERSION%": extract_major(args.client_release),
"%SERVER_RELEASE_LABEL%": args.server_release,
"%SERVER_MAJOR_VERSION%": extract_major(args.server_release),
}
main(args.target, args.nodelete, substitutions)

View file

@ -4,6 +4,17 @@
# It takes all of the swagger YAML files for the client-server API, and turns
# them into API docs, with none of the narrative found in the rst files which
# normally wrap these API docs.
#
# Optionally takes one positional argument, the label of the release, e.g. r1.2.
# This falls back to "unstable" if unspecified.
if [[ $# == 1 ]]; then
client_release=$1
else
client_release="unstable"
fi
client_major_version="$(echo "${client_release}" | perl -pe 's/^(r\d+)\..*$/$1/g')"
cd "$(dirname $0)"
@ -23,5 +34,5 @@ for f in ../api/client-server/*.yaml; do
echo "{{${f/-/_}}}" >> tmp/http_apis
done
(cd ../templating ; python build.py -i matrix_templates -o ../scripts/gen ../scripts/tmp/http_apis)
(cd ../templating ; python build.py -i matrix_templates -o ../scripts/gen ../scripts/tmp/http_apis --substitution=%CLIENT_RELEASE_LABEL%="${client_release}" --substitution=%CLIENT_MAJOR_VERSION%="${client_major_version}")
rst2html.py --stylesheet-path=$(echo css/*.css | tr ' ' ',') gen/http_apis > gen/http_apis.html