diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2024-06-24 15:49:36 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-06-24 15:49:36 +0200 |
commit | f87ad41f72ca4465a0c5b4ba9fd36a7b09e4d4f4 (patch) | |
tree | 24d4a3a5975df2046714c6bc114d5d050bdc61fc /etc/gen_readme.py | |
download | rules-rust-f87ad41f72ca4465a0c5b4ba9fd36a7b09e4d4f4.tar.gz |
Initial commit
Co-authored-by: Klaus Aehlig <klaus.aehlig@huawei.com>
Diffstat (limited to 'etc/gen_readme.py')
-rw-r--r-- | etc/gen_readme.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/etc/gen_readme.py b/etc/gen_readme.py new file mode 100644 index 0000000..66618a3 --- /dev/null +++ b/etc/gen_readme.py @@ -0,0 +1,35 @@ +import json +import os +from typing import List + +def lines(doc:List[str]): + return '\n'.join(doc) + +def gen_doc(dir: str, f): + + with open(os.path.join(dir, "RULES")) as r: + rules = json.load(r) + + for k, v in sorted(rules.items()): + print(f"### `[\"{os.path.basename(dir)}\", \"{k}\"]`\n\n {lines(v['doc'])}\n", file=f) + print("| Field | Description |", file=f) + print("| ----- | ----------- |", file=f) + for field, doc in sorted(v["field_doc"].items()): + print(f"| `\"{field}\"` | {' '.join(doc)} |", file=f) + print(file=f) + + +def main(): + with open("README.md", "w") as f: + print( + """# Rust rules for the [`just`](https://github.com/just-buildsystem/justbuild) build system + +A collection of rules for building Rust libraries, binaries and unit tests. +""", + file=f, + ) + gen_doc("rules/rust", f) + gen_doc("rules/cargo", f) + + +main() |