Inventory: docs fixup

This commit is contained in:
Johannes Kirschbauer
2024-09-16 23:46:19 +02:00
parent a10bb59169
commit cfa1fca76e
3 changed files with 17 additions and 23 deletions

View File

@@ -106,10 +106,23 @@ def extract_frontmatter(readme_content: str, err_scope: str) -> tuple[Frontmatte
)
def has_inventory_feature(module_path: Path) -> bool:
readme_file = module_path / "README.md"
if not readme_file.exists():
return False
with readme_file.open() as f:
readme = f.read()
frontmatter, _ = extract_frontmatter(readme, f"{module_path}")
return "inventory" in frontmatter.features
def get_roles(module_path: Path) -> None | list[str]:
if not has_inventory_feature(module_path):
return None
roles_dir = module_path / "roles"
if not roles_dir.exists() or not roles_dir.is_dir():
return None
return ["default"]
return [
role.stem # filename without .nix extension