From c09eb2f8bf17f97c7990fdeb7f58fd816d79f195 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 27 Sep 2023 10:43:12 +0000 Subject: [PATCH] Adding the script --- update_doc.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 update_doc.py diff --git a/update_doc.py b/update_doc.py new file mode 100644 index 00000000..cb6dc737 --- /dev/null +++ b/update_doc.py @@ -0,0 +1,24 @@ +import subprocess +import argparse + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--check", action="store_true") + + args = parser.parse_args() + + output = subprocess.check_output(["text-generation-launcher", "--help"]).decode("utf-8") + final_doc = f"```\n{output}\n```" + + if args.check: + with open("docs/source/basic_tutorials/launcher.md", "r") as f: + doc = f.read() + if doc != final_doc: + raise Exception("Doc is not up-to-date, run `python update_doc.py` in order to update it") + else: + with open("docs/source/basic_tutorials/launcher.md", "w") as f: + f.write(final_doc) + +if __name__ == "__main__": + main()