introspection

This commit is contained in:
2026-01-20 20:24:22 +05:30
parent c910da9d14
commit 102ea4e215
26 changed files with 525 additions and 0 deletions

31
docforge/model/object.py Normal file
View File

@@ -0,0 +1,31 @@
from __future__ import annotations
from typing import Dict, Iterable, Optional
class DocObject:
"""Represents a documented Python object."""
def __init__(
self,
name: str,
kind: str,
path: str,
signature: Optional[str] = None,
docstring: Optional[str] = None,
) -> None:
self.name = name
self.kind = kind
self.path = path
self.signature = signature
self.docstring = docstring
self.members: Dict[str, DocObject] = {}
def add_member(self, obj: DocObject) -> None:
self.members[obj.name] = obj
def get_member(self, name: str) -> DocObject:
return self.members[name]
def get_all_members(self) -> Iterable[DocObject]:
return self.members.values()