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
7 changes: 5 additions & 2 deletions aws_doc_sdk_examples_tools/doc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,14 @@ def for_root(
pass

if not incremental:
for path in metadata.glob("*_metadata.yaml"):
self.process_metadata(path)
self.find_and_process_metadata(metadata)

return self

def find_and_process_metadata(self, metadata_path: Path):
for path in metadata_path.glob("*_metadata.yaml"):
self.process_metadata(path)

def process_metadata(self, path: Path) -> "DocGen":
if path in self._loaded:
return self
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
IAMPolicy:
property: json
syntax: json
sdk:
1:
long: "IAM policy"
short: "IAM policy"
guide: "IAM/latest/UserGuide/introduction.html"
api_ref:
uid: "IAMPolicy"
name: "&SAZR;"
link_template: "SomeTemplate"
guide: "&guide-iam-user;"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sts_CustomSdkExample:
title: This example uses an SDK from the tributary config
title_abbrev: This example uses an SDK from the tributary config
synopsis: allow a user to assume any role in your account with the access- name prefix. The role must also be tagged with the same project, team, and cost center tags as the user.
category: IAMPolicyCategory
languages:
IAMPolicy:
versions:
- sdk_version: 1
excerpts:
- description: test
services:
sts: {AssumeRole}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sts_RootSdkExample:
title: This example uses an SDK from the root config
title_abbrev: This example uses an SDK from the root config
synopsis: allow a user to assume any role in your account with the access- name prefix. The role must also be tagged with the same project, team, and cost center tags as the user.
category: IAMPolicyCategory
languages:
Python:
versions:
- sdk_version: 3
excerpts:
- description: test
services:
sts: {AssumeRole}
29 changes: 18 additions & 11 deletions aws_doc_sdk_examples_tools/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,35 @@ def main():
)
args = parser.parse_args()
root_path = Path(args.root).resolve()
config_path = Path(args.config).resolve() if args.config else None
return validate(root_path, config_path, args.strict_titles, args.doc_gen_only)

if args.config:
config_path = Path(args.config).resolve()

def validate(
root_path: Path, config_path: Path, strict: bool, doc_gen_only: bool
) -> int:
if config_path is not None:
doc_gen = DocGen.default()
doc_gen.merge(
DocGen.from_root(
root=root_path,
validation=ValidationConfig(strict_titles=args.strict_titles),
config=config_path,
)
doc_gen_local = DocGen.from_root(
root=root_path,
validation=ValidationConfig(strict_titles=strict),
config=config_path,
incremental=True,
)
doc_gen.merge(doc_gen_local)
doc_gen.root = root_path
doc_gen.errors = doc_gen_local.errors
metadata = doc_gen.root / ".doc_gen/metadata"
doc_gen.find_and_process_metadata(metadata)
else:
doc_gen = DocGen.from_root(
root=root_path,
validation=ValidationConfig(strict_titles=args.strict_titles),
config=args.config,
validation=ValidationConfig(strict_titles=strict),
)

doc_gen.collect_snippets(snippets_root=root_path)
doc_gen.validate()
if not args.doc_gen_only:
if not doc_gen_only:
check_files(doc_gen.root, doc_gen.validation, doc_gen.errors)
verify_sample_files(doc_gen.root, doc_gen.validation, doc_gen.errors)

Expand Down
16 changes: 16 additions & 0 deletions aws_doc_sdk_examples_tools/validate_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

"""
Test for validate.
"""

from pathlib import Path

from .validate import validate


def test_validate():
root_path = Path(__file__).parent / "test_resources" / "doc_gen_tributary_test"
error_count = validate(root_path, root_path / ".doc_gen/config", False, False)
assert error_count == 0
Loading