|
| 1 | +from argparse import ArgumentParser |
1 | 2 | from collections import defaultdict |
2 | 3 | from dataclasses import asdict |
3 | 4 | from pathlib import Path |
4 | 5 | from typing import Any, DefaultDict, Dict, List |
| 6 | + |
| 7 | +import logging |
5 | 8 | import yaml |
6 | 9 |
|
7 | 10 | from aws_doc_sdk_examples_tools.doc_gen import DocGen |
8 | 11 | from aws_doc_sdk_examples_tools.metadata import Example |
9 | 12 |
|
| 13 | +logging.basicConfig(level=logging.INFO) |
| 14 | + |
| 15 | +logger = logging.getLogger(__file__) |
| 16 | + |
10 | 17 |
|
11 | 18 | def write_many(root: Path, to_write: Dict[str, str]): |
12 | 19 | for path, examples in to_write.items(): |
@@ -104,11 +111,22 @@ def excerpt_dict(excerpt: Dict) -> Dict: |
104 | 111 | return reordered |
105 | 112 |
|
106 | 113 |
|
107 | | -# For testing |
108 | | -if __name__ == "__main__": |
109 | | - doc_gen = DocGen.from_root( |
110 | | - Path(__file__).parent / "test_resources" / "doc_gen_test" |
| 114 | +def main(): |
| 115 | + parser = ArgumentParser( |
| 116 | + description="Build a DocGen instance and normalize the metadata." |
111 | 117 | ) |
| 118 | + parser.add_argument("root", type=str, help="The root of a DocGen project") |
| 119 | + |
| 120 | + args = parser.parse_args() |
| 121 | + root = Path(args.root) |
| 122 | + |
| 123 | + if not root.is_dir(): |
| 124 | + logger.error(f"Expected {root} to be a directory.") |
| 125 | + |
| 126 | + doc_gen = DocGen.from_root(root) |
112 | 127 | writes = prepare_write(doc_gen.examples) |
113 | | - write_many(Path("/"), writes) |
114 | | - # print(writes) |
| 128 | + write_many(root, writes) |
| 129 | + |
| 130 | + |
| 131 | +if __name__ == "__main__": |
| 132 | + main() |
0 commit comments