Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion aws_doc_sdk_examples_tools/doc_gen_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import logging

from .doc_gen import DocGen, DocGenEncoder
from .entities import EntityErrors

logging.basicConfig(level=logging.INFO)

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

parser.add_argument(
"--strict",
Expand Down Expand Up @@ -61,6 +66,20 @@ def main():
with open(args.write_json, "w") as out:
out.write(serialized)

if args.write_snippets:
for root in args.from_root:
merged_doc_gen.collect_snippets(Path(root))

serialized_snippets = json.dumps(
{
"snippets": merged_doc_gen.snippets,
"snippet_files": merged_doc_gen.snippet_files,
},
cls=DocGenEncoder,
)
with open(args.write_snippets, "w") as out:
out.write(serialized_snippets)


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions aws_doc_sdk_examples_tools/doc_gen_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def test_doc_gen_strict_option(strict, should_raise, patched_environment):
mock_args = Namespace(
from_root=["/mock/path"],
write_json="mock_output.json",
write_snippets="",
strict=strict,
skip_entity_expansion=False,
)
Expand All @@ -94,6 +95,7 @@ def test_skip_entity_expansion(patched_environment):
mock_args = Namespace(
from_root=["/mock/path"],
write_json="mock_output.json",
write_snippets="",
strict=False,
skip_entity_expansion=True,
)
Expand All @@ -111,6 +113,7 @@ def test_default_entity_expansion(patched_environment):
mock_args = Namespace(
from_root=["/mock/path"],
write_json="mock_output.json",
write_snippets="",
strict=False,
skip_entity_expansion=False,
)
Expand Down
Loading