Skip to content

Commit

Permalink
collect_snippets separate from metadta parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSouther committed Jan 11, 2024
1 parent 883a5f6 commit 546da23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions .tools/validation/doc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ class DocGen:
snippet_files: set[str] = field(default_factory=set)
examples: list[Example] = field(default_factory=list)

def collect_snippets(self, snippets_root: Path | None):
if snippets_root is None:
snippets_root = self.root.parent.parent
snippets, errs = collect_snippets(snippets_root)
self.snippets = snippets
self.errors.extend(errs)

@classmethod
def from_root(cls, root: Path, snippets_root: Path | None = None) -> Self:
def from_root(cls, root: Path) -> Self:
errors = MetadataErrors()
metadata = root / ".doc_gen/metadata"

Expand All @@ -43,14 +50,9 @@ def from_root(cls, root: Path, snippets_root: Path | None = None) -> Self:
services, service_errors = parse_services("services.yaml", meta)
errors.extend(service_errors)

if snippets_root is None:
snippets_root = root.parent.parent
snippets, errs = collect_snippets(snippets_root)

doc_gen = cls(
sdks=sdks,
services=services,
snippets=snippets,
errors=errors,
root_path=root,
)
Expand Down
3 changes: 2 additions & 1 deletion .tools/validation/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def main():
args = parser.parse_args()
root_path = Path(args.root).resolve()

doc_gen = DocGen.from_root(root=root_path, snippets_root=root_path)
doc_gen = DocGen.from_root(root=root_path)
doc_gen.collect_snippets(snippets_root=root_path)
doc_gen.validate()

error_count = len(doc_gen.errors)
Expand Down

0 comments on commit 546da23

Please sign in to comment.