mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-23 16:02:10 +00:00
### Broken highlighting (current) <img width="800" alt="Screenshot 2023-09-28 at 22 38 15" src="https://github.com/huggingface/text-generation-inference/assets/11827707/1f07c356-2c3c-4ff0-8ca5-54a032b05d48"> ### Fixed highlighting (this PR) <img width="800" alt="image" src="https://github.com/huggingface/text-generation-inference/assets/11827707/87fe750d-c26e-4801-95cc-86859a2df52d">
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
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"
|
|
)
|
|
wrap_code_blocks_flag = "<!-- WRAP CODE BLOCKS -->"
|
|
final_doc = f"# Text-generation-launcher arguments\n\n{wrap_code_blocks_flag}\n\n```shell\n{output}\n```"
|
|
|
|
filename = "docs/source/basic_tutorials/launcher.md"
|
|
if args.check:
|
|
with open(filename, "r") as f:
|
|
doc = f.read()
|
|
if doc != final_doc:
|
|
tmp = "launcher.md"
|
|
with open(tmp, "w") as g:
|
|
g.write(final_doc)
|
|
diff = subprocess.run(
|
|
["diff", tmp, filename], capture_output=True
|
|
).stdout.decode("utf-8")
|
|
print(diff)
|
|
raise Exception(
|
|
"Doc is not up-to-date, run `python update_doc.py` in order to update it"
|
|
)
|
|
else:
|
|
with open(filename, "w") as f:
|
|
f.write(final_doc)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|