This commit is contained in:
CreaRobotics committed 2026-03-02 11:34:40 +01:00
1 parent 6ccab0347b
commit 954a2fd6d6
18684 files changed
+601012 -190

No files matched your search

@@ -0,0 +1,36 @@
from __future__ import annotations
import abc
from typing import TYPE_CHECKING, Iterable
if TYPE_CHECKING:
from mkdocs.structure.nav import Section
class StructureItem(metaclass=abc.ABCMeta):
"""An item in MkDocs structure - see concrete subclasses Section, Page or Link."""
@abc.abstractmethod
def __init__(self):
...
parent: Section | None = None
"""The immediate parent of the item in the site navigation. `None` if it's at the top level."""
@property
def is_top_level(self) -> bool:
return self.parent is None
title: str | None
is_section: bool = False
is_page: bool = False
is_link: bool = False
@property
def ancestors(self) -> Iterable[StructureItem]:
if self.parent is None:
return []
return [self.parent, *self.parent.ancestors]
def _indent_print(self, depth: int = 0) -> str:
return (' ' * depth) + repr(self)