diff --git a/.tools/validation/sdks.yaml b/.doc_gen/metadata/sdks.yaml similarity index 100% rename from .tools/validation/sdks.yaml rename to .doc_gen/metadata/sdks.yaml diff --git a/.tools/validation/services.yaml b/.doc_gen/metadata/services.yaml similarity index 100% rename from .tools/validation/services.yaml rename to .doc_gen/metadata/services.yaml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index cbc2d90eb7f..89f1cb34620 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -32,7 +32,7 @@ jobs: python3 -m pip install -r .tools/base_requirements.txt - name: Lint metadata files run: >- - yamllint --format standard -c .tools/validation/.yamllint.yaml .doc_gen/metadata .tools/validation/sdks.yaml .tools/validation/services.yaml + yamllint --format standard -c .tools/validation/.yamllint.yaml .doc_gen/metadata - name: Validate metadata and repo run: >- python3 .tools/validation/validate.py --doc-gen .doc_gen diff --git a/.tools/readmes/multi.py b/.tools/readmes/multi.py index c196ace06cc..6d6d06c93da 100755 --- a/.tools/readmes/multi.py +++ b/.tools/readmes/multi.py @@ -13,7 +13,7 @@ def main(): - scanner = Scanner(".tools/validation", ".doc_gen/metadata") + scanner = Scanner(".doc_gen/metadata") sdks = scanner.sdks() lang_vers = [] for sdk in sdks: diff --git a/.tools/readmes/scanner.py b/.tools/readmes/scanner.py index 79e7a002a5e..44092075c6a 100644 --- a/.tools/readmes/scanner.py +++ b/.tools/readmes/scanner.py @@ -13,8 +13,7 @@ class Scanner: - def __init__(self, validation_folder, meta_folder): - self.validation_folder = validation_folder + def __init__(self, meta_folder): self.meta_folder = meta_folder self.lang_name = None self.svc_name = None @@ -24,14 +23,6 @@ def __init__(self, validation_folder, meta_folder): self.cross_meta = None self.snippets = None - def _load_validation(self, file_name, field): - if field is not None: - return field - sdk_file_name = f"{self.validation_folder}/{file_name}" - with open(sdk_file_name) as sdk_file: - meta = yaml.safe_load(sdk_file) - return meta - def _load_meta(self, file_name, field): if field is not None: return field @@ -41,10 +32,10 @@ def _load_meta(self, file_name, field): return meta def _load_sdks(self): - self.sdk_meta = self._load_validation("sdks.yaml", self.sdk_meta) + self.sdk_meta = self._load_meta("sdks.yaml", self.sdk_meta) def _load_services(self): - self.svc_meta = self._load_validation("services.yaml", self.svc_meta) + self.svc_meta = self._load_meta("services.yaml", self.svc_meta) def _load_cross(self): self.cross_meta = self._load_meta("cross_metadata.yaml", self.cross_meta) diff --git a/.tools/readmes/writeme.py b/.tools/readmes/writeme.py index 474fcf7f068..efcb2268ae0 100644 --- a/.tools/readmes/writeme.py +++ b/.tools/readmes/writeme.py @@ -11,7 +11,7 @@ def main(): - scanner = Scanner(".tools/validation", ".doc_gen/metadata") + scanner = Scanner(".doc_gen/metadata") sdks = scanner.sdks() lang_vers = [] for sdk in sdks: diff --git a/.tools/validation/doc_gen.py b/.tools/validation/doc_gen.py index 5f3e3730e99..8cf6750f2fe 100644 --- a/.tools/validation/doc_gen.py +++ b/.tools/validation/doc_gen.py @@ -40,17 +40,18 @@ def collect_snippets(self, snippets_root: Path | None): def from_root(cls, root: Path) -> Self: errors = MetadataErrors() - with open(Path(__file__).parent / "sdks.yaml", encoding="utf-8") as file: + metadata = root / ".doc_gen/metadata" + + with open(metadata / "sdks.yaml", encoding="utf-8") as file: meta = yaml.safe_load(file) sdks, errs = parse_sdks("sdks.yaml", meta) errors.extend(errs) - with open(Path(__file__).parent / "services.yaml", encoding="utf-8") as file: + with open(metadata / "services.yaml", encoding="utf-8") as file: meta = yaml.safe_load(file) services, service_errors = parse_services("services.yaml", meta) errors.extend(service_errors) - metadata = root / ".doc_gen/metadata" cross = set( [path.name for path in (metadata.parent / "cross-content").glob("*.xml")] ) diff --git a/.tools/validation/metadata_validator.py b/.tools/validation/metadata_validator.py index 9e310f0a77e..3bd4f7fcc1b 100755 --- a/.tools/validation/metadata_validator.py +++ b/.tools/validation/metadata_validator.py @@ -182,10 +182,14 @@ def validate_files( def validate_metadata(doc_gen_root: Path, errors: MetadataErrors) -> MetadataErrors: - with open(Path(__file__).parent / "sdks.yaml") as sdks_file: + with open( + Path(__file__).parent.parent.parent / ".doc_gen" / "metadata" / "sdks.yaml" + ) as sdks_file: sdks_yaml: dict[str, Any] = yaml.safe_load(sdks_file) - with open(Path(__file__).parent / "services.yaml") as services_file: + with open( + Path(__file__).parent.parent.parent / ".doc_gen" / "metadata" / "services.yaml" + ) as services_file: services_yaml = yaml.safe_load(services_file) SdkVersion.sdks = sdks_yaml