Skip to content

Commit

Permalink
Restore sdk and service yamls to where Zexii expects them
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSouther committed Jan 18, 2024
1 parent 72f3838 commit f1cff11
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 20 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .tools/readmes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 3 additions & 12 deletions .tools/readmes/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion .tools/readmes/writeme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions .tools/validation/doc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
)
Expand Down
8 changes: 6 additions & 2 deletions .tools/validation/metadata_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1cff11

Please sign in to comment.