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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from aws_doc_sdk_examples_tools.lliam.domain.commands import DedupeReservoir
from aws_doc_sdk_examples_tools.metadata import Example
from aws_doc_sdk_examples_tools.yaml_writer import prepare_write, write_many
from aws_doc_sdk_examples_tools.project_validator import ValidationConfig

logger = logging.getLogger(__name__)

Expand All @@ -19,7 +20,7 @@ def make_title_abbreviation(example: Example, counter: Counter):


def handle_dedupe_reservoir(cmd: DedupeReservoir, uow: None):
doc_gen = DocGen.from_root(cmd.root)
doc_gen = DocGen.from_root(cmd.root, validation=ValidationConfig(check_aws=False))

examples: Dict[str, Example] = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def run_ailly_single_batch(batch: Path, packages: List[str] = []) -> None:
)


EXPECTED_KEYS: Set[str] = set(["title", "title_abbrev"])
EXPECTED_KEYS: Set[str] = set(["title", "title_abbrev", "synopsis"])
VALUE_PREFIXES: Dict[str, str] = {"title": "", "title_abbrev": "", "synopsis": ""}


Expand Down
1 change: 1 addition & 0 deletions aws_doc_sdk_examples_tools/project_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
@dataclass
class ValidationConfig:
allow_list: Set[str] = field(default_factory=set)
check_aws: bool = True
sample_files: Set[Path] = field(default_factory=set)
strict_titles: bool = False

Expand Down
38 changes: 30 additions & 8 deletions aws_doc_sdk_examples_tools/yaml_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,27 @@ def example_from_yaml(
) -> Tuple[Example, MetadataErrors]:
errors = MetadataErrors()

title = get_with_valid_entities("title", yaml, errors, True)
title_abbrev = get_with_valid_entities("title_abbrev", yaml, errors, True)
synopsis = get_with_valid_entities("synopsis", yaml, errors, opt=True)
title = get_field(
name="title",
d=yaml,
errors=errors,
opt=True,
check_aws=validation.check_aws,
)
title_abbrev = get_field(
name="title_abbrev",
d=yaml,
errors=errors,
opt=True,
check_aws=validation.check_aws,
)
synopsis = get_field(
name="synopsis",
d=yaml,
errors=errors,
opt=True,
check_aws=validation.check_aws,
)
synopsis_list = [str(syn) for syn in yaml.get("synopsis_list", [])]

source_key = yaml.get("source_key")
Expand Down Expand Up @@ -123,16 +141,20 @@ def excerpt_from_yaml(yaml: Any) -> Tuple["Excerpt", MetadataErrors]:
return (Excerpt(description, snippet_tags, snippet_files, genai), errors)


def get_with_valid_entities(
name: str, d: Dict[str, str], errors: MetadataErrors, opt: bool = False
def get_field(
name: str,
d: Dict[str, str],
errors: MetadataErrors,
opt: bool = False,
check_aws=True,
) -> str:
field = d.get(name)
if field is None:
if not opt:
errors.append(metadata_errors.MissingField(field=name))
return ""

checker = StringExtension()
checker = StringExtension(check_aws=check_aws)
if not checker.is_valid(field):
errors.append(
metadata_errors.AwsNotEntity(
Expand Down Expand Up @@ -195,7 +217,7 @@ def parse_services(yaml: Any, errors: MetadataErrors) -> Dict[str, Set[str]]:


def url_from_yaml(
yaml: Union[None, Dict[str, Optional[str]]]
yaml: Union[None, Dict[str, Optional[str]]],
) -> Optional[Union[Url, MetadataParseError]]:
if yaml is None:
return None
Expand All @@ -209,7 +231,7 @@ def url_from_yaml(


def person_from_yaml(
yaml: Union[None, Dict[str, Optional[str]]]
yaml: Union[None, Dict[str, Optional[str]]],
) -> Optional[Union[Person, MetadataParseError]]:
if yaml is None:
return None
Expand Down