-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validator: Re-enable yamale validator. (#124)
* Re-enable yamale validator. * Update relaxed schema and use it for tributaries by using strict_titles arg to control strict schema. * Allow bare AWS within code-style XML tags. * Write unit tests for yamale validation.
- Loading branch information
Showing
8 changed files
with
153 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,43 @@ | ||
# Yamale Schema for example metadata, which is all .yaml files in the metadata folder | ||
# with a _metadata.yaml suffix. | ||
|
||
map(include('example'), key=example_id()) | ||
map(include('example'), key=str()) | ||
--- | ||
# An example blocks all the languages together for a single example in a tab list. It is a navigable page on the code examples library. It is the top level "unit" of SoS content. This metadata is merged from tributaries with aws-doc-sdk-examples. | ||
example: | ||
# Human readable title. TODO: Defaults to slug-to-title of the ID if not provided. Overwritten by aws-doc-sdk-example when merging. | ||
title: str(upper_start=True, no_end_punc=True, required=False) | ||
# Used in the TOC. TODO: Defaults to slug-to-title of the ID if not provided. Overwritten by aws-doc-sdk-example when merging. | ||
title_abbrev: str(upper_start=True, no_end_punc=True, required=False) | ||
# String label categories. Categories inferred by cross-service with multiple services, and can be whatever else it wants. Controls where in the TOC it appears. Overwritten by aws-doc-sdk-example when merging. | ||
category: str(upper_start=True, no_end_punc=True, required=False) | ||
# Link to additional topic places. Overwritten by aws-doc-sdk-example when merging. | ||
guide_topic: include('guide_topic', required=False) # TODO Make this a list or a single. | ||
# TODO how to add a language here and require it in sdks_schema. TODO: Keys merged by aws-doc-sdk-example when merging. | ||
languages: map(include('language'), key=enum('Bash', 'C++', 'CLI', 'Go', 'Java', 'JavaScript', 'Kotlin', '.NET', 'PHP', 'Python', 'Ruby', 'Rust', 'SAP ABAP', 'Swift')) | ||
# TODO document service_main and services. Not to be used by tributaries. Part of Cross Service. | ||
# List of services used by the examples. Lines up with those in services.yaml. Overwritten by aws-doc-sdk-example when merging. | ||
title: str(required=False, upper_start=True, no_end_punc=True) | ||
title_abbrev: str(required=False, upper_start=True, no_end_punc=True) | ||
synopsis: str(required=False) | ||
synopsis_list: list(str(upper_start=True), required=False) | ||
category: str(required=False, upper_start=True, no_end_punc=True) | ||
guide_topic: include('guide_topic', required=False) | ||
languages: map(include('language'), key=enum('Bash', 'C++', 'CLI', 'Go', 'Java', 'JavaScript', 'Kotlin', '.NET', 'PHP', 'PowerShell', 'Python', 'Ruby', 'Rust', 'SAP ABAP', 'Swift')) | ||
service_main: service_name(required=False) | ||
services: map(map(key=str(), required=False), key=service_name()) | ||
synopsis: str(required=False, lower_start=True, end_punc_or_semicolon=True, required=False) | ||
synopsis_list: list(str(upper_start=True, end_punc=True), required=False) | ||
services: map(key=service_name()) | ||
|
||
# Used for creating links in the block. | ||
guide_topic: | ||
title: str(upper_start=True, no_end_punc=True) | ||
url: include('doc_url', required=False) | ||
|
||
# Language Version configuration. Likely just the single list item. | ||
language: | ||
versions: list(include('version')) | ||
|
||
# Example for a single Language. | ||
# Per-language excerpts for the example. Languages and SDK versions are defined in .doc_gen/metadata/sdk_metadata.yaml | ||
version: | ||
sdk_version: int(min=1) | ||
# Additional ZonBook XML to include in the tab for this sample. | ||
block_content: block_content(required=False) | ||
# The specific code samples to include in the example. | ||
excerpts: list(include('excerpt'), required=False) | ||
# Link to the source code for this example. TODO rename. | ||
sdk_version: any(int(min=1), str(check_aws=False)) | ||
github: str(required=False) | ||
github_name: str(required=False) | ||
github_note_at_bottom: bool(required=False) | ||
add_services: map(key=service_name(), required=False) | ||
# Deprecated. Replace with guide_topic list. | ||
sdkguide: include('doc_url', required=False) | ||
# Link to additional topic places. TODO: Overwritten by aws-doc-sdk-example when merging. | ||
more_info: list(include('guide_topic', required=False)) | ||
excerpts: list(include('excerpt'), required=False) | ||
block_content: block_content(required=False) | ||
add_services: map(key=service_name(), required=False) | ||
|
||
# One language example can have several excerpts, each having a description block and one or more snippets. | ||
# An excerpt may have either snippet_files OR snippet_tags, but not both. | ||
# The references to code content that will be included in the example's content. | ||
excerpt: | ||
description: str(required=False, upper_start=True, end_punc=True) | ||
# A path within the repo to extract the entire file as a snippet. | ||
snippet_files: list(str(), required=False) | ||
# Tags embedded in source files to extract as snippets. | ||
description: str(required=False) | ||
genai: enum('none', 'some', 'most', 'all', required=False) | ||
snippet_tags: list(str(), required=False) | ||
snippet_files: list(str(), required=False) | ||
|
||
service_slug_regex: regex('^[-a-z0-9]+$', name='service slug') | ||
doc_url: regex('^(?!https://docs.aws.amazon.com/).+', name="relative documentation URL") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from .metadata_errors import MetadataErrors | ||
from .metadata_validator import validate_metadata | ||
|
||
|
||
@pytest.mark.parametrize("strict", [True, False]) | ||
def test_aws_entity_usage(strict): | ||
errors = MetadataErrors() | ||
validate_metadata( | ||
Path(Path(__file__).parent / "test_resources/doc_gen_test"), strict, errors | ||
) | ||
|
||
e_str = str(errors) | ||
assert "Title has AWS" in e_str | ||
assert "Title Abbrev has AWS" in e_str | ||
assert "Synopsis has AWS" in e_str | ||
assert "Synopsis list has AWS" in e_str | ||
assert "Description has AWS" in e_str | ||
|
||
assert "Title has &AWS;" not in e_str | ||
assert "Title Abbrev has &AWS;" not in e_str | ||
assert "Synopsis programlisting has AWS" not in e_str | ||
assert "Synopsis list code has <code>AWS" not in e_str | ||
assert "Description programlisting has AWS" not in e_str |
38 changes: 38 additions & 0 deletions
38
...sdk_examples_tools/test_resources/doc_gen_test/.doc_gen/metadata/aws_entity_metadata.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
sns_EntityFailures: | ||
title: Title has AWS using an &AWS; SDK | ||
title_abbrev: Title Abbrev has AWS in it | ||
synopsis: "Synopsis has AWS in it." | ||
synopsis_list: | ||
- "Synopsis list has AWS in it." | ||
category: Cat | ||
languages: | ||
Java: | ||
versions: | ||
- sdk_version: 1 | ||
github: java/example_code/svc_EntityFailures | ||
sdkguide: | ||
excerpts: | ||
- description: Description has AWS in it. | ||
snippet_tags: | ||
- java.example_code.svc_EntityFailures.Test | ||
services: | ||
sns: | ||
sns_EntitySuccesses: | ||
title: Title has &AWS; using an &AWS; SDK | ||
title_abbrev: Title Abbrev has &AWS; in it | ||
synopsis: "this <programlisting>Synopsis programlisting has AWS in it.</programlisting>." | ||
synopsis_list: | ||
- "Synopsis list code has <code>AWS</code> in it." | ||
category: Cat | ||
languages: | ||
Java: | ||
versions: | ||
- sdk_version: 1 | ||
github: java/example_code/svc_EntityFailures | ||
sdkguide: | ||
excerpts: | ||
- description: This <emphasis><programlisting>Description programlisting has AWS in it</programlisting></emphasis> doesn't it. | ||
snippet_tags: | ||
- java.example_code.svc_EntityFailures.Test | ||
services: | ||
sns: |