Skip to content

Commit 6afb217

Browse files
committed
refactor: simplify Nav module tracking by removing module_path prefix
1 parent f42ebab commit 6afb217

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

mise-tasks/gen/ref-pages.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,26 @@
2323

2424

2525
class Args(argparse.Namespace):
26+
src: Path
2627
api_root: Path
2728
docs_dir: Path
2829
print_nav: bool
29-
src: Path
3030

3131

3232
@dataclasses.dataclass
3333
class Nav:
34-
module_path: str = ""
34+
module: str = ""
3535
index: str | None = None
3636
children: dict[str, Nav] = dataclasses.field(default_factory=dict)
3737

3838
def add(self, parts: Sequence[str], full_doc_path: Path) -> None:
3939
if not parts:
40-
self.index = os.fspath(full_doc_path)
40+
self.index: str = os.fspath(full_doc_path)
4141
return
4242
if parts[0] in self.children:
43-
child = self.children[parts[0]]
43+
child: Nav = self.children[parts[0]]
4444
else:
45-
child = type(self)(
46-
module_path=f"{self.module_path}.{parts[0]}"
47-
if self.module_path
48-
else parts[0]
49-
)
45+
child: Nav = type(self)(module=parts[0])
5046
self.children[parts[0]] = child
5147
child.add(parts[1:], full_doc_path)
5248

@@ -58,7 +54,7 @@ def dump(self) -> Any:
5854
children.append(child.dump())
5955
if len(children) == 1:
6056
return children[0]
61-
return {f"{MODULE_SYMBOL} {self.module_path}": children}
57+
return {f"{MODULE_SYMBOL} {self.module}": children}
6258

6359

6460
def is_public(part: str) -> bool:

0 commit comments

Comments
 (0)