generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 16
Validator: Re-enable yamale validator. #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5ca3893
Re-enable yamale validator.
Laren-AWS d27a84f
Update relaxed schema and use it for tributaries.
Laren-AWS 8f94d5c
Another update to work with existing tributary metadata.
Laren-AWS 1e506e1
Fix type switching issue.
Laren-AWS e40c7a4
Allows bare AWS within code-style XML tags.
Laren-AWS 3471036
Wrap strings for XML checks so they're always valid XML.
Laren-AWS fab7ba5
Do an actual full tree search for blocks.
Laren-AWS 6a1c378
Write unit tests for yamale validation, use strict_titles arg to cont…
Laren-AWS 64567a1
Fix black and typing warnings.
Laren-AWS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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: |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.