25 lines
676 B
Python
25 lines
676 B
Python
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List
|
|
|
|
from docforge.nav.resolver import ResolvedNav
|
|
|
|
|
|
class MkDocsNavEmitter:
|
|
"""Emit MkDocs-compatible nav structure."""
|
|
|
|
def emit(self, nav: ResolvedNav) -> List[Dict[str, Any]]:
|
|
result: List[Dict[str, Any]] = []
|
|
|
|
if nav.home:
|
|
result.append({"Home": nav.home})
|
|
|
|
for group, paths in nav.groups.items():
|
|
entries: List[Dict[str, str]] = []
|
|
for path in paths:
|
|
title = path.stem.replace("_", " ").title()
|
|
entries.append({title: path.as_posix()})
|
|
result.append({group: entries})
|
|
|
|
return result
|