Skip to content

Commit 277ee79

Browse files
committed
doc_gen_cli collects and stores snippets in a second file
1 parent 52e617d commit 277ee79

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

aws_doc_sdk_examples_tools/doc_gen_cli.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import logging
88

99
from .doc_gen import DocGen, DocGenEncoder
10-
from .entities import EntityErrors
1110

1211
logging.basicConfig(level=logging.INFO)
1312

@@ -28,6 +27,12 @@ def main():
2827
type=str,
2928
help="Output a JSON version of the computed DocGen with some properties stripped out. Includes any errors.",
3029
)
30+
parser.add_argument(
31+
"--write-snippets",
32+
default="doc_gen_snippets.json",
33+
type=str,
34+
help="Output a JSON version of the computed DocGen with only snippets and snippet files. Separates snippet content from metadata content.",
35+
)
3136

3237
parser.add_argument(
3338
"--strict",
@@ -61,6 +66,19 @@ def main():
6166
with open(args.write_json, "w") as out:
6267
out.write(serialized)
6368

69+
for root in args.from_root:
70+
merged_doc_gen.collect_snippets(Path(root))
71+
72+
serialized_snippets = json.dumps(
73+
{
74+
"snippets": merged_doc_gen.snippets,
75+
"snippet_files": merged_doc_gen.snippet_files,
76+
},
77+
cls=DocGenEncoder,
78+
)
79+
with open(args.write_snippets, "w") as out:
80+
out.write(serialized_snippets)
81+
6482

6583
if __name__ == "__main__":
6684
main()

0 commit comments

Comments
 (0)