Adding the script

This commit is contained in:
Nicolas Patry 2023-09-27 10:43:12 +00:00
parent 9a3cb6fba8
commit c09eb2f8bf

24
update_doc.py Normal file
View File

@ -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()